Changes in benchmark/io/http/worker.cfa [d9c2284:c82af9f]
- File:
-
- 1 edited
-
benchmark/io/http/worker.cfa (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
benchmark/io/http/worker.cfa
rd9c2284 rc82af9f 12 12 #include "filecache.hfa" 13 13 14 extern "C" { 15 // extern ssize_t sendfile(int out_fd, int in_fd, off_t *offset, size_t count); 16 extern ssize_t splice(int fd_in, loff_t *off_in, int fd_out, loff_t *off_out, size_t len, unsigned int flags); 17 } 18 19 ssize_t sendfile(int out_fd, int in_fd, off_t *offset, size_t count) { 20 return splice(in_fd, offset, out_fd, 0p, count, 0); 21 } 22 23 14 24 //============================================================================================= 15 25 // Worker Thread 16 26 //============================================================================================= 17 27 void ?{}( Worker & this ) { 18 ((thread&)this){ "Server Worker Thread", *options. clopts.instance};19 this.pipe[0] = -1;20 this.pipe[1] = -1;28 ((thread&)this){ "Server Worker Thread", *options.the_cluster }; 29 int ret = pipe(this.pipe); 30 if( ret < 0 ) { abort( "pipe error: (%d) %s\n", (int)errno, strerror(errno) ); } 21 31 } 22 32 23 33 void main( Worker & this ) { 24 park( __cfaabi_dbg_ctx );25 /* paranoid */ assert( this.pipe[0] != -1 );26 /* paranoid */ assert( this.pipe[1] != -1 );27 28 34 CONNECTION: 29 for() { 30 int fd = take(wait_connect); 31 if (fd < 0) break; 32 33 printf("New connection %d, waiting for requests\n", fd); 35 while( int fd = take(wait_connect); fd >= 0) { 36 printf("New connection, waiting for requests\n"); 34 37 REQUEST: 35 38 for() { … … 40 43 41 44 // Read the http request 42 size_t len = options.socket.buflen;45 size_t len = 1024; 43 46 char buffer[len]; 44 47 printf("Reading request\n"); … … 53 56 // If this wasn't a request retrun 400 54 57 if( code != OK200 ) { 55 printf("Invalid Request : %d\n", code_val(code));58 printf("Invalid Request\n"); 56 59 answer_error(fd, code); 57 60 continue REQUEST; 58 61 } 59 62 60 printf("Request for file %.*s\n", (int)name_size, file);63 printf("Request for file %.*s\n", name_size, file); 61 64 62 65 // Get the fd from the file cache … … 87 90 //============================================================================================= 88 91 void ?{}( Acceptor & this, int sockfd, struct sockaddr * addr, socklen_t * addrlen, int flags ) { 89 ((thread&)this){ "Acceptor Thread", *options. clopts.instance};92 ((thread&)this){ "Acceptor Thread", *options.the_cluster }; 90 93 this.sockfd = sockfd; 91 94 this.addr = addr; … … 102 105 } 103 106 104 printf("New connection accepted\n");107 printf("New connection accepted\n"); 105 108 put( wait_connect, ret ); 106 }109 } 107 110 }
Note:
See TracChangeset
for help on using the changeset viewer.