diff --git a/daemon/media_socket.c b/daemon/media_socket.c index 4af0b505c..9c798e8f5 100644 --- a/daemon/media_socket.c +++ b/daemon/media_socket.c @@ -1199,8 +1199,10 @@ loop_ok: // If recording pcap dumper is set, then we record the call. if (recording_pdumper != NULL && call->record_call) { + mutex_lock(&call->recording->recording_lock); stream_pcap_dump(recording_pdumper, stream, s); call->recording->packet_num++; + mutex_unlock(&call->recording->recording_lock); } if (handler_ret >= 0) { diff --git a/daemon/recording.c b/daemon/recording.c index fc2986e4c..f7df890e3 100644 --- a/daemon/recording.c +++ b/daemon/recording.c @@ -138,6 +138,7 @@ int set_record_call(struct call *call, str recordcall) { call->recording->recording_pdumper = NULL; // Wireshark starts at packet index 1, so we start there, too call->recording->packet_num = 1; + mutex_init(&call->recording->recording_lock); meta_setup_file(call->recording, call->callid); } } else if (!str_cmp(&recordcall, "no")) { @@ -287,6 +288,7 @@ int meta_finish_file(struct call *call) { free(recording->meta_filepath->s); free(recording->meta_filepath); } + mutex_destroy(&recording->recording_lock); return return_code; } diff --git a/daemon/recording.h b/daemon/recording.h index 0a0cd2784..7a3cfea94 100644 --- a/daemon/recording.h +++ b/daemon/recording.h @@ -22,6 +22,8 @@ struct recording { pcap_dumper_t *recording_pdumper; uint64_t packet_num; str *recording_path; + + mutex_t recording_lock; };