Browse Source

Add a mutex lock for recording to ensure thread safety when writing to pcap

pull/245/head
Eric Green 10 years ago
parent
commit
aea277dbbe
3 changed files with 6 additions and 0 deletions
  1. +2
    -0
      daemon/media_socket.c
  2. +2
    -0
      daemon/recording.c
  3. +2
    -0
      daemon/recording.h

+ 2
- 0
daemon/media_socket.c View File

@ -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) {


+ 2
- 0
daemon/recording.c View File

@ -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;
}


+ 2
- 0
daemon/recording.h View File

@ -22,6 +22,8 @@ struct recording {
pcap_dumper_t *recording_pdumper;
uint64_t packet_num;
str *recording_path;
mutex_t recording_lock;
};


Loading…
Cancel
Save