pidgin.mxit: 25a0edc6: * fixed crash caused by entering a wron...

pieter.loubser at mxit.com pieter.loubser at mxit.com
Fri Mar 25 04:37:42 EDT 2011


----------------------------------------------------------------------
Revision: 25a0edc656e58082c520636f0bf5ec092990febb
Parent:   c411ce686b03de9da2d99f1d44fbdc5ae5b8dd0d
Author:   pieter.loubser at mxit.com
Date:     03/25/11 04:33:12
Branch:   im.pidgin.pidgin.mxit
URL: http://d.pidgin.im/viewmtn/revision/info/25a0edc656e58082c520636f0bf5ec092990febb

Changelog: 

 * fixed crash caused by entering a wrong password (tx queue management)


Changes against parent c411ce686b03de9da2d99f1d44fbdc5ae5b8dd0d

  patched  libpurple/protocols/mxit/login.c
  patched  libpurple/protocols/mxit/mxit.h
  patched  libpurple/protocols/mxit/protocol.c

-------------- next part --------------
============================================================
--- libpurple/protocols/mxit/login.c	c3b11a7c2a04d44237ec6d2cf3fd2f3b3b95a3ec
+++ libpurple/protocols/mxit/login.c	79859aa4b6d39b6e751a8c32a00c4f5695fc9ab9
@@ -141,9 +141,9 @@ static void mxit_connected( struct MXitS
 	}
 
 	/* This timer might already exist if we're registering a new account */
-	if ( session->q_timer == 0 ) {
+	if ( session->q_slow_timer_id == 0 ) {
 		/* start the tx queue manager timer */
-		session->q_timer = purple_timeout_add_seconds( 2, mxit_manage_queue_slow, session );
+		session->q_slow_timer_id = purple_timeout_add_seconds( 2, mxit_manage_queue_slow, session );
 	}
 }
 
============================================================
--- libpurple/protocols/mxit/mxit.h	c3009a770c3cc34d3db8f3d2951dbe3061198e91
+++ libpurple/protocols/mxit/mxit.h	285c04ee0f8a64b8c9cfe5169a49aa0909cf8189
@@ -162,7 +162,8 @@ struct MXitSession {
 	struct tx_queue		queue;						/* transmit packet queue (FIFO mode) */
 	gint64				last_tx;					/* timestamp of last packet sent */
 	int					outack;						/* outstanding ack packet */
-	guint				q_timer;					/* timer handler for managing queue */
+	guint				q_slow_timer_id;			/* timer handle for slow tx queue */
+	guint				q_fast_timer_id;			/* timer handle for fast tx queue */
 
 	/* receive */
 	char				rx_lbuf[16];				/* receive byte buffer (socket packet length) */
============================================================
--- libpurple/protocols/mxit/protocol.c	d245d8fa7ca77b0695eafe9cefcc851a5a1ee552
+++ libpurple/protocols/mxit/protocol.c	e30155f19c4fb35115e9b0445624fa456cbfef7e
@@ -541,22 +541,25 @@ static void mxit_manage_queue( struct MX
 	 * it does not send messages too fast otherwise mxit will ignore the user for 30 seconds.
 	 * this is what we are trying to avoid here..
 	 */
-	if ( session->last_tx > ( now - MXIT_TX_DELAY ) ) {
-		/* we need to wait a little before sending the next packet, so schedule a wakeup call */
-		gint64 tdiff = now - ( session->last_tx );
-		guint delay = ( MXIT_TX_DELAY - tdiff ) + 9;
-		if ( delay <= 0 )
-			delay = MXIT_TX_DELAY;
-		purple_timeout_add( delay, mxit_manage_queue_fast, session );
-	}
-	else {
-		/* get the next packet from the queue to send */
-		packet = pop_tx_packet( session );
-		if ( packet != NULL ) {
-			/* there was a packet waiting to be sent to the server, now is the time to do something about it */
+	if ( session->q_fast_timer_id == 0 ) {
+		/* the fast timer has not been set yet */
+		if ( session->last_tx > ( now - MXIT_TX_DELAY ) ) {
+			/* we need to wait a little before sending the next packet, so schedule a wakeup call */
+			gint64 tdiff = now - ( session->last_tx );
+			guint delay = ( MXIT_TX_DELAY - tdiff ) + 9;
+			if ( delay <= 0 )
+				delay = MXIT_TX_DELAY;
+			session->q_fast_timer_id = purple_timeout_add( delay, mxit_manage_queue_fast, session );
+		}
+		else {
+			/* get the next packet from the queue to send */
+			packet = pop_tx_packet( session );
+			if ( packet != NULL ) {
+				/* there was a packet waiting to be sent to the server, now is the time to do something about it */
 
-			/* send the packet to MXit server */
-			mxit_send_packet( session, packet );
+				/* send the packet to MXit server */
+				mxit_send_packet( session, packet );
+			}
 		}
 	}
 }
@@ -587,6 +590,7 @@ gboolean mxit_manage_queue_fast( gpointe
 {
 	struct MXitSession* session		= (struct MXitSession*) user_data;
 
+	session->q_fast_timer_id = 0;
 	mxit_manage_queue( session );
 
 	/* stop running */
@@ -2646,10 +2650,14 @@ void mxit_close_connection( struct MXitS
 	if ( session->http_timer_id > 0 )
 		purple_timeout_remove( session->http_timer_id );
 
-	/* remove queue manager timer */
-	if ( session->q_timer > 0 )
-		purple_timeout_remove( session->q_timer );
+	/* remove slow queue manager timer */
+	if ( session->q_slow_timer_id > 0 )
+		purple_timeout_remove( session->q_slow_timer_id );
 
+	/* remove fast queue manager timer */
+	if ( session->q_fast_timer_id > 0 )
+		purple_timeout_remove( session->q_fast_timer_id );
+
 	/* remove all groupchat rooms */
 	while ( session->rooms != NULL ) {
 		struct multimx* multimx = (struct multimx *) session->rooms->data;


More information about the Commits mailing list