Changeset f875681


Ignore:
Timestamp:
06/23/06 11:59:38 (15 years ago)
Author:
Perry Lorier <perry@…>
Branches:
4.0.1-hotfixes, cachetimestamps, develop, dpdk-ndag, etsilive, getfragoff, help, libtrace4, master, ndag_format, pfring, rc-4.0.1, rc-4.0.2, rc-4.0.3, rc-4.0.4, ringdecrementfix, ringperformance, ringtimestampfixes
Children:
c5ebbaa
Parents:
430077b
Message:

Deal better with errors in pcap:

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/format_pcap.c

    rcd7eec7 rf875681  
    249249static int pcap_fin_output(libtrace_out_t *libtrace)
    250250{
    251         pcap_dump_flush(OUTPUT.trace.dump);
    252         pcap_dump_close(OUTPUT.trace.dump);
     251        if (OUTPUT.trace.dump) {
     252                pcap_dump_flush(OUTPUT.trace.dump);
     253                pcap_dump_close(OUTPUT.trace.dump);
     254        }
    253255        pcap_close(OUTPUT.trace.pcap);
    254256        free(libtrace->format_data);
     
    319321                        libtrace_to_pcap_dlt(trace_get_link_type(packet)),
    320322                        65536);
     323                if (!OUTPUT.trace.pcap) {
     324                        trace_set_err_out(libtrace,TRACE_ERR_INIT_FAILED,"Failed to open dead trace: %s\n",
     325                                        pcap_geterr(OUTPUT.trace.pcap));
     326                }
    321327                OUTPUT.trace.dump = pcap_dump_open(OUTPUT.trace.pcap,
    322328                                libtrace->uridata);
    323                 fflush((FILE *)OUTPUT.trace.dump);
     329                if (!OUTPUT.trace.dump) {
     330                        char *errmsg = pcap_geterr(OUTPUT.trace.pcap);
     331                        trace_set_err_out(libtrace,TRACE_ERR_INIT_FAILED,"Failed to open output file: %s\n",
     332                                        errmsg ? errmsg : "Unknown error");
     333                        return -1;
     334                }
    324335        }
    325336        if (packet->trace->format == &pcap ||
Note: See TracChangeset for help on using the changeset viewer.