diff options
author | deniel <deniel@f5534014-38df-0310-8fa8-9805f1628bb7> | 2003-06-22 16:09:04 +0000 |
---|---|---|
committer | deniel <deniel@f5534014-38df-0310-8fa8-9805f1628bb7> | 2003-06-22 16:09:04 +0000 |
commit | 3ed86f10709f0b69617915978e89e6faa80654a3 (patch) | |
tree | f3e3d0937ff44b3b9ecb0d03d7fd4274e63adcb9 /tethereal.c | |
parent | f033d2858de715c44bb958ee5aaa035365f3b602 (diff) |
Ringbuffer rework.
Almost completely rewritten in order to:
- be able to use a unlimited number of ringbuffer files
0 specified with -b argument or in the GUI, means that the number of file
is unlimited.
else the maximum number of ring buffer files is arbitrarily set to 1024.
- close the current file and open (truncating it) the next file at switch
- set the final file name once open (or reopen)
- avoid the deletion of files that could not be truncated (can't arise now)
and do not erase empty files
The idea behind that is to remove the limitation of the maximum # of
ringbuffer files being less than the maximum # of open fd per process
and to be able to reduce the amount of virtual memory usage (having only
one file open at most) or the amount of file system usage (by truncating
the files at switch and not the capture stop, and by closing them which
makes possible their move or deletion after a switch).
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@7912 f5534014-38df-0310-8fa8-9805f1628bb7
Diffstat (limited to 'tethereal.c')
-rw-r--r-- | tethereal.c | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/tethereal.c b/tethereal.c index 07a0c89ec9..4d3835fca9 100644 --- a/tethereal.c +++ b/tethereal.c @@ -1,6 +1,6 @@ /* tethereal.c * - * $Id: tethereal.c,v 1.187 2003/06/13 03:44:36 guy Exp $ + * $Id: tethereal.c,v 1.188 2003/06/22 16:06:03 deniel Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -255,7 +255,7 @@ print_usage(gboolean print_ver) #ifdef HAVE_LIBPCAP static int -get_positive_int(const char *string, const char *name) +get_natural_int(const char *string, const char *name) { long number; char *p; @@ -271,11 +271,6 @@ get_positive_int(const char *string, const char *name) name); exit(1); } - if (number == 0) { - fprintf(stderr, "tethereal: The specified %s is zero\n", - name); - exit(1); - } if (number > INT_MAX) { fprintf(stderr, "tethereal: The specified %s is too large (greater than %d)\n", name, INT_MAX); @@ -284,6 +279,22 @@ get_positive_int(const char *string, const char *name) return number; } +static int +get_positive_int(const char *string, const char *name) +{ + long number; + + number = get_natural_int(string, name); + + if (number == 0) { + fprintf(stderr, "tethereal: The specified %s is zero\n", + name); + exit(1); + } + + return number; +} + /* * Given a string of the form "<autostop criterion>:<value>", as might appear * as an argument to a "-a" option, parse it and set the criterion in @@ -350,7 +361,7 @@ get_ring_arguments(const char *arg) } capture_opts.ringbuffer_num_files = - get_positive_int(arg, "number of ring buffer files"); + get_natural_int(arg, "number of ring buffer files"); if (colonp == NULL) return TRUE; |