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/vwr.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/vwr.c')
-rw-r--r-- | wiretap/vwr.c | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/wiretap/vwr.c b/wiretap/vwr.c index f3ef7e24d6..8ccebc1803 100644 --- a/wiretap/vwr.c +++ b/wiretap/vwr.c @@ -700,15 +700,12 @@ static gboolean vwr_read(wtap *wth, int *err, gchar **err_info, gint64 *data_off guint16 pkt_len; /* length of radiotap headers */ /* read the next frame record header in the capture file; if no more frames, return */ - /* if we found a frame record, set the data_offset value to the start of the frame */ - /* record (i.e., the record header for the frame) */ if ((ret = vwr_read_rec_header(vwr, wth->fh, &rec_size, &IS_TX, err, err_info)) <= 0) { *err_info = g_strdup_printf("Record not readable or EOF encountered"); return(FALSE); /* Read error or EOF */ - } else - wth->data_offset += ret; /* bump offset past header */ + } - *data_offset = (wth->data_offset - 16); /* set offset for random seek @PLCP */ + *data_offset = (file_tell(wth->fh) - 16); /* set offset for random seek @PLCP */ /* got a frame record; read over entire record (frame + trailer) into a local buffer */ /* if we don't get it all, then declare an error, we can't process the frame */ @@ -718,8 +715,6 @@ static gboolean vwr_read(wtap *wth, int *err, gchar **err_info, gint64 *data_off *err = WTAP_ERR_SHORT_READ; return(FALSE); } - else - wth->data_offset += rec_size; /* got it OK, bump to next rec */ |