1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-06-23 21:45:30 +00:00

Attempted fix at causing segfault by freeing connection

This commit is contained in:
James Booth 2012-10-16 23:29:58 +01:00
parent ea9a527606
commit d2aeca9bb4
3 changed files with 13 additions and 7 deletions

View File

@ -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;

View File

@ -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);

View File

@ -281,6 +281,7 @@ _shutdown_init(void)
while (jabber_get_connection_status() == JABBER_DISCONNECTING) {
jabber_process_events();
}
jabber_shutdown();
}
_shutdown();