Changes in / [b6e0b61:c8f5f7d]
- Location:
- benchmark/io/http
- Files:
-
- 5 edited
-
main.cfa (modified) (4 diffs)
-
options.cfa (modified) (2 diffs)
-
options.hfa (modified) (1 diff)
-
socket.cfa (modified) (1 diff)
-
worker.cfa (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
benchmark/io/http/main.cfa
rb6e0b61 rc8f5f7d 234 234 int addrlen = prepaddr(address); 235 235 236 int server_fd; 237 if(!options.socket.manyreuse) { 238 server_fd = listener(address, addrlen); 239 } 236 int server_fd = listener(address, addrlen); 240 237 241 238 //=================== … … 274 271 workers[i].pipe[0] = fds[pipe_off + (i * 2) + 0]; 275 272 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; 277 274 workers[i].addr = (struct sockaddr *)&address; 278 275 workers[i].addrlen = (socklen_t*)&addrlen; … … 314 311 315 312 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) ); 327 316 } 328 317 sout | "done"; … … 331 320 // Close Socket 332 321 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) ); 344 325 } 345 326 sout | "done"; -
benchmark/io/http/options.cfa
rb6e0b61 rc8f5f7d 35 35 36 36 { // 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 42 40 }, 43 41 … … 72 70 {'\0', "shell", "Disable interactive mode", options.interactive, parse_setfalse}, 73 71 {'\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},76 72 {'\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}, 77 73 {'\0', "seed", "seed to use for hashing", options.file_cache.hash_seed }, -
benchmark/io/http/options.hfa
rb6e0b61 rc8f5f7d 27 27 int backlog; 28 28 int buflen; 29 bool onereuse;30 bool manyreuse;31 29 } socket; 32 30 -
benchmark/io/http/socket.cfa
rb6e0b61 rc8f5f7d 31 31 } 32 32 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) ); 40 36 41 37 int ret = 0; -
benchmark/io/http/worker.cfa
rb6e0b61 rc8f5f7d 43 43 /* paranoid */ assert( this.pipe[0] != -1 ); 44 44 /* paranoid */ assert( this.pipe[1] != -1 ); 45 46 const bool reuse = options.socket.manyreuse;47 45 48 46 CONNECTION:
Note:
See TracChangeset
for help on using the changeset viewer.