Changeset ab6006c


Ignore:
Timestamp:
2010-06-28T09:03:39Z (14 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
a670aeb
Parents:
c7eb771
Message:

Callers shouldn't have to expect that irc_channel_del_user() frees the channel
so if it wants to (temporary channels), do it via a timer.

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • irc.h

    rc7eb771 rab6006c  
    229229irc_channel_t *irc_channel_get( irc_t *irc, char *id );
    230230int irc_channel_free( irc_channel_t *ic );
     231void irc_channel_free_soon( irc_channel_t *ic );
    231232int irc_channel_add_user( irc_channel_t *ic, irc_user_t *iu );
    232233int irc_channel_del_user( irc_channel_t *ic, irc_user_t *iu, gboolean silent, const char *msg );
  • irc_channel.c

    rc7eb771 rab6006c  
    141141}
    142142
     143struct irc_channel_free_data
     144{
     145        irc_t *irc;
     146        irc_channel_t *ic;
     147        char *name;
     148};
     149
     150static gboolean irc_channel_free_callback( gpointer data, gint fd, b_input_condition cond )
     151{
     152        struct irc_channel_free_data *d = data;
     153       
     154        if( g_slist_find( irc_connection_list, d->irc ) &&
     155            irc_channel_by_name( d->irc, d->name ) == d->ic &&
     156            !( d->ic->flags & IRC_CHANNEL_JOINED ) )
     157                irc_channel_free( d->ic );
     158
     159        g_free( d->name );
     160        g_free( d );
     161        return FALSE;
     162}
     163
     164/* Free the channel, but via the event loop, so after finishing whatever event
     165   we're currently handling. */
     166void irc_channel_free_soon( irc_channel_t *ic )
     167{
     168        struct irc_channel_free_data *d = g_new0( struct irc_channel_free_data, 1 );
     169       
     170        d->irc = ic->irc;
     171        d->ic = ic;
     172        d->name = g_strdup( ic->name );
     173       
     174        b_timeout_add( 0, irc_channel_free_callback, d );
     175}
     176
    143177static char *set_eval_channel_type( set_t *set, char *value )
    144178{
     
    206240               
    207241                if( ic->flags & IRC_CHANNEL_TEMP )
    208                         irc_channel_free( ic );
     242                        irc_channel_free_soon( ic );
    209243        }
    210244       
Note: See TracChangeset for help on using the changeset viewer.