From 07c73adaee2313e4c8e289212d048bdc013c0075 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stig=20Bj=C3=B8rlykke?= Date: Tue, 19 Feb 2019 19:02:30 +0100 Subject: Qt: Fix restart capture when using a ring buffer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Set capture_opts->restart before restart current capture. Update the restart handling in capture_input_closed() to not remove the current save file; this is either the last file in a ring buffer or a temporary file which will be reused later. Also remove the code which starts the capture again because this is now done in MainWindow::on_actionCaptureRestart_triggered(). Keep the code to restore the original save file when having a ring buffer. This will avoid the error message "Ring buffer requested, but capture isn't being saved to a permanent file" and a following unwanted capture stop. This fix will also avoid the "No packets captured" warning when restart capture without having any packets captured. Remove the unused capture_restart() function which was used in GTK. Change-Id: I80802217b71810eaa36b78a2eb4c32697ddc92ce Reviewed-on: https://code.wireshark.org/review/32110 Petri-Dish: Stig Bjørlykke Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman --- ui/capture.c | 30 ------------------------------ ui/capture.h | 4 ---- ui/qt/main_window_slots.cpp | 2 +- 3 files changed, 1 insertion(+), 35 deletions(-) diff --git a/ui/capture.c b/ui/capture.c index eabf92bc1c..0ecebde116 100644 --- a/ui/capture.c +++ b/ui/capture.c @@ -178,18 +178,6 @@ capture_stop(capture_session *cap_session) } -void -capture_restart(capture_session *cap_session) -{ - capture_options *capture_opts = cap_session->capture_opts; - - g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_MESSAGE, "Capture Restart"); - - capture_opts->restart = TRUE; - capture_stop(cap_session); -} - - void capture_kill_child(capture_session *cap_session) { @@ -732,30 +720,12 @@ capture_input_closed(capture_session *cap_session, gchar *msg) if(capture_opts->restart) { capture_opts->restart = FALSE; - ws_unlink(capture_opts->save_file); - /* If we have a ring buffer, the original save file has been overwritten with the "ring filename". Restore it before starting again */ if ((capture_opts->multi_files_on) && (capture_opts->orig_save_file != NULL)) { g_free(capture_opts->save_file); capture_opts->save_file = g_strdup(capture_opts->orig_save_file); } - - /* if it was a tempfile, throw away the old filename (so it will become a tempfile again) */ - if(cf_is_tempfile((capture_file *)cap_session->cf)) { - g_free(capture_opts->save_file); - capture_opts->save_file = NULL; - } - - /* ... and start the capture again */ - if (capture_opts->ifaces->len == 0) { - collect_ifaces(capture_opts); - } - - /* close the currently loaded capture file */ - cf_close((capture_file *)cap_session->cf); - - capture_start(capture_opts, cap_session, cap_session->cap_data_info, NULL); /*XXX is this NULL ok or we need an update_cb???*/ } else { /* We're not doing a capture any more, so we don't have a save file. */ g_free(capture_opts->save_file); diff --git a/ui/capture.h b/ui/capture.h index d4de9efe09..0494878267 100644 --- a/ui/capture.h +++ b/ui/capture.h @@ -62,10 +62,6 @@ capture_start(capture_options *capture_opts, capture_session *cap_session, info_ extern void capture_stop(capture_session *cap_session); -/** Restart the current captured packets and start again. */ -extern void -capture_restart(capture_session *cap_session); - /** Terminate the capture child cleanly when exiting. */ extern void capture_kill_child(capture_session *cap_session); diff --git a/ui/qt/main_window_slots.cpp b/ui/qt/main_window_slots.cpp index b3bdcacf0b..8358db011d 100644 --- a/ui/qt/main_window_slots.cpp +++ b/ui/qt/main_window_slots.cpp @@ -3616,10 +3616,10 @@ void MainWindow::on_actionCaptureStop_triggered() void MainWindow::on_actionCaptureRestart_triggered() { QString before_what(tr(" before restarting the capture")); + cap_session_.capture_opts->restart = TRUE; if (!testCaptureFileClose(before_what, Restart)) return; -/* TODO: GTK use only this: capture_restart(&cap_session_); */ startCapture(); } -- cgit v1.2.3