changeset 24395:9b253ce969d0

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.
author Mark Doliner <mark@kingant.net>
date Thu, 13 Nov 2008 07:22:39 +0000
parents f0160066b58b
children 58fabce901e1
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
diffstat 5 files changed, 12 insertions(+), 27 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/msn/slpcall.c	Thu Nov 13 06:57:20 2008 +0000
+++ b/libpurple/protocols/msn/slpcall.c	Thu Nov 13 07:22:39 2008 +0000
@@ -110,8 +110,6 @@
 
 	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 @@
 		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);
--- a/libpurple/protocols/msn/slpcall.h	Thu Nov 13 06:57:20 2008 +0000
+++ b/libpurple/protocols/msn/slpcall.h	Thu Nov 13 07:22:39 2008 +0000
@@ -43,7 +43,6 @@
 
 struct _MsnSlpCall
 {
-	/* MsnSession *session; */
 	MsnSlpLink *slplink;
 
 	MsnSlpCallType type;
@@ -76,7 +75,7 @@
 	MsnSlpCb cb;
 	void (*end_cb)(MsnSlpCall *slpcall, MsnSession *session);
 
-	int timer;
+	guint timer;
 };
 
 MsnSlpCall *msn_slp_call_new(MsnSlpLink *slplink);
--- a/libpurple/protocols/msn/slplink.c	Thu Nov 13 06:57:20 2008 +0000
+++ b/libpurple/protocols/msn/slplink.c	Thu Nov 13 07:22:39 2008 +0000
@@ -164,19 +164,11 @@
 {
 	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 *
--- a/libpurple/protocols/msn/switchboard.c	Thu Nov 13 06:57:20 2008 +0000
+++ b/libpurple/protocols/msn/switchboard.c	Thu Nov 13 07:22:39 2008 +0000
@@ -1315,10 +1315,10 @@
 	}
 }
 
-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 @@
 		swboard->conv = NULL;
 
 	if (swboard->flag == 0)
-	{
+		/* Nothing else is using this switchboard, so close it */
 		msn_switchboard_close(swboard);
-		return TRUE;
-	}
-
-	return FALSE;
 }
 
 /**************************************************************************
--- a/libpurple/protocols/msn/switchboard.h	Thu Nov 13 06:57:20 2008 +0000
+++ b/libpurple/protocols/msn/switchboard.h	Thu Nov 13 07:22:39 2008 +0000
@@ -224,10 +224,8 @@
  *
  * @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