Commit ca023b994fcf26ec26e22d09cce494023678328d
1 parent
05a7a386
fix handling of remote close - i should have another eye on this...there still s…
…eems to be something wrong.
Showing
4 changed files
with
11 additions
and
9 deletions
... | ... | @@ -10,7 +10,10 @@ serverCloseConn(Server this, unsigned int i) |
10 | 10 | |
11 | 11 | delete(&((this->conns)[fd].sock)); |
12 | 12 | delete(&((this->conns)[fd].reader)); |
13 | + memset((this->conns)[fd].wbuf, 0, strlen((this->conns)[fd].wbuf)); | |
13 | 14 | (this->fds)[i].events = 0; |
15 | + (this->fds)[i].revents = 0; | |
16 | + (this->fds)[i].fd = 0; | |
14 | 17 | this->ndel++; |
15 | 18 | // CLEAR_CONN(this, i); |
16 | 19 | // this->nfds--; | ... | ... |
... | ... | @@ -14,14 +14,14 @@ serverHandleAccept(Server this) |
14 | 14 | //* clone reader |
15 | 15 | (this->conns)[acc->handle].reader = clone(this->reader); |
16 | 16 | |
17 | - (this->fds)[this->nfds].fd = acc->handle; | |
18 | - (this->fds)[this->nfds].events = POLLIN; | |
17 | + (this->fds)[this->nfds].fd = acc->handle; | |
18 | + (this->fds)[this->nfds].events = POLLIN; | |
19 | 19 | this->nfds++; |
20 | 20 | } else { |
21 | 21 | delete(&acc); |
22 | 22 | } |
23 | 23 | |
24 | - (this->fds)[0].revents |= POLLIN; | |
24 | +// (this->fds)[0].revents |= POLLIN; | |
25 | 25 | } |
26 | 26 | |
27 | 27 | // vim: set ts=4 sw=4: | ... | ... |
... | ... | @@ -3,6 +3,7 @@ int |
3 | 3 | serverRead(Server this, unsigned int i) |
4 | 4 | { |
5 | 5 | int fd = (this->fds)[i].fd; |
6 | + int size; | |
6 | 7 | |
7 | 8 | if (NULL == (this->conns)[fd].reader) { |
8 | 9 | loggerLog( |
... | ... | @@ -12,7 +13,7 @@ serverRead(Server this, unsigned int i) |
12 | 13 | serverCloseConn(this, i); |
13 | 14 | } |
14 | 15 | |
15 | - switch (streamReaderRead((this->conns)[fd].reader, fd)) { | |
16 | + switch ((size = streamReaderRead((this->conns)[fd].reader, fd))) { | |
16 | 17 | case 0: |
17 | 18 | /* |
18 | 19 | * normal close: write remaining data |
... | ... | @@ -32,7 +33,7 @@ serverRead(Server this, unsigned int i) |
32 | 33 | break; |
33 | 34 | } |
34 | 35 | |
35 | - return 0; | |
36 | + return size; | |
36 | 37 | } |
37 | 38 | |
38 | 39 | // vim: set ts=4 sw=4: | ... | ... |
... | ... | @@ -65,15 +65,14 @@ serverRun(Server this) |
65 | 65 | * handle reads |
66 | 66 | */ |
67 | 67 | else { |
68 | - serverRead(this, i); | |
69 | - | |
70 | 68 | /** |
71 | 69 | * do some other processing |
72 | 70 | * @TODO: actually this will hard assume that our stream reader |
73 | 71 | * is a http parser and it has its queue...think about more |
74 | 72 | * generalizing here. |
75 | 73 | */ |
76 | - { | |
74 | + int size; | |
75 | + if (0 < (size=serverRead(this, i))) { | |
77 | 76 | int j; |
78 | 77 | HttpRequestQueue queue = |
79 | 78 | ((HttpRequestParser)(this->conns)[fd].reader)->request_queue; |
... | ... | @@ -143,7 +142,6 @@ serverRun(Server this) |
143 | 142 | "write error, closing connection"); |
144 | 143 | } |
145 | 144 | |
146 | - (this->fds)[i].events = (this->fds)[i].events & ~POLLOUT; | |
147 | 145 | serverCloseConn(this, i); |
148 | 146 | } |
149 | 147 | else { | ... | ... |
Please
register
or
login
to post a comment