Browse Source
changed request handling. @TODO: I still seem to have the problem that the file handles are not closed and freed correctly as the service refuses connections after about a 1000.
master
changed request handling. @TODO: I still seem to have the problem that the file handles are not closed and freed correctly as the service refuses connections after about a 1000.
master
11 changed files with 193 additions and 114 deletions
-
10ChangeLog
-
13include/server.h
-
7src/http/request_parser.c
-
12src/server/close_conn.c
-
32src/server/handle_accept.c
-
28src/server/poll.c
-
56src/server/read.c
-
137src/server/run.c
-
9src/socket.c
-
2src/socket/accept.c
-
1src/testserver.c
@ -1,41 +1,37 @@ |
|||||
static |
static |
||||
int |
int |
||||
serverRead(Server this) |
|
||||
|
serverRead(Server this, unsigned int i) |
||||
{ |
{ |
||||
unsigned int i; |
|
||||
|
int fd = (this->fds)[i].fd; |
||||
|
|
||||
for (i=1; i<this->nfds; i++) { |
|
||||
if (0 != ((this->fds)[i].revents & POLLIN)) { |
|
||||
if (NULL == (this->conns)[i].reader) { |
|
||||
loggerLog( |
|
||||
this->logger, |
|
||||
LOGGER_INFO, |
|
||||
"initialization error: NULL reader"); |
|
||||
serverCloseConn(this, i); |
|
||||
} |
|
||||
|
if (NULL == (this->conns)[fd].reader) { |
||||
|
loggerLog( |
||||
|
this->logger, |
||||
|
LOGGER_INFO, |
||||
|
"initialization error: NULL reader"); |
||||
|
serverCloseConn(this, i); |
||||
|
} |
||||
|
|
||||
switch (streamReaderRead((this->conns)[i].reader, (this->fds)[i].fd)) { |
|
||||
case 0: |
|
||||
/* |
|
||||
* normal close: write remaining data |
|
||||
* @TODO: actually we have no remaining data here.... |
|
||||
*/ |
|
||||
/* DROP-THROUGH */ |
|
||||
|
switch (streamReaderRead((this->conns)[fd].reader, fd)) { |
||||
|
case 0: |
||||
|
/* |
||||
|
* normal close: write remaining data |
||||
|
* @TODO: actually we have no remaining data here.... |
||||
|
*/ |
||||
|
/* DROP-THROUGH */ |
||||
|
|
||||
case -1: |
|
||||
/* |
|
||||
* read failure / close connection |
|
||||
*/ |
|
||||
loggerLog(this->logger, LOGGER_INFO, "connection closed..."); |
|
||||
serverCloseConn(this, i); |
|
||||
break; |
|
||||
|
case -1: |
||||
|
/* |
||||
|
* read failure / close connection |
||||
|
*/ |
||||
|
loggerLog(this->logger, LOGGER_INFO, "connection closed..."); |
||||
|
serverCloseConn(this, i); |
||||
|
break; |
||||
|
|
||||
default: |
|
||||
break; |
|
||||
} |
|
||||
} |
|
||||
|
default: |
||||
|
break; |
||||
} |
} |
||||
|
|
||||
|
|
||||
return 0; |
return 0; |
||||
} |
} |
||||
|
|
||||
|
|||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue