Commit ca023b994fcf26ec26e22d09cce494023678328d

Authored by Georg Hopp
1 parent 05a7a386

fix handling of remote close - i should have another eye on this...there still s…

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