From 25e8c37489cf6503e7ce8c436f19f54bf7a5027a Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Sat, 29 Apr 2006 17:54:46 +0000 Subject: Have the ring buffer routines take a pointer to a "bytes written" count as an argument, rather than keeping the count to themselves, so the count kept by the capturing program can be updated correctly - including getting reset when files are switched. Fixes bug 895. svn path=/trunk/; revision=18032 --- ringbuffer.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'ringbuffer.c') diff --git a/ringbuffer.c b/ringbuffer.c index 7d1e00af66..f4cf4b0d32 100644 --- a/ringbuffer.c +++ b/ringbuffer.c @@ -88,7 +88,6 @@ typedef struct _ringbuf_data { int fd; /* Current ringbuffer file descriptor */ FILE *pdh; - long bytes_written; /* Bytes written to the current file */ } ringbuf_data; static ringbuf_data rb_data; @@ -231,14 +230,15 @@ const gchar *ringbuf_current_filename(void) * Calls libpcap_fdopen() for the current ringbuffer file */ FILE * -ringbuf_init_libpcap_fdopen(int linktype, int snaplen, int *err) +ringbuf_init_libpcap_fdopen(int linktype, int snaplen, + long *bytes_written, int *err) { rb_data.linktype = linktype; rb_data.snaplen = snaplen; - rb_data.pdh = libpcap_fdopen(rb_data.fd, linktype, snaplen, - &rb_data.bytes_written, err); + rb_data.pdh = libpcap_fdopen(rb_data.fd, linktype, snaplen, bytes_written, + err); return rb_data.pdh; } @@ -246,7 +246,8 @@ ringbuf_init_libpcap_fdopen(int linktype, int snaplen, int *err) * Switches to the next ringbuffer file */ gboolean -ringbuf_switch_file(FILE **pdh, gchar **save_file, int *save_file_fd, int *err) +ringbuf_switch_file(FILE **pdh, gchar **save_file, int *save_file_fd, + long *bytes_written, int *err) { int next_file_num; rb_file *next_rfile = NULL; @@ -274,7 +275,7 @@ ringbuf_switch_file(FILE **pdh, gchar **save_file, int *save_file_fd, int *err) } if (ringbuf_init_libpcap_fdopen(rb_data.linktype, rb_data.snaplen, - err) == NULL) { + bytes_written, err) == NULL) { return FALSE; } -- cgit v1.2.3