예제 #1
0
파일: iolayer.c 프로젝트: snivel/libevlite
int32_t _shutdowns_direct( uint8_t index, struct session_manager * manager, struct sidlist * ids )
{
    uint32_t i = 0;
    int32_t count = 0;

    for ( i = 0; i < sidlist_count(ids); ++i )
    {
        sid_t id = sidlist_get(ids, i);

        if ( SID_INDEX(id) != index )
        {
            continue;
        }

        struct session * session = session_manager_get( manager, id );
        if ( session == NULL )
        {
            continue;
        }

        // 直接终止
        ++count;
        session_close( session );
        session_shutdown( session );
    }

    sidlist_destroy( ids );

    return count;
}
예제 #2
0
파일: iolayer.c 프로젝트: snivel/libevlite
int32_t iolayer_shutdowns( iolayer_t self, sid_t * ids, uint32_t count )
{
    uint8_t i = 0;
    int32_t rc = 0;
    struct iolayer * layer = (struct iolayer *)self;

    for ( i = 0; i < layer->nthreads; ++i )
    {
        struct sidlist * list = sidlist_create( count );
        if ( list == NULL )
        {
            continue;
        }
        sidlist_adds( list, ids, count );

        // 参照iolayer_shutdown()

        // 跨线程提交批量终止任务
        int32_t result = iothreads_post( layer->group, i, eIOTaskType_Shutdowns, list, 0 );
        if ( unlikely(result != 0) )
        {
            sidlist_destroy( list );
            continue;
        }

        rc += count;
    }

    return rc;
}
예제 #3
0
int32_t message_set_receivers( struct message * self, struct sidlist * ids )
{
    if ( self->tolist )
    {
        sidlist_destroy( self->tolist );
    }

    self->tolist = ids;

    return 0;
}
예제 #4
0
void message_destroy( struct message * self )
{
    if ( self->tolist )
    {
        sidlist_destroy( self->tolist );
        self->tolist = NULL;
    }

//     if ( self->failurelist )
//     {
//         sidlist_destroy( self->failurelist );
//         self->failurelist = NULL;
//     }

    buffer_clear( &self->buffer );
    free( self );
}