forked from osmocom/wireshark
Proto hierarchy stats: obtain capture file read lock
Obtain the capture file read lock when computing protocol hierarchy stats to prevent segfaulting if the file is closed. The protocol hierarchy stats are always computed on all the packets of the current file that pass the current filter, so don't let it run until a read or rescan is complete. Since the protocol hierarchy stats use the common progress bar, these two changes keep it from hijacking the progress bar when a rescan is in progress, which led to anomolies with the stop button behavior and clearing the progress bar when the stats were done (but not the temporarily paused rescan.) Make the stop button actually stop the protocol hierarchy stats. In the future, the protocol hierarchy stats could perhaps use process_specified_records from file.c Fix #18787. Fix #18788.
This commit is contained in:
parent
89188380ae
commit
acf0ee420f
|
@ -201,7 +201,6 @@ ph_stats_new(capture_file *cf)
|
|||
guint32 framenum;
|
||||
frame_data *frame;
|
||||
progdlg_t *progbar = NULL;
|
||||
gboolean stop_flag;
|
||||
int count;
|
||||
wtap_rec rec;
|
||||
Buffer buf;
|
||||
|
@ -212,6 +211,14 @@ ph_stats_new(capture_file *cf)
|
|||
|
||||
if (!cf) return NULL;
|
||||
|
||||
if (cf->read_lock) {
|
||||
ws_warning("Failing to compute protocol hierarchy stats on \"%s\" since a read is in progress", cf->filename);
|
||||
return NULL;
|
||||
}
|
||||
cf->read_lock = TRUE;
|
||||
|
||||
cf->stop_flag = FALSE;
|
||||
|
||||
pc_proto_id = proto_registrar_get_id_byname("pkt_comment");
|
||||
|
||||
/* Initialize the data */
|
||||
|
@ -232,8 +239,6 @@ ph_stats_new(capture_file *cf)
|
|||
/* Progress so far. */
|
||||
progbar_val = 0.0f;
|
||||
|
||||
stop_flag = FALSE;
|
||||
|
||||
wtap_rec_init(&rec);
|
||||
ws_buffer_init(&buf, 1514);
|
||||
|
||||
|
@ -250,7 +255,7 @@ ph_stats_new(capture_file *cf)
|
|||
progbar = delayed_create_progress_dlg(
|
||||
cf->window, "Computing",
|
||||
"protocol hierarchy statistics",
|
||||
TRUE, &stop_flag, progbar_val);
|
||||
TRUE, &cf->stop_flag, progbar_val);
|
||||
|
||||
/* Update the progress bar, but do it only N_PROGBAR_UPDATES
|
||||
times; when we update it, we have to run the GTK+ main
|
||||
|
@ -275,7 +280,7 @@ ph_stats_new(capture_file *cf)
|
|||
progbar_nextstep += progbar_quantum;
|
||||
}
|
||||
|
||||
if (stop_flag) {
|
||||
if (cf->stop_flag) {
|
||||
/* Well, the user decided to abort the statistics.
|
||||
computation process Just stop. */
|
||||
break;
|
||||
|
@ -310,7 +315,7 @@ ph_stats_new(capture_file *cf)
|
|||
* just abort rather than popping up
|
||||
* the statistics window.
|
||||
*/
|
||||
stop_flag = TRUE;
|
||||
cf->stop_flag = TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -328,16 +333,19 @@ ph_stats_new(capture_file *cf)
|
|||
if (progbar != NULL)
|
||||
destroy_progress_dlg(progbar);
|
||||
|
||||
if (stop_flag) {
|
||||
if (cf->stop_flag) {
|
||||
/*
|
||||
* We quit in the middle; throw away the statistics
|
||||
* and return NULL, so our caller doesn't pop up a
|
||||
* window with the incomplete statistics.
|
||||
*/
|
||||
ph_stats_free(ps);
|
||||
return NULL;
|
||||
ps = NULL;
|
||||
}
|
||||
|
||||
ws_assert(cf->read_lock);
|
||||
cf->read_lock = FALSE;
|
||||
|
||||
return ps;
|
||||
}
|
||||
|
||||
|
|
|
@ -2461,6 +2461,11 @@ void WiresharkMainWindow::setMenusForCaptureFile(bool force_disable)
|
|||
main_ui_->actionFileSave->setEnabled(can_save);
|
||||
main_ui_->actionFileSaveAs->setEnabled(can_save_as);
|
||||
main_ui_->actionStatisticsCaptureFileProperties->setEnabled(enable);
|
||||
/* The Protocol Hierarchy statistics run on all the packets that
|
||||
* pass the current filter, don't enable if a read or rescan is
|
||||
* still in progress.
|
||||
*/
|
||||
main_ui_->actionStatisticsProtocolHierarchy->setEnabled(enable);
|
||||
/*
|
||||
* "Export Specified Packets..." should be available only if
|
||||
* we can write the file out in at least one format.
|
||||
|
|
Loading…
Reference in New Issue