]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-10274: [mod_conference] Prevent double-recording of conference files and all recor...
authorAnthony Minessale <anthm@freeswitch.org>
Fri, 28 Apr 2017 17:26:47 +0000 (12:26 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Fri, 28 Apr 2017 17:26:47 +0000 (12:26 -0500)
src/mod/applications/mod_conference/conference_api.c

index 0954d9e206f0c2ec5f7e0d7190e9cab3730ef932..fa0f353270d1db295e721be30c51a0e6abef7dc0 100644 (file)
@@ -3200,6 +3200,7 @@ switch_status_t conference_api_sub_check_record(conference_obj_t *conference, sw
 switch_status_t conference_api_sub_record(conference_obj_t *conference, switch_stream_handle_t *stream, int argc, char **argv)
 {
        int id = 0;
+       conference_record_t *rec;
 
        switch_assert(conference != NULL);
        switch_assert(stream != NULL);
@@ -3226,10 +3227,34 @@ switch_status_t conference_api_sub_record(conference_obj_t *conference, switch_s
 
        if (id == 0 && conference->canvases[0]) id = 1;
 
-       if (id > conference->canvas_count) {
+       if (id > conference->canvas_count + 1) {
                id = 1;
        }
 
+       switch_mutex_lock(conference->flag_mutex);
+       for (rec = conference->rec_node_head; rec; rec = rec->next) {
+               char *path_a, *path_b;
+               
+               if ((path_a = strrchr(rec->path, '}'))) {
+                       while(*path_a == ' ' || *path_a == '}') path_a++;
+               } else {
+                       path_a = rec->path;
+               }
+
+               if ((path_b = strrchr(argv[2], '}'))) {
+                       while(*path_b == ' ' || *path_b == '}') path_b++;
+               } else {
+                       path_b = argv[2];
+               }
+               
+               if (!strcmp(path_a, path_b)) {
+                       stream->write_function(stream, "-ERR file [%s] is already being used for recording.\n", rec->path);
+                       return SWITCH_STATUS_SUCCESS;
+               }
+       }
+       switch_mutex_unlock(conference->flag_mutex);
+
+
        if (id > 0) {
                stream->write_function(stream, "Record file %s canvas %d\n", argv[2], id);
        } else {