Ignore:
Timestamp:
Jan 9, 2021, 4:27:57 PM (3 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
561dd26
Parents:
35fd2c4
Message:

Added prints.
Naive implementation of cancel.
Server now shutdown cleanly.

File:
1 edited

Legend:

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

    r35fd2c4 rece0e80  
    2828        CONNECTION:
    2929        for() {
    30                 int fd = cfa_accept4( this.[sockfd, addr, addrlen, flags], 0, -1`s, 0p, 0p );
     30                printf("=== Accepting connection ===\n");
     31                int fd = cfa_accept4( this.[sockfd, addr, addrlen, flags], 0, -1`s, &this.cancel, 0p );
    3132                if(fd < 0) {
    3233                        if( errno == ECONNABORTED ) break;
     34                        if( errno == EINVAL ) break;
    3335                        abort( "accept error: (%d) %s\n", (int)errno, strerror(errno) );
    3436                }
    3537
    36                 printf("New connection %d, waiting for requests\n", fd);
     38                printf("=== New connection %d, waiting for requests ===\n", fd);
    3739                REQUEST:
    3840                for() {
     
    4547                        size_t len = options.socket.buflen;
    4648                        char buffer[len];
    47                         printf("Reading request\n");
    48                         [code, closed, file, name_size] = http_read(fd, buffer, len);
     49                        printf("=== Reading request ===\n");
     50                        [code, closed, file, name_size] = http_read(fd, buffer, len, &this.cancel);
    4951
    5052                        // if we are done, break out of the loop
    5153                        if( closed ) {
    52                                 printf("Connection closed\n");
     54                                printf("=== Connection closed ===\n");
    5355                                continue CONNECTION;
    5456                        }
     
    5658                        // If this wasn't a request retrun 400
    5759                        if( code != OK200 ) {
    58                                 printf("Invalid Request : %d\n", code_val(code));
     60                                printf("=== Invalid Request : %d ===\n", code_val(code));
    5961                                answer_error(fd, code);
    6062                                continue REQUEST;
    6163                        }
    6264
    63                         printf("Request for file %.*s\n", (int)name_size, file);
     65                        printf("=== Request for file %.*s ===\n", (int)name_size, file);
    6466
    6567                        // Get the fd from the file cache
     
    7072                        // If we can't find the file, return 404
    7173                        if( ans_fd < 0 ) {
    72                                 printf("File Not Found\n");
     74                                printf("=== File Not Found ===\n");
    7375                                answer_error(fd, E404);
    7476                                continue REQUEST;
     
    8183                        sendfile( this.pipe, fd, ans_fd, count);
    8284
    83                         printf("File sent\n");
     85                        printf("=== File sent ===\n");
    8486                }
    8587        }
Note: See TracChangeset for help on using the changeset viewer.