forked from osmocom/wireshark
dumpcap: do all packet counting in capture_loop_wrote_one_packet().
We need to update global_ld.inpkts_to_sync_pipe as soon as we've written a packet to the current capture file. If we're writing to multiple files, then, if we delay counting until after we switch to another file, the packet-count message we send to the parent before switching won't include the packet, and the first packet-count message we send to the parent *after* switching *will* include the packet, which could mean the parent will try to read more packets than there are in the new file, in which case it'll get an EOF and, at least in the case of TShark, treat that as an error and stop capturing. This should fix issue #17654. While we're at it, don't send a "we have no packets" packet-count message even for the packet-count message we send just before switching files.
This commit is contained in:
parent
74747c4d2f
commit
79920cbc5f
13
dumpcap.c
13
dumpcap.c
|
@ -3760,9 +3760,11 @@ do_file_switch_or_stop(capture_options *capture_opts)
|
|||
global_ld.next_interval_time = get_next_time_interval(global_ld.interval_s);
|
||||
}
|
||||
fflush(global_ld.pdh);
|
||||
if (!quiet)
|
||||
report_packet_count(global_ld.inpkts_to_sync_pipe);
|
||||
global_ld.inpkts_to_sync_pipe = 0;
|
||||
if (global_ld.inpkts_to_sync_pipe) {
|
||||
if (!quiet)
|
||||
report_packet_count(global_ld.inpkts_to_sync_pipe);
|
||||
global_ld.inpkts_to_sync_pipe = 0;
|
||||
}
|
||||
report_new_capture_file(capture_opts->save_file);
|
||||
} else {
|
||||
/* File switch failed: stop here */
|
||||
|
@ -4081,8 +4083,6 @@ capture_loop_start(capture_options *capture_opts, gboolean *stats_known, struct
|
|||
#endif
|
||||
|
||||
if (inpkts > 0) {
|
||||
global_ld.inpkts_to_sync_pipe += inpkts;
|
||||
|
||||
if (capture_opts->output_to_pipe) {
|
||||
fflush(global_ld.pdh);
|
||||
}
|
||||
|
@ -4161,7 +4161,6 @@ capture_loop_start(capture_options *capture_opts, gboolean *stats_known, struct
|
|||
if (!dequeued) {
|
||||
break;
|
||||
}
|
||||
global_ld.inpkts_to_sync_pipe += 1;
|
||||
if (capture_opts->output_to_pipe) {
|
||||
fflush(global_ld.pdh);
|
||||
}
|
||||
|
@ -4475,6 +4474,8 @@ static void
|
|||
capture_loop_wrote_one_packet(capture_src *pcap_src) {
|
||||
global_ld.packets_captured++;
|
||||
global_ld.packets_written++;
|
||||
global_ld.inpkts_to_sync_pipe++;
|
||||
|
||||
if (!use_threads) {
|
||||
pcap_src->received++;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue