Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/msn/sb.c

    r46dca11 r8ff0a61  
    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
     
    551594        else
    552595        {
    553                 debug( "Received unknown command from switchboard server: %s", cmd[0] );
     596                /* debug( "Received unknown command from switchboard server: %s", cmd[0] ); */
    554597        }
    555598       
Note: See TracChangeset for help on using the changeset viewer.