Changes in benchmark/io/http/worker.cfa [8c43d05:ee59ede]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
benchmark/io/http/worker.cfa
r8c43d05 ree59ede 6 6 #include <unistd.h> 7 7 8 #include <fstream.hfa>9 8 #include <iofwd.hfa> 10 9 … … 34 33 CONNECTION: 35 34 for() { 36 if( options.log ) sout | "=== Accepting connection ===";35 if( options.log ) printf("=== Accepting connection ===\n"); 37 36 int fd = cfa_accept4( this.[sockfd, addr, addrlen, flags], 0, -1`s, &this.cancel, 0p ); 38 37 // int fd = accept4( this.[sockfd, addr, addrlen, flags] ); … … 43 42 } 44 43 45 if( options.log ) sout | "=== New connection" | fd | "" | ", waiting for requests ===";44 if( options.log ) printf("=== New connection %d, waiting for requests ===\n", fd); 46 45 REQUEST: 47 46 for() { … … 54 53 size_t len = options.socket.buflen; 55 54 char buffer[len]; 56 if( options.log ) sout | "=== Reading request ===";55 if( options.log ) printf("=== Reading request ===\n"); 57 56 [code, closed, file, name_size] = http_read(fd, buffer, len, &this.cancel); 58 57 … … 62 61 // If this wasn't a request retrun 400 63 62 if( code != OK200 ) { 64 sout | "=== Invalid Request :" | code_val(code) | "===";63 printf("=== Invalid Request : %d ===\n", code_val(code)); 65 64 answer_error(fd, code); 66 65 continue REQUEST; … … 68 67 69 68 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"); 71 70 72 71 char text[] = "Hello, World!\n"; … … 76 75 if( ret == -ECONNRESET ) break REQUEST; 77 76 78 if( options.log ) sout | "=== Answer sent ===";77 if( options.log ) printf("=== Answer sent ===\n"); 79 78 continue REQUEST; 80 79 } 81 80 82 81 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"); 84 83 85 84 // Send the header … … 87 86 if( ret == -ECONNRESET ) break REQUEST; 88 87 89 if( options.log ) sout | "=== Answer sent ===";88 if( options.log ) printf("=== Answer sent ===\n"); 90 89 continue REQUEST; 91 90 } 92 91 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); 98 93 99 94 // Get the fd from the file cache … … 104 99 // If we can't find the file, return 404 105 100 if( ans_fd < 0 ) { 106 sout | "=== File Not Found (" | nonl; 107 write(sout, file, name_size); 108 sout | ") ==="; 101 printf("=== File Not Found ===\n"); 109 102 answer_error(fd, E404); 110 103 continue REQUEST; … … 119 112 if( ret == -ECONNRESET ) break REQUEST; 120 113 121 if( options.log ) sout | "=== Answer sent ===";114 if( options.log ) printf("=== Answer sent ===\n"); 122 115 } 123 116 124 if( options.log ) sout | "=== Connection closed ===";117 if( options.log ) printf("=== Connection closed ===\n"); 125 118 close(fd); 126 119 continue CONNECTION;
Note: See TracChangeset
for help on using the changeset viewer.