Changeset 07997cd for benchmark/io/http


Ignore:
Timestamp:
Jun 10, 2022, 5:35:55 PM (2 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, ast-experimental, master, pthread-emulation, qualifiedEnum
Children:
1f0ee71
Parents:
8419b76
Message:

Fixed errors with the accept many version

Location:
benchmark/io/http
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • benchmark/io/http/socket.cfa

    r8419b76 r07997cd  
    2727int listener(struct sockaddr_in & address, int addrlen) {
    2828        int type = SOCK_STREAM;
    29         if(options.socket.reuseport) type |= SOCK_NONBLOCK;
     29        // if(options.socket.reuseport) type |= SOCK_NONBLOCK;
    3030        int sockfd = socket(AF_INET, type, 0);
    3131        if(sockfd < 0) {
  • benchmark/io/http/worker.cfa

    r8419b76 r07997cd  
    189189}
    190190
    191 #define ACCEPT_SPIN
     191static inline __s32 get_res( io_future_t & this ) {
     192        if( this.result < 0 ) {{
     193                errno = -this.result;
     194                return -1;
     195        }}
     196        return this.result;
     197}
     198
     199static inline void push_connection( Acceptor & this, int fd ) {
     200        PendingRead * p = 0p;
     201        for() {
     202                if(this.done) return;
     203                p = pop(*this.queue);
     204                if(p) break;
     205                yield();
     206                this.stats.creates++;
     207        };
     208
     209        p->out.fd = fd;
     210        async_recv(p->f, p->out.fd, p->in.buf, p->in.len, 0, CFA_IO_LAZY);
     211}
     212
     213// #define ACCEPT_SPIN
     214#define ACCEPT_MANY
    192215
    193216void main( Acceptor & this ) {
     
    215238                if( options.log ) sout | "=== New connection" | fd | "" | ", waiting for requests ===";
    216239
    217                 if(fd) {
    218                         PendingRead * p = 0p;
    219                         for() {
    220                                 if(this.done) return;
    221                                 p = pop(*this.queue);
    222                                 if(p) break;
    223                                 yield();
    224                                 this.stats.creates++;
    225                         };
    226 
    227                         p->out.fd = fd;
    228                         async_recv(p->f, p->out.fd, p->in.buf, p->in.len, 0, CFA_IO_LAZY);
    229                 }
     240                if(fd) push_connection(this, fd);
    230241
    231242                if (stats_thrd) {
     
    243254        }
    244255
    245 #elif define(ACCEPT_MANY)
     256#elif defined(ACCEPT_MANY)
    246257        const int nacc = 10;
    247258        io_future_t results[nacc];
Note: See TracChangeset for help on using the changeset viewer.