loudmouth/lm-connection.c
changeset 573 038320b7357e
parent 545 58954d98a7f9
child 600 7f0be2600f6d
equal deleted inserted replaced
571:6fb1c4046db7 573:038320b7357e
   251 }
   251 }
   252 
   252 
   253 static void
   253 static void
   254 connection_free (LmConnection *connection)
   254 connection_free (LmConnection *connection)
   255 {
   255 {
       
   256     /* This needs to be run before starting to free internal states.
       
   257      * It used to be run after the handlers where freed which lead to a crash
       
   258      * when the connection was freed prior to running lm_connection_close.
       
   259      */
       
   260     if (connection->state >= LM_CONNECTION_STATE_OPENING) {
       
   261         connection_do_close (connection);
       
   262     }
       
   263 
   256     g_free (connection->server);
   264     g_free (connection->server);
   257     g_free (connection->jid);
   265     g_free (connection->jid);
   258     g_free (connection->effective_jid);
   266     g_free (connection->effective_jid);
   259     g_free (connection->stream_id);
   267     g_free (connection->stream_id);
   260     g_free (connection->resource);
   268     g_free (connection->resource);
   268     }
   276     }
   269 
   277 
   270     connection_free_handlers (connection);
   278     connection_free_handlers (connection);
   271     
   279     
   272     g_hash_table_destroy (connection->id_handlers);
   280     g_hash_table_destroy (connection->id_handlers);
   273     if (connection->state >= LM_CONNECTION_STATE_OPENING) {
   281     
   274         connection_do_close (connection);
       
   275     }
       
   276 
       
   277     if (connection->open_cb) {
   282     if (connection->open_cb) {
   278         _lm_utils_free_callback (connection->open_cb);
   283         _lm_utils_free_callback (connection->open_cb);
   279     }
   284     }
   280     
   285     
   281     if (connection->auth_cb) {
   286     if (connection->auth_cb) {