summaryrefslogtreecommitdiff
path: root/ringbuffer.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2002-06-23 20:30:01 +0000
committerGuy Harris <guy@alum.mit.edu>2002-06-23 20:30:01 +0000
commit7ad0ca82b1e58101bba7cadff5114eeaf8d098c6 (patch)
tree08dfcf5c0bf330f90a20e51af0d052eb723f7c3b /ringbuffer.c
parent008c41a753f8ab95ad51feaccc8c9808fc4d3929 (diff)
downloadwireshark-7ad0ca82b1e58101bba7cadff5114eeaf8d098c6.tar.gz
From Graeme Hewson: flush the output after every frame if Tethereal is
writing a capture to a FIFO, and improve the error checking for ring buffers. svn path=/trunk/; revision=5745
Diffstat (limited to 'ringbuffer.c')
-rw-r--r--ringbuffer.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/ringbuffer.c b/ringbuffer.c
index d317ba78a7..d9740bf47a 100644
--- a/ringbuffer.c
+++ b/ringbuffer.c
@@ -1,7 +1,7 @@
/* ringbuffer.c
* Routines for packet capture windows
*
- * $Id: ringbuffer.c,v 1.2 2002/05/04 10:10:42 guy Exp $
+ * $Id: ringbuffer.c,v 1.3 2002/06/23 20:30:01 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -219,7 +219,12 @@ ringbuf_init_wtap_dump_fdopen(int filetype, int linktype,
}
return NULL;
}
- rb_data.files[i].start_pos = ftell(fh);
+ if ((rb_data.files[i].start_pos = ftell(fh)) < 0) {
+ if (err != NULL) {
+ *err = errno;
+ }
+ return NULL;
+ }
clearerr(fh);
}
}
@@ -236,6 +241,7 @@ ringbuf_switch_file(capture_file *cf, wtap_dumper **pdh, int *err)
{
int next_file_num;
FILE *fh;
+ gboolean err_on_next = FALSE;
/* flush the current file */
fh = wtap_dump_file(rb_data.files[rb_data.curr_file_num].pdh);
@@ -254,7 +260,11 @@ ringbuf_switch_file(capture_file *cf, wtap_dumper **pdh, int *err)
if (!rb_data.files[next_file_num].is_new) {
/* rewind to the position after the file header */
fh = wtap_dump_file(rb_data.files[next_file_num].pdh);
- fseek(fh, rb_data.files[next_file_num].start_pos, SEEK_SET);
+ if (fseek(fh, rb_data.files[next_file_num].start_pos, SEEK_SET) < 0) {
+ *err = errno;
+ /* Don't return straight away: have caller report correct save_file */
+ err_on_next = TRUE;
+ }
wtap_set_bytes_dumped(rb_data.files[next_file_num].pdh,
rb_data.files[next_file_num].start_pos);
/* set the absolute file number */
@@ -273,6 +283,9 @@ ringbuf_switch_file(capture_file *cf, wtap_dumper **pdh, int *err)
/* finally set the current file number */
rb_data.curr_file_num = next_file_num;
+ if (err_on_next)
+ return FALSE;
+
return TRUE;
}