fix a packet_list_freeze / thaw pair, if a return comes in it's way
authorulfl <ulfl@f5534014-38df-0310-8fa8-9805f1628bb7>
Thu, 6 Oct 2005 00:55:21 +0000 (00:55 +0000)
committerulfl <ulfl@f5534014-38df-0310-8fa8-9805f1628bb7>
Thu, 6 Oct 2005 00:55:21 +0000 (00:55 +0000)
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

git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@16136 f5534014-38df-0310-8fa8-9805f1628bb7

file.c
gtk/gui_utils.c
gtk/main.c
log.h

diff --git a/file.c b/file.c
index cdab76a8e846d46eda1530b7d82fac4f737c5fdb..a555092ec15b251fd8874ef49b963f52d7e70df1 100644 (file)
--- 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. */
index c42e9fbf2130a793121bac6facc6f8d57fb36b49..725dcfcb08f240d131930631594b50c73b7b9515 100644 (file)
@@ -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,
index b701578052b12309454d7384db0bfc4930f0b5d6..ca5ba4f9e2ecc4d3b1fbe1a602c65f9775184a03 100644 (file)
@@ -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 56bb60d6f2951a50ae6489d6197039ab24492b54..4d13bbecf2bfee51497e2778a7a139bf14f4d9aa 100644 (file)
--- 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*/