int main( int argc, char ** argv )
{
    uint8_t i = 0;
    uint16_t port = 0;
    uint8_t threadcount = 0;

    struct acceptor * a = NULL;
    struct iothread ** thrgroup = NULL;

    if ( argc != 3 )
    {
        printf("echoserver [port] [threadcount] .\n");
        return 0;
    }

    signal( SIGPIPE, SIG_IGN );
    signal( SIGINT, echoserver_signal_handler );
    signal( SIGTERM, echoserver_signal_handler );

    port = (uint16_t)atoi( argv[1] );
    threadcount = (uint8_t)atoi( argv[2] );

    a = acceptor_create( "127.0.0.1", port );

    thrgroup = (struct iothread **)malloc( threadcount*sizeof(struct iothread *) );
    for ( i = 0; i < threadcount; ++i )
    {
        thrgroup[i] = iothread_create( i+1, a );
    }

    isstarted = 1;
    while ( isstarted )
    {
    #if defined(__FreeBSD__)
        sleep(2);
    #else
        pause();
    #endif
    }

    for ( i = 0; i < threadcount; ++i )
    {
        evsets_destroy( thrgroup[i]->core_sets );
    }

    return 0;
}
Beispiel #2
0
static void blk_alloc(struct XenDevice *xendev)
{
    struct XenBlkDev *blkdev = container_of(xendev, struct XenBlkDev, xendev);
    Error *err = NULL;

    trace_xen_disk_alloc(xendev->name);

    QLIST_INIT(&blkdev->inflight);
    QLIST_INIT(&blkdev->finished);
    QLIST_INIT(&blkdev->freelist);

    blkdev->iothread = iothread_create(xendev->name, &err);
    assert(!err);

    blkdev->ctx = iothread_get_aio_context(blkdev->iothread);
    blkdev->bh = aio_bh_new(blkdev->ctx, blk_bh, blkdev);
}