diff options
author | James Booth <boothj5@gmail.com> | 2012-10-16 23:29:58 +0100 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2012-10-16 23:29:58 +0100 |
commit | d2aeca9bb4517658e22529168c17d789db9dab43 (patch) | |
tree | 2222f90eaf7207ec0188803a2c395bf03a5ed85d | |
parent | ea9a52760620327a286cec07cb8a0750a1f1274c (diff) | |
download | profani-tty-d2aeca9bb4517658e22529168c17d789db9dab43.tar.gz |
Attempted fix at causing segfault by freeing connection
-rw-r--r-- | src/jabber.c | 18 | ||||
-rw-r--r-- | src/jabber.h | 1 | ||||
-rw-r--r-- | src/profanity.c | 1 |
3 files changed, 13 insertions, 7 deletions
diff --git a/src/jabber.c b/src/jabber.c index da606132..64d33666 100644 --- a/src/jabber.c +++ b/src/jabber.c @@ -70,6 +70,17 @@ jabber_init(const int disable_tls) jabber_conn.tls_disabled = disable_tls; } +void +jabber_shutdown(void) +{ + // free memory for connection and context + xmpp_conn_release(jabber_conn.conn); + xmpp_ctx_free(jabber_conn.ctx); + + // shutdown libstrophe + xmpp_shutdown(); +} + jabber_conn_status_t jabber_connect(const char * const user, const char * const passwd) @@ -306,13 +317,6 @@ _connection_handler(xmpp_conn_t * const conn, // received close stream response from server after disconnect if (jabber_conn.conn_status == JABBER_DISCONNECTING) { - // free memory for connection object and context - xmpp_conn_release(jabber_conn.conn); - xmpp_ctx_free(jabber_conn.ctx); - - // shutdown libstrophe - xmpp_shutdown(); - jabber_conn.conn_status = JABBER_DISCONNECTED; jabber_conn.presence = PRESENCE_OFFLINE; diff --git a/src/jabber.h b/src/jabber.h index 7e04d0bb..f9ad7fb6 100644 --- a/src/jabber.h +++ b/src/jabber.h @@ -41,6 +41,7 @@ typedef enum { } jabber_presence_t; void jabber_init(const int disable_tls); +void jabber_shutdown(void); jabber_conn_status_t jabber_connect(const char * const user, const char * const passwd); gboolean jabber_disconnect(void); diff --git a/src/profanity.c b/src/profanity.c index 249268a5..002b2453 100644 --- a/src/profanity.c +++ b/src/profanity.c @@ -281,6 +281,7 @@ _shutdown_init(void) while (jabber_get_connection_status() == JABBER_DISCONNECTING) { jabber_process_events(); } + jabber_shutdown(); } _shutdown(); |