diff options
author | Kevin Stange <kstange@pidgin.im> | 2007-12-04 05:43:15 +0000 |
---|---|---|
committer | Kevin Stange <kstange@pidgin.im> | 2007-12-04 05:43:15 +0000 |
commit | 8eaf3290e57b146dc77c646e254b55986794b4b2 (patch) | |
tree | 645151156f5a87c583dfbd370f66855e0a49524a | |
parent | 5620a99adbace14386a63a18bc0dd22847b6fba8 (diff) | |
download | pidgin-8eaf3290e57b146dc77c646e254b55986794b4b2.tar.gz |
Avoid checking for new message in the inbox when not actually connected.
This helps avoid a half-dozen assertions by not trying to act on a closed
socket.
-rw-r--r-- | libpurple/protocols/myspace/myspace.c | 11 | ||||
-rw-r--r-- | libpurple/protocols/myspace/session.c | 6 | ||||
-rw-r--r-- | libpurple/protocols/myspace/session.h | 1 |
3 files changed, 16 insertions, 2 deletions
diff --git a/libpurple/protocols/myspace/myspace.c b/libpurple/protocols/myspace/myspace.c index 6680d2fa5f..2055c726b2 100644 --- a/libpurple/protocols/myspace/myspace.c +++ b/libpurple/protocols/myspace/myspace.c @@ -1369,7 +1369,9 @@ msim_check_inbox_cb(MsimSession *session, MsimMessage *reply, gpointer data) msim_msg_dump("msim_check_inbox_cb: reply=%s\n", reply); body = msim_msg_get_dictionary(reply, "body"); - g_return_if_fail(body != NULL); + + if (body == NULL) + return; old_inbox_status = session->inbox_status; @@ -1433,6 +1435,11 @@ msim_check_inbox(gpointer data) session = (MsimSession *)data; + if (!MSIM_SESSION_VALID(session)) { + purple_debug_info("msim", "msim_check_inbox: session invalid, stopping the mail check.\n"); + return FALSE; + } + purple_debug_info("msim", "msim_check_inbox: checking mail\n"); g_return_val_if_fail(msim_send(session, "persist", MSIM_TYPE_INTEGER, 1, @@ -1645,7 +1652,7 @@ msim_we_are_logged_on(MsimSession *session, MsimMessage *msg) /* Check mail if they want to. */ if (purple_account_get_check_mail(session->account)) { - purple_timeout_add(MSIM_MAIL_INTERVAL_CHECK, + session->inbox_handle = purple_timeout_add(MSIM_MAIL_INTERVAL_CHECK, (GSourceFunc)msim_check_inbox, session); msim_check_inbox(session); } diff --git a/libpurple/protocols/myspace/session.c b/libpurple/protocols/myspace/session.c index 101b73fe1e..92a5e94da8 100644 --- a/libpurple/protocols/myspace/session.c +++ b/libpurple/protocols/myspace/session.c @@ -63,6 +63,7 @@ msim_session_new(PurpleAccount *acct) session->next_rid = 1; session->last_comm = time(NULL); session->inbox_status = 0; + session->inbox_handle = 0; return session; } @@ -90,6 +91,11 @@ msim_session_destroy(MsimSession *session) msim_msg_free(session->server_info); } + /* Stop checking the inbox at the end of the session. */ + if (session->inbox_handle) { + purple_timeout_remove(session->inbox_handle); + } + g_free(session); } diff --git a/libpurple/protocols/myspace/session.h b/libpurple/protocols/myspace/session.h index aab1bace93..209cf20b06 100644 --- a/libpurple/protocols/myspace/session.h +++ b/libpurple/protocols/myspace/session.h @@ -45,6 +45,7 @@ typedef struct _MsimSession guint next_rid; /**< Next request/response ID */ time_t last_comm; /**< Time received last communication */ guint inbox_status; /**< Bit field of inbox notifications */ + guint inbox_handle; /**< The handle for the mail check timer */ } MsimSession; /* Check if an MsimSession is valid */ |