diff --git a/file.c b/file.c index 44895a9bc0..2c6c3eb546 100644 --- a/file.c +++ b/file.c @@ -801,6 +801,7 @@ cf_continue_tail(capture_file *cf, volatile int to_read, int *err) /*g_log(NULL, G_LOG_LEVEL_MESSAGE, "cf_continue_tail: %u new: %u", cf->count, to_read);*/ + wtap_cleareof(cf->wth); while (to_read != 0 && (wtap_read(cf->wth, err, &err_info, &data_offset))) { if (cf->state == FILE_READ_ABORTED) { /* Well, the user decided to exit Wireshark. Break out of the diff --git a/wiretap/wtap.c b/wiretap/wtap.c index f3a12b1432..f1281a7cf7 100644 --- a/wiretap/wtap.c +++ b/wiretap/wtap.c @@ -637,6 +637,15 @@ wtap_close(wtap *wth) g_free(wth); } +void +wtap_cleareof(wtap *wth) { +#ifdef HAVE_LIBZ + /* Reset EOF */ + if (gzeof(wth->fh)) + gzclearerr(wth->fh); +#endif +} + gboolean wtap_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) { @@ -650,14 +659,6 @@ wtap_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) */ wth->phdr.pkt_encap = wth->file_encap; -#if defined(ZLIB_VERNUM) && ZLIB_VERNUM == 0x1250 - /* Reset EOF */ - /* g_log(NULL, G_LOG_LEVEL_DEBUG, "wtap_read: eof before seek: %d", gzeof(wth->fh)); */ - if (gzeof(wth->fh)) - gzseek(wth->fh, 0, SEEK_CUR); - /* g_log(NULL, G_LOG_LEVEL_DEBUG, "wtap_read: eof after seek: %d", gzeof(wth->fh)); */ -#endif - if (!wth->subtype_read(wth, err, err_info, data_offset)) return FALSE; /* failure */ diff --git a/wiretap/wtap.h b/wiretap/wtap.h index 5995d97e94..09fae00340 100644 --- a/wiretap/wtap.h +++ b/wiretap/wtap.h @@ -886,7 +886,7 @@ struct gsm_um_phdr { #define GSM_UM_CHANNEL_RACH 6 #define GSM_UM_CHANNEL_AGCH 7 #define GSM_UM_CHANNEL_PCH 8 - + union wtap_pseudo_header { struct eth_phdr eth; struct x25_phdr x25; @@ -972,6 +972,13 @@ typedef int (*wtap_open_routine_t)(struct wtap*, int *, char **); struct wtap* wtap_open_offline(const char *filename, int *err, gchar **err_info, gboolean do_random); +/* + * If we were compiled with zlib and we're at EOF, unset EOF so that + * wtap_read/gzread has a chance to succeed. This is necessary if + * we're tailing a file. + */ +void wtap_cleareof(wtap *wth); + /* Returns TRUE if read was successful. FALSE if failure. data_offset is * set to the offset in the file where the data for the read packet is * located. */