Changeset 10ba012 for benchmark


Ignore:
Timestamp:
Jun 10, 2022, 3:04:27 PM (23 months ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, ast-experimental, master, pthread-emulation, qualifiedEnum
Children:
c25338d
Parents:
f3da205
Message:

Minor fixes to Worker threads

File:
1 edited

Legend:

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

    rf3da205 r10ba012  
    2626
    2727                // Read the http request
    28                 if( options.log ) sout | "=== Reading request ===";
     28                if( options.log ) mutex(sout) sout | "=== Reading request ===";
    2929                [code, closed, file, name_size] = http_read(fd, buffer, len, f);
    3030                f = 0p;
     
    4141
    4242                if(0 == strncmp(file, "plaintext", min(name_size, sizeof("plaintext") ))) {
    43                         if( options.log ) sout | "=== Request for /plaintext ===";
     43                        if( options.log ) mutex(sout) sout | "=== Request for /plaintext ===";
    4444
    4545                        int ret = answer_plaintext(fd);
    4646                        if( ret == -ECONNRESET ) break REQUEST;
    4747
    48                         if( options.log ) sout | "=== Answer sent ===";
     48                        if( options.log ) mutex(sout) sout | "=== Answer sent ===";
    4949                        continue REQUEST;
    5050                }
    5151
    5252                if(0 == strncmp(file, "ping", min(name_size, sizeof("ping") ))) {
    53                         if( options.log ) sout | "=== Request for /ping ===";
     53                        if( options.log ) mutex(sout) sout | "=== Request for /ping ===";
    5454
    5555                        // Send the header
     
    5757                        if( ret == -ECONNRESET ) break REQUEST;
    5858
    59                         if( options.log ) sout | "=== Answer sent ===";
     59                        if( options.log ) mutex(sout) sout | "=== Answer sent ===";
    6060                        continue REQUEST;
    6161                }
     
    9797                if( ret == -ECONNRESET ) break REQUEST;
    9898
    99                 if( options.log ) sout | "=== Answer sent ===";
     99                if( options.log ) mutex(sout) sout | "=== Answer sent ===";
    100100        }
    101101
     
    103103                unsigned long long next = rdtscl();
    104104                if(next > (last + 500000000)) {
    105                         if(try_lock(stats_thrd->stats.lock)) {
     105                        if(try_lock(stats_thrd->stats.lock __cfaabi_dbg_ctx2)) {
    106106                                push(this.stats.sendfile, stats_thrd->stats.send);
    107107                                unlock(stats_thrd->stats.lock);
     
    127127        /* paranoid */ assert( this.conn.pipe[1] != -1 );
    128128        for() {
    129                 if( options.log ) sout | "=== Accepting connection ===";
     129                if( options.log ) mutex(sout) sout | "=== Accepting connection ===";
    130130                int fd = cfa_accept4( this.sockfd, this.[addr, addrlen, flags], CFA_IO_LAZY );
    131131                if(fd < 0) {
     
    136136                if(this.done) break;
    137137
    138                 if( options.log ) sout | "=== New connection" | fd | "" | ", waiting for requests ===";
     138                if( options.log ) mutex(sout) sout | "=== New connection" | fd | "" | ", waiting for requests ===";
    139139                size_t len = options.socket.buflen;
    140140                char buffer[len];
    141141                handle_connection( this.conn, fd, buffer, len, 0p, last );
    142142
    143                 if( options.log ) sout | "=== Connection closed ===";
     143                if( options.log ) mutex(sout) sout | "=== Connection closed ===";
    144144        }
    145145}
     
    164164                char buffer[len];
    165165                PendingRead p;
     166                p.next = 0p;
    166167                p.in.buf = (void*)buffer;
    167168                p.in.len = len;
    168169                push(*this.queue, &p);
    169170
    170                 if( options.log ) sout | "=== Waiting new connection ===";
     171                if( options.log ) mutex(sout) sout | "=== Waiting new connection ===";
    171172                handle_connection( this.conn, p.out.fd, buffer, len, &p.f, last );
    172173
    173                 if( options.log ) sout | "=== Connection closed ===";
     174                if( options.log ) mutex(sout) sout | "=== Connection closed ===";
    174175                if(this.done) break;
    175176        }
     
    181182
    182183void ?{}( Acceptor & this ) {
    183         ((thread&)this){ "Server Worker Thread", *options.clopts.instance, 64000 };
     184        ((thread&)this){ "Server Acceptor Thread", *options.clopts.instance, 64000 };
    184185        options.clopts.thrd_cnt++;
    185186        this.done = false;
Note: See TracChangeset for help on using the changeset viewer.