diff options
author | Guy Harris <gharris@sonic.net> | 2022-03-14 12:11:24 -0700 |
---|---|---|
committer | Guy Harris <gharris@sonic.net> | 2022-03-14 19:12:20 +0000 |
commit | 109b92b5d796f2fb64491fe1976257bc976f1f40 (patch) | |
tree | fa9fe0a1d1e9dc33aa6cb25774bf19ae3a53d60b /wiretap | |
parent | 304dae33d68d923cd2da6d405d999f8a8527ba71 (diff) |
wiretap: have wtap_dump_close() provide a "needs to be reloaded" indication.
This allows the "needs to be reloaded" indication to be set in the close
process, as is the case for ERF; having a routine that returns the value
of that indication is not useful if it gets seet in the close process,
as the handle for the wtap_dumper is no longer valid after
wtap_dump_close() finishes.
We also get rid of wtap_dump_get_needs_reload(), as callers should get
that information via the added argument to wtap_dump_close().
Fixes #17989.
Diffstat (limited to 'wiretap')
-rw-r--r-- | wiretap/file_access.c | 9 | ||||
-rw-r--r-- | wiretap/merge.c | 4 | ||||
-rw-r--r-- | wiretap/wtap.h | 17 |
3 files changed, 20 insertions, 10 deletions
diff --git a/wiretap/file_access.c b/wiretap/file_access.c index adf98b88cd..d2911bc601 100644 --- a/wiretap/file_access.c +++ b/wiretap/file_access.c @@ -2621,7 +2621,8 @@ wtap_dump_flush(wtap_dumper *wdh, int *err) } gboolean -wtap_dump_close(wtap_dumper *wdh, int *err, gchar **err_info) +wtap_dump_close(wtap_dumper *wdh, gboolean *needs_reload, + int *err, gchar **err_info) { gboolean ret = TRUE; @@ -2643,6 +2644,8 @@ wtap_dump_close(wtap_dumper *wdh, int *err, gchar **err_info) } ret = FALSE; } + if (needs_reload != NULL) + *needs_reload = wdh->needs_reload; g_free(wdh->priv); wtap_block_array_free(wdh->interface_data); wtap_block_array_free(wdh->dsbs_initial); @@ -2709,10 +2712,6 @@ wtap_dump_discard_decryption_secrets(wtap_dumper *wdh) } } -gboolean wtap_dump_get_needs_reload(wtap_dumper *wdh) { - return wdh->needs_reload; -} - /* internally open a file for writing (compressed or not) */ #ifdef HAVE_ZLIB static WFILE_T diff --git a/wiretap/merge.c b/wiretap/merge.c index da4e20b585..05a48ad90a 100644 --- a/wiretap/merge.c +++ b/wiretap/merge.c @@ -952,7 +952,7 @@ merge_process_packets(wtap_dumper *pdh, const int file_type, cb->callback_func(MERGE_EVENT_DONE, count, in_files, in_file_count, cb->data); if (status == MERGE_OK || status == MERGE_USER_ABORTED) { - if (!wtap_dump_close(pdh, err, err_info)) + if (!wtap_dump_close(pdh, NULL, err, err_info)) status = MERGE_ERR_CANT_CLOSE_OUTFILE; } else { /* @@ -963,7 +963,7 @@ merge_process_packets(wtap_dumper *pdh, const int file_type, */ int close_err = 0; gchar *close_err_info = NULL; - (void)wtap_dump_close(pdh, &close_err, &close_err_info); + (void)wtap_dump_close(pdh, NULL, &close_err, &close_err_info); g_free(close_err_info); } diff --git a/wiretap/wtap.h b/wiretap/wtap.h index b0505b3a22..f10cf077f5 100644 --- a/wiretap/wtap.h +++ b/wiretap/wtap.h @@ -2121,16 +2121,27 @@ gboolean wtap_addrinfo_list_empty(addrinfo_lists_t *addrinfo_lists); WS_DLL_PUBLIC gboolean wtap_dump_set_addrinfo_list(wtap_dumper *wdh, addrinfo_lists_t *addrinfo_lists); WS_DLL_PUBLIC -gboolean wtap_dump_get_needs_reload(wtap_dumper *wdh); -WS_DLL_PUBLIC void wtap_dump_discard_decryption_secrets(wtap_dumper *wdh); /** * Closes open file handles and frees memory associated with wdh. Note that * shb_hdr, idb_inf and nrb_hdr are not freed by this routine. + * + * @param wdh handle for the file we're closing. + * @param[out] needs_reload if not null, points to a gboolean that will + * be set to TRUE if a full reload of the file would be required if + * this was done as part of a "Save" or "Save As" operation, FALSE + * if no full reload would be required. + * @param[out] err points to an int that will be set to an error code + * on failure. + * @param[out] err_info for some errors, points to a gchar * that will + * be set to a string giving more details of the error. + * + * @return TRUE on success, FALSE on failure. */ WS_DLL_PUBLIC -gboolean wtap_dump_close(wtap_dumper *wdh, int *err, gchar **err_info); +gboolean wtap_dump_close(wtap_dumper *wdh, gboolean *needs_reload, + int *err, gchar **err_info); /** * Return TRUE if we can write a file out with the given GArray of file |