[Freeswitch-svn] [commit] r7135 - freeswitch/trunk/src/mod/applications/mod_conference

Freeswitch SVN mikej at freeswitch.org
Mon Jan 7 22:00:57 EST 2008


Author: mikej
Date: Mon Jan  7 22:00:57 2008
New Revision: 7135

Modified:
   freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c

Log:
avoid file handle leak

Modified: freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c	(original)
+++ freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c	Mon Jan  7 22:00:57 2008
@@ -984,7 +984,8 @@
 	if (switch_test_flag(conference, CFLAG_DESTRUCT)) {
 
 		switch_mutex_lock(conference->mutex);
-
+		conference_stop_file(conference, FILE_STOP_ASYNC);
+		conference_stop_file(conference, FILE_STOP_ALL);
 		/* Close Unused Handles */
 		if (conference->fnode) {
 			conference_file_node_t *fnode, *cur;
@@ -1005,6 +1006,14 @@
 			conference->fnode = NULL;
 		}
 
+		if (conference->async_fnode) {
+			switch_memory_pool_t *pool;
+            switch_core_file_close(&conference->async_fnode->fh);
+            pool = conference->async_fnode->pool;
+            conference->async_fnode = NULL;
+            switch_core_destroy_memory_pool(&pool);
+		}
+
 		switch_mutex_lock(conference->member_mutex);
 		for (imember = conference->members; imember; imember = imember->next) {
 			switch_channel_t *channel;
@@ -2782,7 +2791,7 @@
 static switch_status_t conf_api_sub_list(conference_obj_t * conference, switch_stream_handle_t *stream, int argc, char **argv)
 {
 	int ret_status = SWITCH_STATUS_GENERR;
-
+	int count = 0;
 	switch_hash_index_t *hi;
 	void *val;
 	char *d = ";";
@@ -2816,6 +2825,7 @@
 			stream->write_function(stream, "Conference %s (%u member%s%s)\n",
 								   conference->name,
 								   conference->count, conference->count == 1 ? "" : "s", switch_test_flag(conference, CFLAG_LOCKED) ? " locked" : "");
+			count++;
 			if (pretty) {
 				conference_list_pretty(conference, stream);
 			} else {
@@ -2823,6 +2833,7 @@
 			}
 		}
 	} else {
+		count++;
 		if (pretty) {
 			conference_list_pretty(conference, stream);
 		} else {
@@ -2830,6 +2841,10 @@
 		}
 	}
 
+	if (!count) {
+		stream->write_function(stream, "No active conferences.\n");
+	}
+
 	ret_status = SWITCH_STATUS_SUCCESS;
 
 	return ret_status;



More information about the Freeswitch-svn mailing list