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/ipfix.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/ipfix.c')
-rw-r--r-- | wiretap/ipfix.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/wiretap/ipfix.c b/wiretap/ipfix.c index 07a7c0acee..e7e0b0ab5b 100644 --- a/wiretap/ipfix.c +++ b/wiretap/ipfix.c @@ -262,8 +262,8 @@ ipfix_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) { ipfix_message_header_t msg_hdr; - ipfix_debug1("ipfix_read: wth->data_offset is initially %" G_GINT64_MODIFIER "u", wth->data_offset); - *data_offset = wth->data_offset; + *data_offset = file_tell(wth->fh); + ipfix_debug1("ipfix_read: data_offset is initially %" G_GINT64_MODIFIER "d", *data_offset); if (!ipfix_read_message_header(&msg_hdr, wth->fh, err, err_info)) { ipfix_debug2("ipfix_read: couldn't read message header with code: %d\n, and error '%s'", @@ -282,8 +282,7 @@ ipfix_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) wth->phdr.ts.nsecs = 0; /*ipfix_debug2("Read length: %u Packet length: %u", msg_hdr.message_length, wth->phdr.caplen);*/ - wth->data_offset += msg_hdr.message_length; - ipfix_debug1("ipfix_read: wth->data_offset is finally %" G_GINT64_MODIFIER "u", wth->data_offset); + ipfix_debug1("ipfix_read: data_offset is finally %" G_GINT64_MODIFIER "d", file_tell(wth->fh)); return TRUE; } |