Ignore:
File:
1 edited

Legend:

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

    r3f95dab r32d1383  
    1414#include "filecache.hfa"
    1515
    16 static const unsigned long long period = 50_000_000;
     16static const unsigned long long period = 5_000_000;
    1717
    1818//=============================================================================================
     
    3333
    3434                // if we are done, break out of the loop
    35                 if( closed ) break REQUEST;
     35                if( closed ) {
     36                        if( code != OK200 ) this.stats.sendfile.error++;
     37                        break REQUEST;
     38                }
    3639
    3740                // If this wasn't a request retrun 400
    3841                if( code != OK200 ) {
    39                         sout | "=== Invalid Request :" | code_val(code) | "===";
    40                         answer_error(fd, code);
    41                         continue REQUEST;
    42                 }
    43 
    44                 if(0 == strncmp(file, "plaintext", min(name_size, sizeof("plaintext") ))) {
    45                         if( options.log ) mutex(sout) sout | "=== Request for /plaintext ===";
    46 
    47                         int ret = answer_plaintext(fd);
    48                         if( ret == -ECONNRESET ) break REQUEST;
    49 
    50                         if( options.log ) mutex(sout) sout | "=== Answer sent ===";
    51                         continue REQUEST;
    52                 }
    53 
    54                 if(0 == strncmp(file, "ping", min(name_size, sizeof("ping") ))) {
    55                         if( options.log ) mutex(sout) sout | "=== Request for /ping ===";
    56 
    57                         // Send the header
    58                         int ret = answer_empty(fd);
    59                         if( ret == -ECONNRESET ) break REQUEST;
    60 
    61                         if( options.log ) mutex(sout) sout | "=== Answer sent ===";
    62                         continue REQUEST;
    63                 }
     42                        abort | "=== Invalid Request :" | code_val(code) | "===";
     43                        // answer_error(fd, code);
     44                        // continue REQUEST;
     45                }
     46
     47                // if(0 == strncmp(file, "plaintext", min(name_size, sizeof("plaintext") ))) {
     48                //      if( options.log ) mutex(sout) sout | "=== Request for /plaintext ===";
     49
     50                //      int ret = answer_plaintext(fd);
     51                //      if( ret == -ECONNRESET ) { this.stats.sendfile.error++; break REQUEST; }
     52
     53                //      if( options.log ) mutex(sout) sout | "=== Answer sent ===";
     54                //      continue REQUEST;
     55                // }
     56
     57                // if(0 == strncmp(file, "ping", min(name_size, sizeof("ping") ))) {
     58                //      if( options.log ) mutex(sout) sout | "=== Request for /ping ===";
     59
     60                //      // Send the header
     61                //      int ret = answer_empty(fd);
     62                //      if( ret == -ECONNRESET ) { this.stats.sendfile.error++; break REQUEST; }
     63
     64                //      if( options.log ) mutex(sout) sout | "=== Answer sent ===";
     65                //      continue REQUEST;
     66                // }
    6467
    6568                if( options.log ) {
     
    7073
    7174                if( !options.file_cache.path ) {
    72                         if( options.log ) {
    73                                 sout | "=== File Not Found (" | nonl;
    74                                 write(sout, file, name_size);
    75                                 sout | ") ===";
    76                         }
    77                         answer_error(fd, E405);
    78                         continue REQUEST;
     75                        // if( options.log ) {
     76                                serr | "=== File Not Found (" | nonl;
     77                                write(serr, file, name_size);
     78                                serr | ") ===";
     79                                abort();
     80                        // }
     81                        // answer_error(fd, E405);
     82                        // continue REQUEST;
    7983                }
    8084
     
    8690                // If we can't find the file, return 404
    8791                if( ans_fd < 0 ) {
    88                         if( options.log ) {
    89                                 sout | "=== File Not Found (" | nonl;
    90                                 write(sout, file, name_size);
    91                                 sout | ") ===";
    92                         }
    93                         answer_error(fd, E404);
    94                         continue REQUEST;
     92                        // if( options.log ) {
     93                                serr | "=== File Not Found 2 (" | nonl;
     94                                write(serr, file, name_size);
     95                                serr | ") ===";
     96                                abort();
     97                        // }
     98                        // answer_error(fd, E404);
     99                        // continue REQUEST;
    95100                }
    96101
     
    98103                int ret = answer_sendfile( this.pipe, fd, ans_fd, count, this.stats.sendfile );
    99104                if(ret < 0) {
    100                         if( ret == -ECONNABORTED ) break REQUEST;
    101                         if( ret == -ECONNRESET ) break REQUEST;
    102                         if( ret == -EPIPE ) break REQUEST;
    103                         abort( "sendfile error: %d (%d) %s\n", ret, (int)errno, strerror(errno) );
     105                        if( ret == -ECONNABORTED ) { this.stats.sendfile.error++; break REQUEST; }
     106                        if( ret == -ECONNRESET ) { this.stats.sendfile.error++; break REQUEST; }
     107                        if( ret == -EPIPE ) { this.stats.sendfile.error++; break REQUEST; }
     108                        if( ret == -EBADF ) { this.stats.sendfile.error++; break REQUEST; }
     109                        abort( "answer sendfile error: %d (%d) %s\n", ret, (int)errno, strerror(errno) );
    104110                }
    105111
     
    107113        }
    108114
     115        this.stats.sendfile.close++;
     116
    109117        if (stats_thrd) {
    110                 unsigned long long next = rdtscl();
    111                 if(next > (last + period)) {
     118                // unsigned long long next = rdtscl();
     119                // if(next > (last + period)) {
    112120                        if(try_lock(stats_thrd->stats.lock __cfaabi_dbg_ctx2)) {
    113121                                push(this.stats.sendfile, stats_thrd->stats.send);
    114122                                unlock(stats_thrd->stats.lock);
    115                                 last = next;
    116                         }
    117                 }
     123                                // last = next;
     124                        }
     125                // }
    118126        }
    119127}
     
    144152                if(this.done) break;
    145153
     154                this.stats.accepts++;
     155                if (stats_thrd && try_lock(stats_thrd->stats.lock)) {
     156                        push(this.stats, stats_thrd->stats.accpt);
     157                        unlock(stats_thrd->stats.lock);
     158                }
     159
    146160                if( options.log ) mutex(sout) sout | "=== New connection" | fd | "" | ", waiting for requests ===";
    147161                size_t len = options.socket.buflen;
     
    149163                handle_connection( this.conn, fd, buffer, len, 0p, last );
    150164                this.conn.stats.sendfile.maxfd = max(this.conn.stats.sendfile.maxfd, fd);
    151                 this.conn.stats.sendfile.close++;
    152165
    153166                if( options.log ) mutex(sout) sout | "=== Connection closed ===";
     
    172185        /* paranoid */ assert( this.conn.pipe[1] != -1 );
    173186        this.conn.stats.sendfile.maxfd = max(this.conn.pipe[0], this.conn.pipe[1]);
     187        // this.conn.stats.sendfile.maxfd = 0;
    174188        for() {
    175189                size_t len = options.socket.buflen;
     
    220234                p = pop(*this.queue);
    221235                if(p) break;
     236                // abort( "Too few threads" );
    222237                yield();
    223238                this.stats.creates++;
     
    288303
    289304                if (stats_thrd) {
    290                         unsigned long long next = rdtscl();
    291                         if(next > (last + period)) {
     305                        // unsigned long long next = rdtscl();
     306                        // if(next > (last + period)) {
    292307                                if(try_lock(stats_thrd->stats.lock)) {
    293308                                        push(this.stats, stats_thrd->stats.accpt);
    294309                                        unlock(stats_thrd->stats.lock);
    295                                         last = next;
     310                                        // last = next;
    296311                                }
    297                         }
     312                        // }
    298313                }
    299314
Note: See TracChangeset for help on using the changeset viewer.