|
Hi Vadim! I've added the critical section control on "transport_manager" as exposed below and it seems it work pretty fine. At least, I'm not getting the crash on "udp.c" file any more. The idea is quite simple: avoid the "transport_manager" finalization while a packet is being handled by "transport_on_data_socket_event" method. (I have protected "transport_on_listening_socket_event" method too, although I'm not completely sure if it's necessary as "transport_on_data_socket_event"). Please let me know if you have any comments or disagreements about it, ok ? Thanks and best regards, Mauro. Mauro Sergio Ferreira Brasil escreveu:
--
|
diff -r dc29b6afa409 wifo/eXosip/transport_manager/transport_manager.c
--- a/wifo/eXosip/transport_manager/transport_manager.c Mon Jun 15 18:27:14
2009 +0200
+++ b/wifo/eXosip/transport_manager/transport_manager.c Tue Jun 16 13:35:25
2009 -0300
@@ -34,6 +34,8 @@
static OWList * transport_data_socket_list = NULL ;
static OWList * transport_listening_socket_list = NULL ;
static pthread_mutex_t transport_socket_lists_mutex ;
+static pthread_mutex_t transport_termination_mutex ;
+static int is_terminating = 0;
static void
transport_on_data_socket_event
@@ -305,6 +307,17 @@
return -1 ;
}
+ if (pthread_mutex_init (& transport_termination_mutex, NULL))
+ {
+ pthread_mutex_destroy (& transport_socket_lists_mutex) ;
+ owlist_free (transport_listening_socket_list) ;
+ transport_listening_socket_list = NULL ;
+ owlist_free (transport_data_socket_list) ;
+ transport_data_socket_list = NULL ;
+ owsl_terminate () ;
+ return -1 ;
+ }
+
return 0 ;
}
@@ -314,7 +327,18 @@
{
int return_code = 0 ;
+ if ((return_code = pthread_mutex_lock (& transport_termination_mutex))
!= 0)
+ {
+ //TODO: What ?
+ //return return_code;
+ }
+
+ is_terminating = 1;
+
+ pthread_mutex_unlock (& transport_termination_mutex);
+
return_code |= pthread_mutex_destroy (& transport_socket_lists_mutex) ;
+ return_code |= pthread_mutex_destroy (& transport_termination_mutex) ;
return_code |= owlist_free_all (transport_listening_socket_list, (void
(*) (void *)) transport_socket_free) ;
transport_listening_socket_list = NULL ;
@@ -789,9 +813,21 @@
void * user_data
)
{
+ if (pthread_mutex_lock (& transport_termination_mutex))
+ {
+ return;
+ }
+
+ if (is_terminating)
+ {
+ pthread_mutex_unlock (& transport_termination_mutex);
+ return;
+ }
+
if (event & OWSL_EVENT_ERROR)
{
transport_socket_remove (socket, TRANSPORT_DATA) ;
+ pthread_mutex_unlock (& transport_termination_mutex);
return ;
}
@@ -799,6 +835,9 @@
{
transport_recv_callback (socket) ;
}
+
+ pthread_mutex_unlock (& transport_termination_mutex);
+
return ;
}
@@ -810,6 +849,17 @@
void * user_data
)
{
+ if (pthread_mutex_lock (& transport_termination_mutex))
+ {
+ return;
+ }
+
+ if (is_terminating)
+ {
+ pthread_mutex_unlock (& transport_termination_mutex);
+ return;
+ }
+
if ((event & OWSL_EVENT_ERROR) != 0)
{
OWSLSocketType implementation = owsl_type_get (socket) ;
@@ -819,6 +869,9 @@
{
transport_listen_error_callback (transport_protocol_get
(implementation), bind_address) ;
}
+
+ pthread_mutex_unlock (& transport_termination_mutex);
+
return ;
}
@@ -829,7 +882,13 @@
{
transport_socket_add (new_socket, TRANSPORT_DATA) ;
}
+
+ pthread_mutex_unlock (& transport_termination_mutex);
+
return ;
}
+
+ pthread_mutex_unlock (& transport_termination_mutex);
+
return ;
}
_______________________________________________ QuteCom-dev mailing list [email protected] http://lists.qutecom.org/mailman/listinfo/qutecom-dev
