changeset 31492:7c3b4002f46e

* fixed crash caused by entering a wrong password (tx queue management)
author pieter.loubser@mxit.com
date Fri, 25 Mar 2011 08:33:12 +0000
parents 56ca46c0a13b
children dde6f5770cd0 f1fd3df53e74
files libpurple/protocols/mxit/login.c libpurple/protocols/mxit/mxit.h libpurple/protocols/mxit/protocol.c
diffstat 3 files changed, 31 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/mxit/login.c	Wed Mar 23 14:28:07 2011 +0000
+++ b/libpurple/protocols/mxit/login.c	Fri Mar 25 08:33:12 2011 +0000
@@ -141,9 +141,9 @@
 	}
 
 	/* 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 );
 	}
 }
 
--- a/libpurple/protocols/mxit/mxit.h	Wed Mar 23 14:28:07 2011 +0000
+++ b/libpurple/protocols/mxit/mxit.h	Fri Mar 25 08:33:12 2011 +0000
@@ -162,7 +162,8 @@
 	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) */
--- a/libpurple/protocols/mxit/protocol.c	Wed Mar 23 14:28:07 2011 +0000
+++ b/libpurple/protocols/mxit/protocol.c	Fri Mar 25 08:33:12 2011 +0000
@@ -541,22 +541,25 @@
 	 * 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 */
-
-			/* send the packet to MXit server */
-			mxit_send_packet( session, packet );
+	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 );
+			}
 		}
 	}
 }
@@ -587,6 +590,7 @@
 {
 	struct MXitSession* session		= (struct MXitSession*) user_data;
 
+	session->q_fast_timer_id = 0;
 	mxit_manage_queue( session );
 
 	/* stop running */
@@ -2646,9 +2650,13 @@
 	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 ) {