pidgin: 430ded76: msn_slplink_remove_slpcall() shouldn't b...

markdoliner at pidgin.im markdoliner at pidgin.im
Thu Nov 13 02:25:48 EST 2008


-----------------------------------------------------------------
Revision: 430ded768587b2c84b0bd662bc468b1a0aae6745
Ancestor: 48b991aa6c243ff6b28ed6ccbc8d746616c6a99a
Author: markdoliner at pidgin.im
Date: 2008-11-13T07:22:39
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/430ded768587b2c84b0bd662bc468b1a0aae6745

Modified files:
        libpurple/protocols/msn/slpcall.c
        libpurple/protocols/msn/slpcall.h
        libpurple/protocols/msn/slplink.c
        libpurple/protocols/msn/switchboard.c
        libpurple/protocols/msn/switchboard.h

ChangeLog: 

msn_slplink_remove_slpcall() shouldn't be responsible for setting
slpcall->slplink to NULL.  In fact, msn_slp_call_destroy() shouldn't
even call msn_slplink_remove_slpcall() until it knows that it doesn't
need the slplink anymore.  So move the call to
msn_slplink_remove_slpcall() further down in that function.

Now we no longer need the return value from msn_switchboard_release().
That return value, by the way, was dumb.  If you're no longer using
the MsnSwitchBoard then you're not using it and you shouldn't care
if it was destroyed or not.

-------------- next part --------------
============================================================
--- libpurple/protocols/msn/slpcall.c	bd65d2ee239eab88d1cb649643d3275ccc7b30c1
+++ libpurple/protocols/msn/slpcall.c	9ba2bce8316ea43e02d748e21febfa4108432cad
@@ -110,8 +110,6 @@ msn_slp_call_destroy(MsnSlpCall *slpcall
 
 	session = slpcall->slplink->session;
 
-	msn_slplink_remove_slpcall(slpcall->slplink, slpcall);
-
 	if (slpcall->end_cb != NULL)
 		slpcall->end_cb(slpcall, session);
 
@@ -120,6 +118,8 @@ msn_slp_call_destroy(MsnSlpCall *slpcall
 		purple_xfer_unref(slpcall->xfer);
 	}
 
+	msn_slplink_remove_slpcall(slpcall->slplink, slpcall);
+
 	g_free(slpcall->id);
 	g_free(slpcall->branch);
 	g_free(slpcall->data_info);
============================================================
--- libpurple/protocols/msn/slpcall.h	ddd51328454f9ab54e1f0e893aa6c8bbc3fc1e29
+++ libpurple/protocols/msn/slpcall.h	298d3e4f09c57a5c0fcd74139ccc04b0c904b2e1
@@ -43,7 +43,6 @@ struct _MsnSlpCall
 
 struct _MsnSlpCall
 {
-	/* MsnSession *session; */
 	MsnSlpLink *slplink;
 
 	MsnSlpCallType type;
@@ -76,7 +75,7 @@ struct _MsnSlpCall
 	MsnSlpCb cb;
 	void (*end_cb)(MsnSlpCall *slpcall, MsnSession *session);
 
-	int timer;
+	guint timer;
 };
 
 MsnSlpCall *msn_slp_call_new(MsnSlpLink *slplink);
============================================================
--- libpurple/protocols/msn/slplink.c	3380f27c477be434913b0c1d6f411f9901c8dece
+++ libpurple/protocols/msn/slplink.c	d2cd72af13d98a716680e51497d9702c44b1baa4
@@ -164,19 +164,11 @@ msn_slplink_remove_slpcall(MsnSlpLink *s
 {
 	slplink->slp_calls = g_list_remove(slplink->slp_calls, slpcall);
 
-	/* The slplink has no slpcalls in it. If no one is using it, we might
-	 * destroy the switchboard, but we should be careful not to use the slplink
-	 * again. */
-	if (slplink->slp_calls == NULL)
-	{
-		if (slplink->swboard != NULL)
-		{
-			if (msn_switchboard_release(slplink->swboard, MSN_SB_FLAG_FT))
-				/* I'm not sure this is the best thing to do, but it's better
-				 * than nothing. */
-				slpcall->slplink = NULL;
-		}
-	}
+	/* The slplink has no slpcalls in it, release it from MSN_SB_FLAG_FT.
+	 * If nothing else is using it then this might cause swboard to be
+	 * destroyed. */
+	if (slplink->slp_calls == NULL && slplink->swboard != NULL)
+		msn_switchboard_release(slplink->swboard, MSN_SB_FLAG_FT);
 }
 
 MsnSlpCall *
============================================================
--- libpurple/protocols/msn/switchboard.c	f7fce1b63dc21b75eff51c1d6aafe704c5c41439
+++ libpurple/protocols/msn/switchboard.c	8a0b0cf2ed01500745519525b4c8eb5040a36970
@@ -1315,10 +1315,10 @@ msn_switchboard_close(MsnSwitchBoard *sw
 	}
 }
 
-gboolean
+void
 msn_switchboard_release(MsnSwitchBoard *swboard, MsnSBFlag flag)
 {
-	g_return_val_if_fail(swboard != NULL, FALSE);
+	g_return_if_fail(swboard != NULL);
 
 	swboard->flag &= ~flag;
 
@@ -1328,12 +1328,8 @@ msn_switchboard_release(MsnSwitchBoard *
 		swboard->conv = NULL;
 
 	if (swboard->flag == 0)
-	{
+		/* Nothing else is using this switchboard, so close it */
 		msn_switchboard_close(swboard);
-		return TRUE;
-	}
-
-	return FALSE;
 }
 
 /**************************************************************************
============================================================
--- libpurple/protocols/msn/switchboard.h	f2c8051a21dbba0f14fb05913df8a2e4c1d5e46c
+++ libpurple/protocols/msn/switchboard.h	dbe228fc6d8336e13b1329af0865772161903b6b
@@ -224,10 +224,8 @@ void msn_switchboard_close(MsnSwitchBoar
  *
  * @param swboard The switchboard to release.
  * @param flag The flag that states the function.
- *
- * @return @c TRUE if the switchboard was closed, @c FALSE otherwise.
  */
-gboolean msn_switchboard_release(MsnSwitchBoard *swboard, MsnSBFlag flag);
+void msn_switchboard_release(MsnSwitchBoard *swboard, MsnSBFlag flag);
 
 /**
  * Returns whether or not we currently can send a message through this


More information about the Commits mailing list