Revision
14411
Author
gmaruzz
Date
2009-07-29 06:07:46 -0500 (Wed, 29 Jul 2009)

Log Message

skypiax: fixed crash when you set an interface as 'sk' console, then remove the interface, then use the 'sk' command to send a message to the API (it try to use a non-existing interface)

Modified Paths

Diff

Modified: freeswitch/trunk/src/mod/endpoints/mod_skypiax/mod_skypiax.c (14410 => 14411)


--- freeswitch/trunk/src/mod/endpoints/mod_skypiax/mod_skypiax.c	2009-07-29 09:08:31 UTC (rev 14410)
+++ freeswitch/trunk/src/mod/endpoints/mod_skypiax/mod_skypiax.c	2009-07-29 11:07:46 UTC (rev 14411)
@@ -348,9 +348,14 @@
                        globals.SKYPIAX_INTERFACES[interface_id].skypiax_api_thread);
   }
 
+  switch_mutex_lock(globals.mutex);
+  if(globals.sk_console == &globals.SKYPIAX_INTERFACES[interface_id]){
+	DEBUGA_SKYPE("interface '%s' no more console\n", SKYPIAX_P_LOG, interface);
+	globals.sk_console = NULL;
+  } else {
+	DEBUGA_SKYPE("interface '%s' STILL console\n", SKYPIAX_P_LOG, interface);
+  }
   memset(&globals.SKYPIAX_INTERFACES[interface_id], '\0', sizeof(private_t));
-
-  switch_mutex_lock(globals.mutex);
   globals.real_interfaces--;
   switch_mutex_unlock(globals.mutex);