Applied

Thanks
Vadim
[email protected] wrote:
> # HG changeset patch
> # User [email protected]
> # Date 1245179624 10800
> # Node ID 081ee3dc01152ab3358293aa441c2a9110ef2e7a
> # Parent  15be388684d5ac61ee2ef6f248b48eb3a1d4b96c
> Added the critical section control on "transport_manager" avoiding the 
> finalization while a packet is being handled by 
> "transport_on_data_socket_event" method.
>
> diff -r 15be388684d5 -r 081ee3dc0115 
> wifo/eXosip/transport_manager/transport_manager.c
> --- a/wifo/eXosip/transport_manager/transport_manager.c       Tue Jun 16 
> 19:55:04 2009 +0200
> +++ b/wifo/eXosip/transport_manager/transport_manager.c       Tue Jun 16 
> 16:13:44 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

Reply via email to