Changeset 59f527b6


Ignore:
Timestamp:
2008-01-12T17:24:38Z (17 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
fc0cf92
Parents:
e64de00
Message:

When a switchboard connection dies (at the TCP level) and there are still
queued messages, they will now be moved back to the main queue and a new
sb will be created to try to send the messages again. I hope this will
solve some/most/all of the "Closing switchboard with unsent messages"
problems, but can't be sure since this problem isn't very easy to reproduce.
At least it should solve the ones caused by keeping spare switchboards
around. Also enabling switchboard debugging output if configured with
--debug=1, at least for now this will be useful.

Location:
protocols/msn
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • protocols/msn/msn.h

    re64de00 r59f527b6  
    2929#define GROUPCHAT_SWITCHBOARD_MESSAGE "\r\r\rME WANT TALK TO MANY PEOPLE\r\r\r"
    3030
    31 #ifdef _WIN32
    32 #define debug 
     31#ifdef DEBUG
     32#define debug( text... ) imcb_log( ic, text );
    3333#else
    34 #define debug( text... ) irc_usermsg( IRC, text );
    35 #undef debug
    3634#define debug( text... )
    3735#endif
     
    6664        GSList *msgq;
    6765        GSList *switchboards;
     66        int sb_failures;
     67        time_t first_sb_failure;
     68       
    6869        const struct msn_away_state *away_state;
    69        
    7070        int buddycount;
    7171        int groupcount;
  • protocols/msn/sb.c

    re64de00 r59f527b6  
    277277{
    278278        struct msn_switchboard *sb = data;
     279        struct im_connection *ic = sb->ic;
     280        struct msn_data *md = ic->proto_data;
    279281       
    280282        if( msn_handler( sb->handler ) == -1 )
    281283        {
     284                time_t now = time( NULL );
     285               
     286                if( now - md->first_sb_failure > 600 )
     287                {
     288                        /* It's not really the first one, but the start of this "series".
     289                           With this, the warning below will be shown only if this happens
     290                           at least three times in ten minutes. This algorithm isn't
     291                           perfect, but for this purpose it will do. */
     292                        md->first_sb_failure = now;
     293                        md->sb_failures = 0;
     294                }
     295               
    282296                debug( "Error: Switchboard died" );
     297                if( ++ md->sb_failures >= 3 )
     298                        imcb_log( ic, "Warning: Many switchboard failures on MSN connection. "
     299                                      "There might be problems delivering your messages." );
     300               
     301                if( sb->msgq != NULL )
     302                {
     303                        char buf[1024];
     304                       
     305                        if( md->msgq == NULL )
     306                        {
     307                                md->msgq = sb->msgq;
     308                        }
     309                        else
     310                        {
     311                                GSList *l;
     312                               
     313                                for( l = md->msgq; l->next; l = l->next );
     314                                l->next = sb->msgq;
     315                        }
     316                        sb->msgq = NULL;
     317                       
     318                        debug( "Moved queued messages back to the main queue, creating a new switchboard to retry." );
     319                        g_snprintf( buf, sizeof( buf ), "XFR %d SB\r\n", ++md->trId );
     320                        if( !msn_write( ic, buf, strlen( buf ) ) )
     321                                return FALSE;
     322                }
     323               
    283324                msn_sb_destroy( sb );
    284325               
     
    286327        }
    287328        else
     329        {
    288330                return TRUE;
     331        }
    289332}
    290333
Note: See TracChangeset for help on using the changeset viewer.