Changeset 118 in Main for trunk/Server/http.c


Ignore:
Timestamp:
Sep 21, 2024, 6:03:27 PM (8 weeks ago)
Author:
Nishi
Message:

use poll for select by default

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Server/http.c

    r104 r118  
    1919#include <winsock2.h>
    2020#else
     21#ifdef USE_POLL
     22#include <poll.h>
     23#else
    2124#include <sys/select.h>
     25#endif
    2226#endif
    2327
     
    4650        char cbuf[2];
    4751        int phase = 0;
     52
     53#ifdef USE_POLL
     54        struct pollfd pollfds[1];
     55        pollfds[0].fd = sock;
     56        pollfds[0].events = POLLIN | POLLPRI;
     57#else
    4858        fd_set fds;
     59#endif
    4960
    5061        bool bad = false;
     
    6475
    6576        while(1) {
     77#ifndef USE_POLL
    6678                FD_ZERO(&fds);
    6779                FD_SET(sock, &fds);
     
    6981                tv.tv_sec = 5;
    7082                tv.tv_usec = 0;
     83#endif
    7184#ifndef NO_SSL
    7285                if(ssl == NULL || !SSL_has_pending(ssl)) {
    7386#endif
     87#ifdef USE_POLL
     88                        int n = poll(pollfds, 1, 5000);
     89#else
    7490#ifdef __HAIKU__
    75                         int n = select(32, &fds, NULL, NULL, &tv);
     91                int n = select(32, &fds, NULL, NULL, &tv);
    7692#else
    7793                int n = select(FD_SETSIZE, &fds, NULL, NULL, &tv);
     94#endif
    7895#endif
    7996                        if(n <= 0) {
Note: See TracChangeset for help on using the changeset viewer.