If doing a catpure with "-S", as soon as we've created the capture file
authorguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Tue, 20 Jul 1999 06:16:09 +0000 (06:16 +0000)
committerguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Tue, 20 Jul 1999 06:16:09 +0000 (06:16 +0000)
(this assumes that "libpcap" writes out the header as soon as that
happens, which is the case for "libpcap" 0.4), we sync it out (to make
sure said header is in the file), and signal the parent process, so that
it opens the capture file and updates its windows to indicate that the
capture is in progress.

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

capture.c
capture.h

index d68c81c597550ae6e2cb7c3afa9854457ac4a19b..b7ebe8ca89ff556de8cb757e0eb18e769721a56b 100644 (file)
--- a/capture.c
+++ b/capture.c
@@ -1,7 +1,7 @@
 /* capture.c
  * Routines for packet capture windows
  *
 /* capture.c
  * Routines for packet capture windows
  *
- * $Id: capture.c,v 1.32 1999/07/20 05:07:57 guy Exp $
+ * $Id: capture.c,v 1.33 1999/07/20 06:16:08 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@zing.org>
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@zing.org>
@@ -411,7 +411,6 @@ capture(void) {
   ld.counts.total = 0;
   ld.max          = cf.count;
   ld.linktype     = DLT_NULL;
   ld.counts.total = 0;
   ld.max          = cf.count;
   ld.linktype     = DLT_NULL;
-  ld.signal_sent  = 0;
   ld.sync_time    = 0;
   ld.counts.tcp   = 0;
   ld.counts.udp   = 0;
   ld.sync_time    = 0;
   ld.counts.tcp   = 0;
   ld.counts.udp   = 0;
@@ -451,6 +450,15 @@ capture(void) {
       }
     }
 
       }
     }
 
+    if (sync_mode) {
+      /* Sync out the capture file, so the header makes it to the file
+         system, and signal our parent so that they'll open the capture
+        file and update its windows to indicate that we have a live
+        capture in progress. */
+      fflush((FILE *)ld.pdh);
+      kill(getppid(), SIGUSR2);
+    }
+
     cap_w = gtk_window_new(GTK_WINDOW_TOPLEVEL);
     gtk_window_set_title(GTK_WINDOW(cap_w), "Ethereal: Capture / Playback");
 
     cap_w = gtk_window_new(GTK_WINDOW_TOPLEVEL);
     gtk_window_set_title(GTK_WINDOW(cap_w), "Ethereal: Capture / Playback");
 
@@ -622,15 +630,6 @@ capture_pcap_cb(u_char *user, const struct pcap_pkthdr *phdr,
       capture_raw(pd, phdr->caplen, &ld->counts);
       break;
   }
       capture_raw(pd, phdr->caplen, &ld->counts);
       break;
   }
-
-  if (sync_mode && !ld->signal_sent) {
-    /* will trigger the father to open the cap file which contains 
-       at least one complete packet */
-    fflush((FILE *)ld->pdh);
-    kill(getppid(), SIGUSR2);
-    ld->signal_sent = 1;
-  }
-  
 }
 
 #endif /* HAVE_LIBPCAP */
 }
 
 #endif /* HAVE_LIBPCAP */
index 18ca05a1c0da8f8e7684b366b01c18548da4c2d8..43395bf067726885103c5a5695715bee938daf9f 100644 (file)
--- a/capture.h
+++ b/capture.h
@@ -1,7 +1,7 @@
 /* capture.h
  * Definitions for packet capture windows
  *
 /* capture.h
  * Definitions for packet capture windows
  *
- * $Id: capture.h,v 1.8 1999/07/09 04:18:33 gram Exp $
+ * $Id: capture.h,v 1.9 1999/07/20 06:16:09 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@zing.org>
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@zing.org>
@@ -36,7 +36,6 @@ typedef struct _loop_data {
   gint           go;
   gint           max;
   gint           linktype;
   gint           go;
   gint           max;
   gint           linktype;
-  gint           signal_sent;
   time_t         sync_time;
   packet_counts  counts;
   pcap_dumper_t *pdh;
   time_t         sync_time;
   packet_counts  counts;
   pcap_dumper_t *pdh;