dispatcher_wait(Dispatcher *dispr, uint32_t timeout)

{

    struct timeval tv;

    tv.tv_sec = timeout / 1000000;

    tv.tv_usec = timeout % 1000000;



    fd_set fdset = dispr->fdset;



    /* wait until some of sockets become readable. */

    int rc = select(dispr->max_sock + 1, &fdset, 0, 0, &tv);



    if (rc == -1) {

        vubr_die("select");

    }



    /* Timeout */

    if (rc == 0) {

        return 0;

    }



    /* Now call callback for every ready socket. */



    int sock;

    for (sock = 0; sock < dispr->max_sock + 1; sock++)

        if (FD_ISSET(sock, &fdset)) {

            Event *e = &dispr->events[sock];

            e->callback(sock, e->ctx);

        }



    return 0;

}

dispatcher_wait(Dispatcher *dispr, uint32_t timeout)

{

    struct timeval tv;

    tv.tv_sec = timeout / 1000000;

    tv.tv_usec = timeout % 1000000;



    fd_set fdset = dispr->fdset;



    

    int rc = select(dispr->max_sock + 1, &fdset, 0, 0, &tv);



    if (rc == -1) {

        vubr_die("select");

    }



    

    if (rc == 0) {

        return 0;

    }



    



    int sock;

    for (sock = 0; sock < dispr->max_sock + 1; sock++)

        if (FD_ISSET(sock, &fdset)) {

            Event *e = &dispr->events[sock];

            e->callback(sock, e->ctx);

        }



    return 0;

}

    for (sock = 0; sock < dispr->max_sock + 1; sock++)         if (FD_ISSET(sock, &fdset)) {
FUNC_0(Dispatcher *VAR_0, uint32_t VAR_1)

{

    struct timeval VAR_2;

    VAR_2.tv_sec = VAR_1 / 1000000;

    VAR_2.tv_usec = VAR_1 % 1000000;



    fd_set fdset = VAR_0->fdset;



    

    int VAR_3 = select(VAR_0->max_sock + 1, &fdset, 0, 0, &VAR_2);



    if (VAR_3 == -1) {

        vubr_die("select");

    }



    

    if (VAR_3 == 0) {

        return 0;

    }



    



    int VAR_4;

    for (VAR_4 = 0; VAR_4 < VAR_0->max_sock + 1; VAR_4++)

        if (FD_ISSET(VAR_4, &fdset)) {

            Event *e = &VAR_0->events[VAR_4];

            e->callback(VAR_4, e->ctx);

        }



    return 0;

}

FUNC_0(Dispatcher *VAR_0, uint32_t VAR_1)
{ struct timeval VAR_2; VAR_2.tv_sec = VAR_1 / 1000000; VAR_2.tv_usec = VAR_1 % 1000000; fd_set fdset = VAR_0->fdset; int VAR_3 = select(VAR_0->max_sock + 1, &fdset, 0, 0, &VAR_2); if (VAR_3 == -1) { vubr_die("select"); } if (VAR_3 == 0) { return 0; } int VAR_4; for (VAR_4 = 0; VAR_4 < VAR_0->max_sock + 1; VAR_4++) if (FD_ISSET(VAR_4, &fdset)) { Event *e = &VAR_0->events[VAR_4]; e->callback(VAR_4, e->ctx); } return 0; }