summaryrefslogtreecommitdiff
path: root/wiretap/file_access.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2011-04-12 02:40:14 +0000
committerGuy Harris <guy@alum.mit.edu>2011-04-12 02:40:14 +0000
commitb28ee8b33149385549f08fc009691773777180f5 (patch)
treeebb3a5291dd0439aed7f8651d6ea30c5ddf49c5e /wiretap/file_access.c
parente5fe0128d75998d5bd8fc2342e3df8d03240641d (diff)
downloadwireshark-b28ee8b33149385549f08fc009691773777180f5.tar.gz
From Jakub Zawadzki: speed up random access to gzipped files, as per the
zran.c example in the zlib source. This means that problems in the file's contents might not be reported when a packet is read, as long as there's no problem in the contents of the file up to the last bit of compressed data for the packet; we now check for errors after finishing the sequential read of the file, at least in some programs, so that shouldn't be an issue (the other programs need to be changed to do so as well). This is necessary in order to be able to read all the packets we saw in the sequential pass; it also lets us get a few more packets from truncated files in some cases. svn path=/trunk/; revision=36577
Diffstat (limited to 'wiretap/file_access.c')
-rw-r--r--wiretap/file_access.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/wiretap/file_access.c b/wiretap/file_access.c
index c50e4b30a6..f9ff384ca8 100644
--- a/wiretap/file_access.c
+++ b/wiretap/file_access.c
@@ -333,6 +333,12 @@ wtap* wtap_open_offline(const char *filename, int *err, char **err_info,
wth->priv = NULL;
init_open_routines();
+ if (wth->random_fh) {
+ wth->fast_seek = g_ptr_array_new();
+
+ file_set_random_access(wth->fh, FALSE, wth->fast_seek);
+ file_set_random_access(wth->random_fh, TRUE, wth->fast_seek);
+ }
/* Try all file types */
for (i = 0; i < open_routines_arr->len; i++) {
@@ -374,10 +380,7 @@ wtap* wtap_open_offline(const char *filename, int *err, char **err_info,
}
/* Well, it's not one of the types of file we know about. */
- if (wth->random_fh != NULL)
- file_close(wth->random_fh);
- file_close(wth->fh);
- g_free(wth);
+ wtap_close(wth);
*err = WTAP_ERR_FILE_UNKNOWN_FORMAT;
return NULL;