Changes in / [b6e0b61:c8f5f7d]


Ignore:
Location:
benchmark/io/http
Files:
5 edited

Legend:

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

    rb6e0b61 rc8f5f7d  
    234234        int addrlen = prepaddr(address);
    235235
    236         int server_fd;
    237         if(!options.socket.manyreuse) {
    238                 server_fd = listener(address, addrlen);
    239         }
     236        int server_fd = listener(address, addrlen);
    240237
    241238        //===================
     
    274271                                                workers[i].pipe[0] = fds[pipe_off + (i * 2) + 0];
    275272                                                workers[i].pipe[1] = fds[pipe_off + (i * 2) + 1];
    276                                                 workers[i].sockfd  = options.socket.manyreuse ?  listener(address, addrlen) : server_fd;
     273                                                workers[i].sockfd  = server_fd;
    277274                                                workers[i].addr    = (struct sockaddr *)&address;
    278275                                                workers[i].addrlen = (socklen_t*)&addrlen;
     
    314311
    315312                                sout | "Shutting down socket..." | nonl; flush( sout );
    316                                 if(options.socket.manyreuse) {
    317                                         for(i; options.clopts.nworkers) {
    318                                                 ret = shutdown( workers[i].sockfd, SHUT_RD );
    319                                                 if(ret < 0) abort( "close socket %d error: (%d) %s\n", i, (int)errno, strerror(errno) );
    320                                         }
    321                                 }
    322                                 else {
    323                                         ret = shutdown( server_fd, SHUT_RD );
    324                                         if( ret < 0 ) {
    325                                                 abort( "shutdown error: (%d) %s\n", (int)errno, strerror(errno) );
    326                                         }
     313                                int ret = shutdown( server_fd, SHUT_RD );
     314                                if( ret < 0 ) {
     315                                        abort( "shutdown error: (%d) %s\n", (int)errno, strerror(errno) );
    327316                                }
    328317                                sout | "done";
     
    331320                                // Close Socket
    332321                                sout | "Closing Socket..." | nonl; flush( sout );
    333                                 if(options.socket.manyreuse) {
    334                                         for(i; options.clopts.nworkers) {
    335                                                 ret = close(workers[i].sockfd);
    336                                                 if(ret < 0) abort( "close socket %d error: (%d) %s\n", i, (int)errno, strerror(errno) );
    337                                         }
    338                                 }
    339                                 else {
    340                                         ret = close( server_fd );
    341                                         if(ret < 0) {
    342                                                 abort( "close socket error: (%d) %s\n", (int)errno, strerror(errno) );
    343                                         }
     322                                ret = close( server_fd );
     323                                if(ret < 0) {
     324                                        abort( "close socket error: (%d) %s\n", (int)errno, strerror(errno) );
    344325                                }
    345326                                sout | "done";
  • benchmark/io/http/options.cfa

    rb6e0b61 rc8f5f7d  
    3535
    3636        { // socket
    37                 8080,  // port
    38                 10,    // backlog
    39                 1024,  // buflen
    40                 false, // onereuse
    41                 false  // manyreuse
     37                8080, // port
     38                10,   // backlog
     39                1024  // buflen
    4240        },
    4341
     
    7270                {'\0', "shell",          "Disable interactive mode", options.interactive, parse_setfalse},
    7371                {'\0', "accept-backlog", "Maximum number of pending accepts", options.socket.backlog},
    74                 {'\0', "reuseport-one",  "Create a single listen socket with SO_REUSEPORT", options.socket.onereuse, parse_settrue},
    75                 {'\0', "reuseport",      "Use many listen sockets with SO_REUSEPORT", options.socket.manyreuse, parse_settrue},
    7672                {'\0', "request_len",    "Maximum number of bytes in the http request, requests with more data will be answered with Http Code 414", options.socket.buflen},
    7773                {'\0', "seed",           "seed to use for hashing", options.file_cache.hash_seed },
  • benchmark/io/http/options.hfa

    rb6e0b61 rc8f5f7d  
    2727                int backlog;
    2828                int buflen;
    29                 bool onereuse;
    30                 bool manyreuse;
    3129        } socket;
    3230
  • benchmark/io/http/socket.cfa

    rb6e0b61 rc8f5f7d  
    3131        }
    3232
    33         if(options.socket.onereuse || options.socket.manyreuse) {
    34                 int value = 1;
    35                 // if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (const void*)&on, sizeof(on)))
    36                 //      abort( "setsockopt SO_REUSEADDR error: (%d) %s\n", (int)errno, strerror(errno) );
    37                 if (setsockopt(sockfd, SOL_SOCKET, SO_REUSEPORT, &value, sizeof(int)) < 0)
    38                         abort( "setsockopt SO_REUSEPORT error: (%d) %s\n", (int)errno, strerror(errno) );
    39         }
     33        int value = 1;
     34        if (setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &value, sizeof(int)) < 0)
     35                abort( "setsockopt error: (%d) %s\n", (int)errno, strerror(errno) );
    4036
    4137        int ret = 0;
  • benchmark/io/http/worker.cfa

    rb6e0b61 rc8f5f7d  
    4343        /* paranoid */ assert( this.pipe[0] != -1 );
    4444        /* paranoid */ assert( this.pipe[1] != -1 );
    45 
    46         const bool reuse = options.socket.manyreuse;
    4745
    4846        CONNECTION:
Note: See TracChangeset for help on using the changeset viewer.