MT#61856 recording: clear recording path on failure

If the dumper was not opened, then also take care
to clear the recording path, because later
the `response_pcap()` only checks the recording path
itself and not wehther the dumper was actually opened.

Hence NG would report a recording file, which indeed
was never even created.

For consistency reasons add the dumper's guard
in the `response_pcap()`.

Change-Id: Ifc1d5b73785633ffcc6293d64dbfbdea51b54582
pull/2147/head
Donat Zenichev 3 weeks ago
parent 707d16eff3
commit 19dfbe9e91

@ -701,9 +701,11 @@ static char *recording_open_pcap_file(struct recording *recording, char *path) {
recording->pcap.recording_pd = pcap_open_dead(rec_pcap_format->linktype, 65535);
recording->pcap.recording_pdumper = pcap_dump_open(recording->pcap.recording_pd, path);
if (recording->pcap.recording_pdumper == NULL) {
pcap_close(recording->pcap.recording_pd);
recording->pcap.recording_pd = NULL;
recording->pcap.recording_path = NULL;
ilog(LOG_INFO, "Failed to write recording file: %s", path);
} else {
ilog(LOG_INFO, "Writing recording file: %s", path);
@ -833,6 +835,8 @@ static void response_pcap(struct recording *recording, const ng_parser_t *parser
return;
if (!recording->pcap.recording_path)
return;
if (!recording->pcap.recording_pdumper)
return;
parser_arg recordings = parser->dict_add_list(output, "recordings");
parser->list_add_string(recordings, recording->pcap.recording_path);

Loading…
Cancel
Save