# HG changeset patch # User Kevin Stange # Date 1196746995 0 # Node ID 4308279228283eb31b6b8cd56f3f500524898fd5 # Parent 61725f2eb4a6472bbb2554b32d1144c11a3eca5b 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. diff -r 61725f2eb4a6 -r 430827922828 libpurple/protocols/myspace/myspace.c --- a/libpurple/protocols/myspace/myspace.c Tue Dec 04 02:50:44 2007 +0000 +++ b/libpurple/protocols/myspace/myspace.c Tue Dec 04 05:43:15 2007 +0000 @@ -1369,7 +1369,9 @@ 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 @@ 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 @@ /* 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 -r 61725f2eb4a6 -r 430827922828 libpurple/protocols/myspace/session.c --- a/libpurple/protocols/myspace/session.c Tue Dec 04 02:50:44 2007 +0000 +++ b/libpurple/protocols/myspace/session.c Tue Dec 04 05:43:15 2007 +0000 @@ -63,6 +63,7 @@ session->next_rid = 1; session->last_comm = time(NULL); session->inbox_status = 0; + session->inbox_handle = 0; return session; } @@ -90,6 +91,11 @@ 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 -r 61725f2eb4a6 -r 430827922828 libpurple/protocols/myspace/session.h --- a/libpurple/protocols/myspace/session.h Tue Dec 04 02:50:44 2007 +0000 +++ b/libpurple/protocols/myspace/session.h Tue Dec 04 05:43:15 2007 +0000 @@ -45,6 +45,7 @@ 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 */