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/packetlogger.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/packetlogger.c')
-rw-r--r-- | wiretap/packetlogger.c | 5 |
1 files changed, 1 insertions, 4 deletions
diff --git a/wiretap/packetlogger.c b/wiretap/packetlogger.c index e8435698d7..ba80f55b63 100644 --- a/wiretap/packetlogger.c +++ b/wiretap/packetlogger.c @@ -82,7 +82,6 @@ int packetlogger_open(wtap *wth, int *err, gchar **err_info) wth->subtype_read = packetlogger_read; wth->subtype_seek_read = packetlogger_seek_read; - wth->data_offset = 0; wth->file_type = WTAP_FILE_PACKETLOGGER; wth->file_encap = WTAP_ENCAP_PACKETLOGGER; wth->tsprecision = WTAP_FILE_TSPREC_USEC; @@ -96,7 +95,7 @@ packetlogger_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) packetlogger_header_t pl_hdr; guint bytes_read; - *data_offset = wth->data_offset; + *data_offset = file_tell(wth->fh); if(!packetlogger_read_header(&pl_hdr, wth->fh, err, err_info)) return FALSE; @@ -129,8 +128,6 @@ packetlogger_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) return FALSE; } - wth->data_offset += (pl_hdr.len + 4); - wth->phdr.presence_flags = WTAP_HAS_TS; wth->phdr.len = pl_hdr.len - 8; |