aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUlf Lamping <ulf.lamping@web.de>2005-10-06 00:55:21 +0000
committerUlf Lamping <ulf.lamping@web.de>2005-10-06 00:55:21 +0000
commitbb5e5d6ce10fe015e1c7aabcca8c51d097b5c789 (patch)
tree433f89941372c48953ab394a1dda36da8b645606
parent70d49795575878ccb1f4a48536243866ba6a61ef (diff)
fix a packet_list_freeze / thaw pair, if a return comes in it's way
add a g_warning() call if an error occured while reading from capture file (while doing a live update), usually shouldn't happen but is difficult to debug *if* it happens add a new log domain LOG_DOMAIN_MAIN and the standard log handler for it add some (partly commented out) g_log() calls, useful for GUI sequence debugging svn path=/trunk/; revision=16136
-rw-r--r--file.c13
-rw-r--r--gtk/gui_utils.c11
-rw-r--r--gtk/main.c18
-rw-r--r--log.h2
4 files changed, 42 insertions, 2 deletions
diff --git a/file.c b/file.c
index cdab76a8e8..a555092ec1 100644
--- a/file.c
+++ b/file.c
@@ -554,6 +554,8 @@ cf_continue_tail(capture_file *cf, int to_read, int *err)
packet_list_freeze();
+ /*g_log(NULL, G_LOG_LEVEL_MESSAGE, "cf_continue_tail: %u new: %u", cf->count, to_read);*/
+
while (to_read != 0 && (wtap_read(cf->wth, err, &err_info, &data_offset))) {
if (cf->state == FILE_READ_ABORTED) {
/* Well, the user decided to exit Ethereal. Break out of the
@@ -565,6 +567,9 @@ cf_continue_tail(capture_file *cf, int to_read, int *err)
to_read--;
}
+ /*g_log(NULL, G_LOG_LEVEL_MESSAGE, "cf_continue_tail: count %u state: %u err: %u",
+ cf->count, cf->state, *err);*/
+
/* XXX - this cheats and looks inside the packet list to find the final
row number. */
if (auto_scroll_live && cf->plist_end != NULL)
@@ -581,7 +586,10 @@ cf_continue_tail(capture_file *cf, int to_read, int *err)
return CF_READ_ABORTED;
} else if (*err != 0) {
/* We got an error reading the capture file.
- XXX - pop up a dialog box? */
+ XXX - pop up a dialog box instead? */
+ g_warning("Error \"%s\" while reading: \"%s\"\n",
+ wtap_strerror(*err), cf->filename);
+
return CF_READ_ERROR;
} else
return CF_READ_OK;
@@ -610,6 +618,8 @@ cf_finish_tail(capture_file *cf, int *err)
read_packet(cf, data_offset);
}
+ packet_list_thaw();
+
if (cf->state == FILE_READ_ABORTED) {
/* Well, the user decided to abort the read. We're only called
when the child capture process closes the pipe to us (meaning
@@ -620,7 +630,6 @@ cf_finish_tail(capture_file *cf, int *err)
return CF_READ_ABORTED;
}
- packet_list_thaw();
if (auto_scroll_live && cf->plist_end != NULL)
/* XXX - this cheats and looks inside the packet list to find the final
row number. */
diff --git a/gtk/gui_utils.c b/gtk/gui_utils.c
index c42e9fbf21..725dcfcb08 100644
--- a/gtk/gui_utils.c
+++ b/gtk/gui_utils.c
@@ -637,6 +637,8 @@ pipe_timer_cb(gpointer data)
/* try to read data from the pipe only 5 times, to avoid blocking */
while(iterations < 5) {
+ /*g_log(NULL, G_LOG_LEVEL_DEBUG, "pipe_timer_cb: new iteration");*/
+
/* Oddly enough although Named pipes don't work on win9x,
PeekNamedPipe does !!! */
handle = (HANDLE) _get_osfhandle (pipe_input->source);
@@ -651,7 +653,10 @@ pipe_timer_cb(gpointer data)
callback */
if (!result || avail > 0 || childstatus != STILL_ACTIVE) {
+ /*g_log(NULL, G_LOG_LEVEL_DEBUG, "pipe_timer_cb: data avail");*/
+
if(pipe_input->pipe_input_id != 0) {
+ /*g_log(NULL, G_LOG_LEVEL_DEBUG, "pipe_timer_cb: stop timer");*/
/* avoid reentrancy problems and stack overflow */
gtk_timeout_remove(pipe_input->pipe_input_id);
pipe_input->pipe_input_id = 0;
@@ -659,11 +664,13 @@ pipe_timer_cb(gpointer data)
/* And call the real handler */
if (!pipe_input->input_cb(pipe_input->source, pipe_input->user_data)) {
+ g_log(NULL, G_LOG_LEVEL_DEBUG, "pipe_timer_cb: input pipe closed, iterations: %u", iterations);
/* pipe closed, return false so that the old timer is not run again */
return FALSE;
}
}
else {
+ /*g_log(NULL, G_LOG_LEVEL_DEBUG, "pipe_timer_cb: no data avail");*/
/* No data, stop now */
break;
}
@@ -674,10 +681,13 @@ pipe_timer_cb(gpointer data)
if(pipe_input->pipe_input_id == 0) {
/* restore pipe handler */
pipe_input->pipe_input_id = gtk_timeout_add(200, pipe_timer_cb, data);
+ /*g_log(NULL, G_LOG_LEVEL_DEBUG, "pipe_timer_cb: finished with iterations: %u, new timer", iterations);*/
/* Return false so that the old timer is not run again */
return FALSE;
} else {
+ /*g_log(NULL, G_LOG_LEVEL_DEBUG, "pipe_timer_cb: finished with iterations: %u, old timer", iterations);*/
+
/* we didn't stopped the old timer, so let it run */
return TRUE;
}
@@ -725,6 +735,7 @@ void pipe_input_set_handler(gint source, gpointer user_data, int *child_process,
this but doesn't seem to work over processes. Attempt to do
something similar here, start a timer and check for data on every
timeout. */
+ /*g_log(NULL, G_LOG_LEVEL_DEBUG, "pipe_input_set_handler: new");*/
pipe_input.pipe_input_id = gtk_timeout_add(200, pipe_timer_cb, &pipe_input);
#else
pipe_input.pipe_input_id = gtk_input_add_full(source,
diff --git a/gtk/main.c b/gtk/main.c
index b701578052..ca5ba4f9e2 100644
--- a/gtk/main.c
+++ b/gtk/main.c
@@ -1572,37 +1572,48 @@ static void main_cf_callback(gint event, gpointer data, gpointer user_data _U_)
{
switch(event) {
case(cf_cb_file_closing):
+ g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: Closing");
main_cf_cb_file_closing(data);
break;
case(cf_cb_file_closed):
+ g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: Closed");
main_cf_cb_file_closed(data);
break;
case(cf_cb_file_read_start):
+ g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: Read start");
main_cf_cb_file_read_start(data);
break;
case(cf_cb_file_read_finished):
+ g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: Read finished");
main_cf_cb_file_read_finished(data);
break;
#ifdef HAVE_LIBPCAP
case(cf_cb_live_capture_prepared):
+ g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: capture prepared");
main_cf_cb_live_capture_prepared(data);
break;
case(cf_cb_live_capture_update_started):
+ g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: capture update started");
main_cf_cb_live_capture_update_started(data);
break;
case(cf_cb_live_capture_update_continue):
+ /*g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: capture update continue");*/
main_cf_cb_live_capture_update_continue(data);
break;
case(cf_cb_live_capture_fixed_started):
+ g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: capture fixed started");
main_cf_cb_live_capture_fixed_started(data);
break;
case(cf_cb_live_capture_update_finished):
+ g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: capture update finished");
main_cf_cb_live_capture_update_finished(data);
break;
case(cf_cb_live_capture_fixed_finished):
+ g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: capture fixed finished");
main_cf_cb_live_capture_fixed_finished(data);
break;
case(cf_cb_live_capture_stopping):
+ g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: capture stopping");
main_cf_cb_live_capture_stopping(data);
break;
#endif
@@ -1616,15 +1627,19 @@ static void main_cf_callback(gint event, gpointer data, gpointer user_data _U_)
main_cf_cb_field_unselected(data);
break;
case(cf_cb_file_safe_started):
+ g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: safe started");
main_cf_cb_file_safe_started(data);
break;
case(cf_cb_file_safe_finished):
+ g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: safe finished");
main_cf_cb_file_safe_finished(data);
break;
case(cf_cb_file_safe_reload_finished):
+ g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: reload finished");
main_cf_cb_file_safe_reload_finished(data);
break;
case(cf_cb_file_safe_failed):
+ g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: safe failed");
main_cf_cb_file_safe_failed(data);
break;
default:
@@ -1830,6 +1845,9 @@ main(int argc, char *argv[])
g_log_set_handler(NULL,
log_flags,
console_log_handler, NULL /* user_data */);
+ g_log_set_handler(LOG_DOMAIN_MAIN,
+ log_flags,
+ console_log_handler, NULL /* user_data */);
#ifdef HAVE_LIBPCAP
g_log_set_handler(LOG_DOMAIN_CAPTURE,
diff --git a/log.h b/log.h
index 56bb60d6f2..4d13bbecf2 100644
--- a/log.h
+++ b/log.h
@@ -31,6 +31,8 @@
/* capture child domain (the capture child might also contain file domain messages!) */
#define LOG_DOMAIN_CAPTURE_CHILD "CaptureChild"
+/* main domain */
+#define LOG_DOMAIN_MAIN "Main"
/* enable very verbose capture log debug output */
/*#define LOG_CAPTURE_VERBOSE*/