Mercurial > pidgin
comparison libpurple/protocols/mxit/protocol.c @ 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 | 671113b90ff6 |
children | dde6f5770cd0 |
comparison
equal
deleted
inserted
replaced
31491:56ca46c0a13b | 31492:7c3b4002f46e |
---|---|
539 * the mxit server has flood detection and it prevents you from sending messages to fast. | 539 * the mxit server has flood detection and it prevents you from sending messages to fast. |
540 * this is a self defense mechanism, a very annoying feature. so the client must ensure that | 540 * this is a self defense mechanism, a very annoying feature. so the client must ensure that |
541 * it does not send messages too fast otherwise mxit will ignore the user for 30 seconds. | 541 * it does not send messages too fast otherwise mxit will ignore the user for 30 seconds. |
542 * this is what we are trying to avoid here.. | 542 * this is what we are trying to avoid here.. |
543 */ | 543 */ |
544 if ( session->last_tx > ( now - MXIT_TX_DELAY ) ) { | 544 if ( session->q_fast_timer_id == 0 ) { |
545 /* we need to wait a little before sending the next packet, so schedule a wakeup call */ | 545 /* the fast timer has not been set yet */ |
546 gint64 tdiff = now - ( session->last_tx ); | 546 if ( session->last_tx > ( now - MXIT_TX_DELAY ) ) { |
547 guint delay = ( MXIT_TX_DELAY - tdiff ) + 9; | 547 /* we need to wait a little before sending the next packet, so schedule a wakeup call */ |
548 if ( delay <= 0 ) | 548 gint64 tdiff = now - ( session->last_tx ); |
549 delay = MXIT_TX_DELAY; | 549 guint delay = ( MXIT_TX_DELAY - tdiff ) + 9; |
550 purple_timeout_add( delay, mxit_manage_queue_fast, session ); | 550 if ( delay <= 0 ) |
551 } | 551 delay = MXIT_TX_DELAY; |
552 else { | 552 session->q_fast_timer_id = purple_timeout_add( delay, mxit_manage_queue_fast, session ); |
553 /* get the next packet from the queue to send */ | 553 } |
554 packet = pop_tx_packet( session ); | 554 else { |
555 if ( packet != NULL ) { | 555 /* get the next packet from the queue to send */ |
556 /* there was a packet waiting to be sent to the server, now is the time to do something about it */ | 556 packet = pop_tx_packet( session ); |
557 | 557 if ( packet != NULL ) { |
558 /* send the packet to MXit server */ | 558 /* there was a packet waiting to be sent to the server, now is the time to do something about it */ |
559 mxit_send_packet( session, packet ); | 559 |
560 /* send the packet to MXit server */ | |
561 mxit_send_packet( session, packet ); | |
562 } | |
560 } | 563 } |
561 } | 564 } |
562 } | 565 } |
563 | 566 |
564 | 567 |
585 */ | 588 */ |
586 gboolean mxit_manage_queue_fast( gpointer user_data ) | 589 gboolean mxit_manage_queue_fast( gpointer user_data ) |
587 { | 590 { |
588 struct MXitSession* session = (struct MXitSession*) user_data; | 591 struct MXitSession* session = (struct MXitSession*) user_data; |
589 | 592 |
593 session->q_fast_timer_id = 0; | |
590 mxit_manage_queue( session ); | 594 mxit_manage_queue( session ); |
591 | 595 |
592 /* stop running */ | 596 /* stop running */ |
593 return FALSE; | 597 return FALSE; |
594 } | 598 } |
2644 | 2648 |
2645 /* remove HTTP poll timer */ | 2649 /* remove HTTP poll timer */ |
2646 if ( session->http_timer_id > 0 ) | 2650 if ( session->http_timer_id > 0 ) |
2647 purple_timeout_remove( session->http_timer_id ); | 2651 purple_timeout_remove( session->http_timer_id ); |
2648 | 2652 |
2649 /* remove queue manager timer */ | 2653 /* remove slow queue manager timer */ |
2650 if ( session->q_timer > 0 ) | 2654 if ( session->q_slow_timer_id > 0 ) |
2651 purple_timeout_remove( session->q_timer ); | 2655 purple_timeout_remove( session->q_slow_timer_id ); |
2656 | |
2657 /* remove fast queue manager timer */ | |
2658 if ( session->q_fast_timer_id > 0 ) | |
2659 purple_timeout_remove( session->q_fast_timer_id ); | |
2652 | 2660 |
2653 /* remove all groupchat rooms */ | 2661 /* remove all groupchat rooms */ |
2654 while ( session->rooms != NULL ) { | 2662 while ( session->rooms != NULL ) { |
2655 struct multimx* multimx = (struct multimx *) session->rooms->data; | 2663 struct multimx* multimx = (struct multimx *) session->rooms->data; |
2656 | 2664 |