diff options
author | Peter Wu <peter@lekensteyn.nl> | 2017-06-12 14:23:32 +0200 |
---|---|---|
committer | Peter Wu <peter@lekensteyn.nl> | 2017-06-17 14:29:49 +0000 |
commit | 51c57cee843a871c31a18306ccc136bcc0f44c87 (patch) | |
tree | 1a62fd386e60121284b31a82e00cc0eb5699cf22 /file.c | |
parent | 6c7ed876a2b9d9bed519bce9fed7ba78dde8202d (diff) | |
download | wireshark-51c57cee843a871c31a18306ccc136bcc0f44c87.tar.gz wireshark-51c57cee843a871c31a18306ccc136bcc0f44c87.tar.bz2 wireshark-51c57cee843a871c31a18306ccc136bcc0f44c87.zip |
Qt: fix hang on exiting Qt while loading capture file
testCaptureFileClose can also be invoked while reading an existing
capture file (the original comment only applied to GTK+, not Qt). When
the user quits Wireshark while reading an offline pcap, this could
result in a confusing "Unsaved packets" dialog. Fix this by checking the
actual capture session state.
After fixing this, the next issue is that cf_close trips on an assertion
("cf->state != FILE_READ_IN_PROGRESS"). To address this problem, do not
close the capture file immediately, but signal to the reader (cf_read)
that this should be done (similar to the quit logic in GTK+).
Bug: 13563
Change-Id: I12d4b813557bf354199320df2ed8609070fdc58a
Reviewed-on: https://code.wireshark.org/review/22096
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
(cherry picked from commit 800a856fb4784e31347e15a8ec825d2daeb62350)
Reviewed-on: https://code.wireshark.org/review/22190
Diffstat (limited to 'file.c')
-rw-r--r-- | file.c | 18 |
1 files changed, 18 insertions, 0 deletions
@@ -541,6 +541,7 @@ cf_read(capture_file *cf, gboolean reloading) volatile gboolean create_proto_tree; guint tap_flags; gboolean compiled; + volatile gboolean is_read_aborted = FALSE; /* Compile the current display filter. * We assume this will not fail since cf->dfilter is only set in @@ -642,6 +643,13 @@ cf_read(capture_file *cf, gboolean reloading) } } + if (cf->state == FILE_READ_ABORTED) { + /* Well, the user decided to exit Wireshark. Break out of the + loop, and let the code below (which is called even if there + aren't any packets left to read) exit. */ + is_read_aborted = TRUE; + break; + } if (cf->stop_flag) { /* Well, the user decided to abort the read. He/She will be warned and it might be enough for him/her to work with the already loaded @@ -717,6 +725,16 @@ cf_read(capture_file *cf, gboolean reloading) packet_list_select_first_row(); } + if (is_read_aborted) { + /* + * Well, the user decided to exit Wireshark while reading this *offline* + * capture file (Live captures are handled by something like + * cf_continue_tail). Clean up accordingly. + */ + cf_close(cf); + return CF_READ_ABORTED; + } + if (cf->stop_flag) { simple_message_box(ESD_TYPE_WARN, NULL, "The remaining packets in the file were discarded.\n" |