- Timestamp:
- Jun 6, 2022, 9:04:31 PM (3 years ago)
- Branches:
- ADT, ast-experimental, master, pthread-emulation, qualifiedEnum
- Children:
- b6e0b61
- Parents:
- ac1aba4b
- Location:
- benchmark/io/http
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified benchmark/io/http/main.cfa ¶
rac1aba4b r86c12d65 234 234 int addrlen = prepaddr(address); 235 235 236 int server_fd = listener(address, addrlen); 236 int server_fd; 237 if(!options.socket.manyreuse) { 238 server_fd = listener(address, addrlen); 239 } 237 240 238 241 //=================== … … 271 274 workers[i].pipe[0] = fds[pipe_off + (i * 2) + 0]; 272 275 workers[i].pipe[1] = fds[pipe_off + (i * 2) + 1]; 273 workers[i].sockfd = server_fd;276 workers[i].sockfd = options.socket.manyreuse ? listener(address, addrlen) : server_fd; 274 277 workers[i].addr = (struct sockaddr *)&address; 275 278 workers[i].addrlen = (socklen_t*)&addrlen; … … 311 314 312 315 sout | "Shutting down socket..." | nonl; flush( sout ); 313 int ret = shutdown( server_fd, SHUT_RD ); 314 if( ret < 0 ) { 315 abort( "shutdown error: (%d) %s\n", (int)errno, strerror(errno) ); 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 } 316 327 } 317 328 sout | "done"; … … 320 331 // Close Socket 321 332 sout | "Closing Socket..." | nonl; flush( sout ); 322 ret = close( server_fd ); 323 if(ret < 0) { 324 abort( "close socket error: (%d) %s\n", (int)errno, strerror(errno) ); 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 } 325 344 } 326 345 sout | "done"; -
TabularUnified benchmark/io/http/options.cfa ¶
rac1aba4b r86c12d65 35 35 36 36 { // socket 37 8080, // port 38 10, // backlog 39 1024 // buflen 37 8080, // port 38 10, // backlog 39 1024, // buflen 40 false, // onereuse 41 false // manyreuse 40 42 }, 41 43 … … 70 72 {'\0', "shell", "Disable interactive mode", options.interactive, parse_setfalse}, 71 73 {'\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}, 72 76 {'\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}, 73 77 {'\0', "seed", "seed to use for hashing", options.file_cache.hash_seed }, -
TabularUnified benchmark/io/http/options.hfa ¶
rac1aba4b r86c12d65 27 27 int backlog; 28 28 int buflen; 29 bool onereuse; 30 bool manyreuse; 29 31 } socket; 30 32 -
TabularUnified benchmark/io/http/socket.cfa ¶
rac1aba4b r86c12d65 31 31 } 32 32 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) ); 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 } 36 40 37 41 int ret = 0; -
TabularUnified benchmark/io/http/worker.cfa ¶
rac1aba4b r86c12d65 43 43 /* paranoid */ assert( this.pipe[0] != -1 ); 44 44 /* paranoid */ assert( this.pipe[1] != -1 ); 45 46 const bool reuse = options.socket.manyreuse; 45 47 46 48 CONNECTION:
Note: See TracChangeset
for help on using the changeset viewer.