[Freeswitch-svn] [commit] r2430 - in freeswitch/trunk/src: include mod/event_handlers/mod_event_socket

Freeswitch SVN anthm at freeswitch.org
Tue Aug 29 16:27:44 EDT 2006


Author: anthm
Date: Tue Aug 29 16:27:43 2006
New Revision: 2430

Modified:
   freeswitch/trunk/src/include/switch_utils.h
   freeswitch/trunk/src/mod/event_handlers/mod_event_socket/mod_event_socket.c

Log:
fix event_socket bugs

Modified: freeswitch/trunk/src/include/switch_utils.h
==============================================================================
--- freeswitch/trunk/src/include/switch_utils.h	(original)
+++ freeswitch/trunk/src/include/switch_utils.h	Tue Aug 29 16:27:43 2006
@@ -61,7 +61,7 @@
 !strcasecmp(expr, "true") ||\
 atoi(expr))) ? SWITCH_TRUE : SWITCH_FALSE
 
-#define SWITCH_STATUS_IS_BREAK(x) (x || x == SWITCH_STATUS_BREAK || x == 730035 || x == 35)
+#define SWITCH_STATUS_IS_BREAK(x) (x == SWITCH_STATUS_BREAK || x == 730035 || x == 35)
 
 /*!
   \brief Return a printable name of a switch_priority_t

Modified: freeswitch/trunk/src/mod/event_handlers/mod_event_socket/mod_event_socket.c
==============================================================================
--- freeswitch/trunk/src/mod/event_handlers/mod_event_socket/mod_event_socket.c	(original)
+++ freeswitch/trunk/src/mod/event_handlers/mod_event_socket/mod_event_socket.c	Tue Aug 29 16:27:43 2006
@@ -31,7 +31,6 @@
  */
 #include <switch.h>
 #define CMD_BUFLEN 1024 * 1000
-#define IS_BREAK(x) ((int)x || SWITCH_STATUS_BREAK || (int)x == 730035 || (int)x == 35)
 
 static const char modname[] = "mod_event_socket";
 static char *MARKER = "1";
@@ -68,6 +67,7 @@
 static struct {
 	switch_socket_t *sock;
 	switch_mutex_t *mutex;
+	switch_mutex_t *sock_mutex;
 	listener_t *listeners;
 	uint8_t ready;
 } listen_list;
@@ -152,26 +152,29 @@
 
 
 static void close_socket(switch_socket_t **sock) {
-
+	switch_mutex_lock(listen_list.sock_mutex);
 	if (*sock) {
 		apr_socket_shutdown(*sock, APR_SHUTDOWN_READWRITE);
 		switch_socket_close(*sock);
 		*sock = NULL;
 	}
+	switch_mutex_unlock(listen_list.sock_mutex);
 }
 
 SWITCH_MOD_DECLARE(switch_status_t) switch_module_shutdown(void)
 {
 	listener_t *l;
 
+	close_socket(&listen_list.sock);
+
 	switch_mutex_lock(listen_list.mutex);
 	for (l = listen_list.listeners; l; l = l->next) {
 		close_socket(&l->sock);
 	}
 	switch_mutex_unlock(listen_list.mutex);
 
-	close_socket(&listen_list.sock);
 
+
 	return SWITCH_STATUS_SUCCESS;
 }
 
@@ -646,7 +649,7 @@
 }
 
 
-/* Create a thread for the conference and launch it */
+/* Create a thread for the socket and launch it */
 static void launch_listener_thread(listener_t *listener)
 {
 	switch_thread_t *thread;
@@ -718,8 +721,9 @@
 	}
 
 	switch_mutex_init(&listen_list.mutex, SWITCH_MUTEX_NESTED, pool);
-
+	switch_mutex_init(&listen_list.sock_mutex, SWITCH_MUTEX_NESTED, pool);
 	
+	
 	for(;;) {
 		rv = switch_sockaddr_info_get(&sa, prefs.ip, APR_INET, prefs.port, 0, pool);
 		if (rv) goto fail;
@@ -767,11 +771,12 @@
 
 		listener->sock = inbound_socket;
 		listener->pool = listener_pool;
+		listener_pool = NULL;
 		listener->format = EVENT_FORMAT_PLAIN;
-		switch_mutex_init(&listener->flag_mutex, SWITCH_MUTEX_NESTED, listener_pool);
-		switch_core_hash_init(&listener->event_hash, listener_pool);
-
+		switch_mutex_init(&listener->flag_mutex, SWITCH_MUTEX_NESTED, listener->pool);
+		switch_core_hash_init(&listener->event_hash, listener->pool);
 		launch_listener_thread(listener);
+		
 	}
 
 	close_socket(&listen_list.sock);



More information about the Freeswitch-svn mailing list