about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorDmitry Podgorny <pasis.ua@gmail.com>2013-01-07 22:13:24 +0200
committerDmitry Podgorny <pasis.ua@gmail.com>2013-01-07 22:13:24 +0200
commit0f0e04603a1c8a08532764dddf76b8535e0bb80e (patch)
tree568cbc15d1bdb64a11f843445a9003b3d9c8a19a
parent5542752afbf581ef9a060472c0db08107d9810e4 (diff)
downloadprofani-tty-0f0e04603a1c8a08532764dddf76b8535e0bb80e.tar.gz
added resources release to connetion handler
-rw-r--r--src/chat_session.c3
-rw-r--r--src/jabber.c7
2 files changed, 8 insertions, 2 deletions
diff --git a/src/chat_session.c b/src/chat_session.c
index 3cd50404..10465032 100644
--- a/src/chat_session.c
+++ b/src/chat_session.c
@@ -63,7 +63,8 @@ chat_sessions_init(void)
 void
 chat_sessions_clear(void)
 {
-    g_hash_table_remove_all(sessions);
+    if (sessions != NULL)
+        g_hash_table_remove_all(sessions);
 }
 
 void
diff --git a/src/jabber.c b/src/jabber.c
index 48495000..ffe4d2b6 100644
--- a/src/jabber.c
+++ b/src/jabber.c
@@ -527,7 +527,8 @@ jabber_free_resources(void)
     FREE_SET_NULL(saved_account);
     FREE_SET_NULL(saved_altdomain);
     chat_sessions_clear();
-    g_hash_table_remove_all(sub_requests);
+    if (sub_requests != NULL)
+        g_hash_table_remove_all(sub_requests);
     xmpp_conn_release(jabber_conn.conn);
     xmpp_ctx_free(jabber_conn.ctx);
     xmpp_shutdown();
@@ -790,6 +791,9 @@ _connection_handler(xmpp_conn_t * const conn,
             if (prefs_get_reconnect() != 0) {
                 assert(reconnect_timer == NULL);
                 reconnect_timer = g_timer_new();
+                // TODO: free resources but leave saved_* untouched
+            } else {
+                jabber_free_resources();
             }
 
         // login attempt failed
@@ -801,6 +805,7 @@ _connection_handler(xmpp_conn_t * const conn,
                 if (prefs_get_reconnect() != 0) {
                     g_timer_start(reconnect_timer);
                 }
+                // TODO: free resources but leave saved_* untouched
             }
         }