Changeset fa75134


Ignore:
Timestamp:
2008-04-01T23:07:21Z (16 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
4af7b4f, 5be87b2, 5f5d433, 69aaf14, 883a398, dd34575, f1e7407
Parents:
ddba0ae
Message:

Reordered irc_free() a little bit, hoping that this will fix a crash-on-quit
bug I can't figure out. The previous order wasn't optimal.

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • account.c

    rddba0ae rfa75134  
    182182        account_t *a, *l = NULL;
    183183       
     184        if( acc->ic )
     185                /* Caller should have checked, accounts still in use can't be deleted. */
     186                return;
     187       
    184188        for( a = irc->accounts; a; a = (l=a)->next )
    185189                if( a == acc )
    186190                {
    187                         if( a->ic ) return; /* Caller should have checked, accounts still in use can't be deleted. */
    188                        
    189191                        if( l )
    190                         {
    191192                                l->next = a->next;
    192                         }
    193193                        else
    194                         {
    195194                                irc->accounts = a->next;
    196                         }
    197195                       
    198196                        while( a->set )
     
    203201                        g_free( a->user );
    204202                        g_free( a->pass );
    205                         if( a->server ) g_free( a->server );
     203                        g_free( a->server );
    206204                        if( a->reconnect )      /* This prevents any reconnect still queued to happen */
    207205                                cancel_auto_reconnect( a );
  • irc.c

    rddba0ae rfa75134  
    220220
    221221/* Because we have no garbage collection, this is quite annoying */
    222 void irc_free(irc_t * irc)
    223 {
    224         account_t *account;
     222void irc_free( irc_t * irc )
     223{
    225224        user_t *user, *usertmp;
    226225       
     
    231230                        irc_usermsg( irc, "Error while saving settings!" );
    232231       
    233         closesocket( irc->fd );
     232        irc_connection_list = g_slist_remove( irc_connection_list, irc );
     233       
     234        while( irc->accounts )
     235        {
     236                if( irc->accounts->ic )
     237                        imc_logout( irc->accounts->ic, FALSE );
     238                else if( irc->accounts->reconnect )
     239                        cancel_auto_reconnect( irc->accounts );
     240               
     241                if( irc->accounts->ic == NULL )
     242                        account_del( irc, irc->accounts );
     243                else
     244                        /* Nasty hack, but account_del() doesn't work in this
     245                           case and we don't want infinite loops, do we? ;-) */
     246                        irc->accounts = irc->accounts->next;
     247        }
     248       
     249        while( irc->queries != NULL )
     250                query_del( irc, irc->queries );
     251       
     252        while( irc->set )
     253                set_del( &irc->set, irc->set->key );
     254       
     255        if (irc->users != NULL)
     256        {
     257                user = irc->users;
     258                while( user != NULL )
     259                {
     260                        g_free( user->nick );
     261                        g_free( user->away );
     262                        g_free( user->handle );
     263                        if( user->user != user->nick ) g_free( user->user );
     264                        if( user->host != user->nick ) g_free( user->host );
     265                        if( user->realname != user->nick ) g_free( user->realname );
     266                        b_event_remove( user->sendbuf_timer );
     267                                       
     268                        usertmp = user;
     269                        user = user->next;
     270                        g_free( usertmp );
     271                }
     272        }
    234273       
    235274        if( irc->ping_source_id > 0 )
     
    239278                b_event_remove( irc->w_watch_source_id );
    240279       
    241         irc_connection_list = g_slist_remove( irc_connection_list, irc );
    242        
    243         for (account = irc->accounts; account; account = account->next) {
    244                 if (account->ic) {
    245                         imc_logout(account->ic, TRUE);
    246                 } else if (account->reconnect) {
    247                         cancel_auto_reconnect(account);
    248                 }
    249         }
    250        
    251         g_free(irc->sendbuffer);
    252         g_free(irc->readbuffer);
    253        
    254         g_free(irc->nick);
    255         g_free(irc->user);
    256         g_free(irc->host);
    257         g_free(irc->realname);
    258         g_free(irc->password);
    259        
    260         g_free(irc->myhost);
    261         g_free(irc->mynick);
    262        
    263         g_free(irc->channel);
    264        
    265         while (irc->queries != NULL)
    266                 query_del(irc, irc->queries);
    267        
    268         while (irc->accounts)
    269                 if (irc->accounts->ic == NULL)
    270                         account_del(irc, irc->accounts);
    271                 else
    272                         /* Nasty hack, but account_del() doesn't work in this
    273                            case and we don't want infinite loops, do we? ;-) */
    274                         irc->accounts = irc->accounts->next;
    275        
    276         while (irc->set)
    277                 set_del(&irc->set, irc->set->key);
    278        
    279         if (irc->users != NULL) {
    280                 user = irc->users;
    281                 while (user != NULL) {
    282                         g_free(user->nick);
    283                         g_free(user->away);
    284                         g_free(user->handle);
    285                         if(user->user!=user->nick) g_free(user->user);
    286                         if(user->host!=user->nick) g_free(user->host);
    287                         if(user->realname!=user->nick) g_free(user->realname);
    288                         b_event_remove(user->sendbuf_timer);
    289                                        
    290                         usertmp = user;
    291                         user = user->next;
    292                         g_free(usertmp);
    293                 }
    294         }
    295        
    296         g_hash_table_foreach_remove(irc->userhash, irc_free_hashkey, NULL);
    297         g_hash_table_destroy(irc->userhash);
    298        
    299         g_hash_table_foreach_remove(irc->watches, irc_free_hashkey, NULL);
    300         g_hash_table_destroy(irc->watches);
     280        closesocket( irc->fd );
     281        irc->fd = -1;
     282       
     283        g_hash_table_foreach_remove( irc->userhash, irc_free_hashkey, NULL );
     284        g_hash_table_destroy( irc->userhash );
     285       
     286        g_hash_table_foreach_remove( irc->watches, irc_free_hashkey, NULL );
     287        g_hash_table_destroy( irc->watches );
    301288       
    302289        if( irc->iconv != (GIConv) -1 )
     
    305292                g_iconv_close( irc->oconv );
    306293       
     294        g_free( irc->sendbuffer );
     295        g_free( irc->readbuffer );
     296       
     297        g_free( irc->nick );
     298        g_free( irc->user );
     299        g_free( irc->host );
     300        g_free( irc->realname );
     301        g_free( irc->password );
     302       
     303        g_free( irc->myhost );
     304        g_free( irc->mynick );
     305       
     306        g_free( irc->channel );
     307       
    307308        g_free( irc->last_target );
    308309       
    309         g_free(irc);
     310        g_free( irc );
    310311       
    311312        if( global.conf->runmode == RUNMODE_INETD || global.conf->runmode == RUNMODE_FORKDAEMON )
Note: See TracChangeset for help on using the changeset viewer.