Ignore:
File:
1 edited

Legend:

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

    r8c43d05 ree59ede  
    66#include <unistd.h>
    77
    8 #include <fstream.hfa>
    98#include <iofwd.hfa>
    109
     
    3433        CONNECTION:
    3534        for() {
    36                 if( options.log ) sout | "=== Accepting connection ===";
     35                if( options.log ) printf("=== Accepting connection ===\n");
    3736                int fd = cfa_accept4( this.[sockfd, addr, addrlen, flags], 0, -1`s, &this.cancel, 0p );
    3837                // int fd = accept4( this.[sockfd, addr, addrlen, flags] );
     
    4342                }
    4443
    45                 if( options.log ) sout | "=== New connection" | fd | "" | ", waiting for requests ===";
     44                if( options.log ) printf("=== New connection %d, waiting for requests ===\n", fd);
    4645                REQUEST:
    4746                for() {
     
    5453                        size_t len = options.socket.buflen;
    5554                        char buffer[len];
    56                         if( options.log ) sout | "=== Reading request ===";
     55                        if( options.log ) printf("=== Reading request ===\n");
    5756                        [code, closed, file, name_size] = http_read(fd, buffer, len, &this.cancel);
    5857
     
    6261                        // If this wasn't a request retrun 400
    6362                        if( code != OK200 ) {
    64                                 sout | "=== Invalid Request :" | code_val(code) | "===";
     63                                printf("=== Invalid Request : %d ===\n", code_val(code));
    6564                                answer_error(fd, code);
    6665                                continue REQUEST;
     
    6867
    6968                        if(0 == strncmp(file, "plaintext", min(name_size, sizeof("plaintext") ))) {
    70                                 if( options.log ) sout | "=== Request for /plaintext ===";
     69                                if( options.log ) printf("=== Request for /plaintext ===\n");
    7170
    7271                                char text[] = "Hello, World!\n";
     
    7675                                if( ret == -ECONNRESET ) break REQUEST;
    7776
    78                                 if( options.log ) sout | "=== Answer sent ===";
     77                                if( options.log ) printf("=== Answer sent ===\n");
    7978                                continue REQUEST;
    8079                        }
    8180
    8281                        if(0 == strncmp(file, "ping", min(name_size, sizeof("ping") ))) {
    83                                 if( options.log ) sout | "=== Request for /ping ===";
     82                                if( options.log ) printf("=== Request for /ping ===\n");
    8483
    8584                                // Send the header
     
    8786                                if( ret == -ECONNRESET ) break REQUEST;
    8887
    89                                 if( options.log ) sout | "=== Answer sent ===";
     88                                if( options.log ) printf("=== Answer sent ===\n");
    9089                                continue REQUEST;
    9190                        }
    9291
    93                         if( options.log ) {
    94                                 sout | "=== Request for file " | nonl;
    95                                 write(sout, file, name_size);
    96                                 sout | " ===";
    97                         }
     92                        if( options.log ) printf("=== Request for file %.*s ===\n", (int)name_size, file);
    9893
    9994                        // Get the fd from the file cache
     
    10499                        // If we can't find the file, return 404
    105100                        if( ans_fd < 0 ) {
    106                                 sout | "=== File Not Found (" | nonl;
    107                                 write(sout, file, name_size);
    108                                 sout | ") ===";
     101                                printf("=== File Not Found ===\n");
    109102                                answer_error(fd, E404);
    110103                                continue REQUEST;
     
    119112                        if( ret == -ECONNRESET ) break REQUEST;
    120113
    121                         if( options.log ) sout | "=== Answer sent ===";
     114                        if( options.log ) printf("=== Answer sent ===\n");
    122115                }
    123116
    124                 if( options.log ) sout | "=== Connection closed ===";
     117                if( options.log ) printf("=== Connection closed ===\n");
    125118                close(fd);
    126119                continue CONNECTION;
Note: See TracChangeset for help on using the changeset viewer.