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/visual.c | |
parent | f65cb5f27bab6310e847f88cd763eb08bff1c93b (diff) | |
download | wireshark-33bb54a9452f4be53377a185195a63194016241a.tar.gz |
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/visual.c')
-rw-r--r-- | wiretap/visual.c | 9 |
1 files changed, 1 insertions, 8 deletions
diff --git a/wiretap/visual.c b/wiretap/visual.c index de10c33f43..0b0e0aebb5 100644 --- a/wiretap/visual.c +++ b/wiretap/visual.c @@ -266,10 +266,6 @@ int visual_open(wtap *wth, int *err, gchar **err_info) wth->file_encap = encap; wth->snapshot_length = pletohs(&vfile_hdr.max_length); - /* Save the pointer to the beginning of the packet data so - that the later seek_reads work correctly. */ - wth->data_offset = CAPTUREFILE_HEADER_SIZE; - /* Set up the pointers to the handlers for this file type */ wth->subtype_read = visual_read; wth->subtype_seek_read = visual_seek_read; @@ -326,7 +322,6 @@ static gboolean visual_read(wtap *wth, int *err, gchar **err_info, } return FALSE; } - wth->data_offset += phdr_size; /* Get the included length of data. This includes extra headers + payload */ packet_size = pletohs(&vpkt_hdr.incl_len); @@ -346,7 +341,6 @@ static gboolean visual_read(wtap *wth, int *err, gchar **err_info, } return FALSE; } - wth->data_offset += ahdr_size; /* Remove ATM header from length of included bytes in capture, as this header was appended by the processor doing the packet reassembly, @@ -365,7 +359,7 @@ static gboolean visual_read(wtap *wth, int *err, gchar **err_info, return FALSE; } buffer_assure_space(wth->frame_buffer, packet_size); - *data_offset = wth->data_offset; + *data_offset = file_tell(wth->fh); errno = WTAP_ERR_CANT_READ; bytes_read = file_read(buffer_start_ptr(wth->frame_buffer), packet_size, wth->fh); @@ -377,7 +371,6 @@ static gboolean visual_read(wtap *wth, int *err, gchar **err_info, *err = WTAP_ERR_SHORT_READ; return FALSE; } - wth->data_offset += packet_size; wth->phdr.presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN; |