diff options
author | Guy Harris <guy@alum.mit.edu> | 2012-05-04 16:56:18 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2012-05-04 16:56:18 +0000 |
commit | 33bb54a9452f4be53377a185195a63194016241a (patch) | |
tree | 9308829e2105b6e51e0dc5cc0af2295d8d97a0a3 /wiretap/5views.c | |
parent | f65cb5f27bab6310e847f88cd763eb08bff1c93b (diff) |
file_seek() used to be a wrapper around fseek() or gzseek(), both of
which could use lseek() and were thus expensive due to system call
overhead. To avoid making a system call for every packet on a
sequential read, we maintained a data_offset field in the wtap structure
for sequential reads.
It's now a routine that just returns information from the FILE_T data
structure, so it's cheap. Use it, rather than maintaining the data_offset
field.
Readers for some file formats need to maintain file offset themselves;
have them do so in their private data structures.
svn path=/trunk/; revision=42423
Diffstat (limited to 'wiretap/5views.c')
-rw-r--r-- | wiretap/5views.c | 8 |
1 files changed, 1 insertions, 7 deletions
diff --git a/wiretap/5views.c b/wiretap/5views.c index 1ad604204f..f3cfda1865 100644 --- a/wiretap/5views.c +++ b/wiretap/5views.c @@ -134,8 +134,6 @@ int _5views_open(wtap *wth, int *err, gchar **err_info) return 0; } - wth->data_offset+=bytes_read; - /* Check whether that's 5Views format or not */ if(Capture_Header.Info_Header.Signature != CST_5VW_INFO_HEADER_KEY) { @@ -189,7 +187,6 @@ int _5views_open(wtap *wth, int *err, gchar **err_info) return -1; return 0; } - wth->data_offset+=bytes_read; /* This is a 5views capture file */ wth->file_type = WTAP_FILE_5VIEWS; @@ -220,7 +217,6 @@ _5views_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) */ return FALSE; } - wth->data_offset += bytes_read; TimeStamped_Header.Key = pletohl(&TimeStamped_Header.Key); if(TimeStamped_Header.Key != CST_5VW_RECORDS_HEADER_KEY) { @@ -237,7 +233,6 @@ _5views_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) if(TimeStamped_Header.RecSubType != CST_5VW_FRAME_RECORD) { if (file_seek(wth->fh, TimeStamped_Header.RecSize, SEEK_CUR, err) == -1) return FALSE; - wth->data_offset += TimeStamped_Header.RecSize; } else break; } while (1); @@ -255,14 +250,13 @@ _5views_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) return FALSE; } - *data_offset = wth->data_offset; + *data_offset = file_tell(wth->fh); buffer_assure_space(wth->frame_buffer, packet_size); if (!_5views_read_rec_data(wth->fh, buffer_start_ptr(wth->frame_buffer), packet_size, err, err_info)) return FALSE; /* Read error */ - wth->data_offset += packet_size; TimeStamped_Header.Utc = pletohl(&TimeStamped_Header.Utc); TimeStamped_Header.NanoSecondes = pletohl(&TimeStamped_Header.NanoSecondes); |