Browse Source

fix handling of remote close - i should have another eye on this...there still seems to be something wrong.

master
Georg Hopp 14 years ago
parent
commit
ca023b994f
  1. 3
      src/server/close_conn.c
  2. 2
      src/server/handle_accept.c
  3. 5
      src/server/read.c
  4. 6
      src/server/run.c

3
src/server/close_conn.c

@ -10,7 +10,10 @@ serverCloseConn(Server this, unsigned int i)
delete(&((this->conns)[fd].sock)); delete(&((this->conns)[fd].sock));
delete(&((this->conns)[fd].reader)); delete(&((this->conns)[fd].reader));
memset((this->conns)[fd].wbuf, 0, strlen((this->conns)[fd].wbuf));
(this->fds)[i].events = 0; (this->fds)[i].events = 0;
(this->fds)[i].revents = 0;
(this->fds)[i].fd = 0;
this->ndel++; this->ndel++;
// CLEAR_CONN(this, i); // CLEAR_CONN(this, i);
// this->nfds--; // this->nfds--;

2
src/server/handle_accept.c

@ -21,7 +21,7 @@ serverHandleAccept(Server this)
delete(&acc); delete(&acc);
} }
(this->fds)[0].revents |= POLLIN;
// (this->fds)[0].revents |= POLLIN;
} }
// vim: set ts=4 sw=4: // vim: set ts=4 sw=4:

5
src/server/read.c

@ -3,6 +3,7 @@ int
serverRead(Server this, unsigned int i) serverRead(Server this, unsigned int i)
{ {
int fd = (this->fds)[i].fd; int fd = (this->fds)[i].fd;
int size;
if (NULL == (this->conns)[fd].reader) { if (NULL == (this->conns)[fd].reader) {
loggerLog( loggerLog(
@ -12,7 +13,7 @@ serverRead(Server this, unsigned int i)
serverCloseConn(this, i); serverCloseConn(this, i);
} }
switch (streamReaderRead((this->conns)[fd].reader, fd)) {
switch ((size = streamReaderRead((this->conns)[fd].reader, fd))) {
case 0: case 0:
/* /*
* normal close: write remaining data * normal close: write remaining data
@ -32,7 +33,7 @@ serverRead(Server this, unsigned int i)
break; break;
} }
return 0;
return size;
} }
// vim: set ts=4 sw=4: // vim: set ts=4 sw=4:

6
src/server/run.c

@ -65,15 +65,14 @@ serverRun(Server this)
* handle reads * handle reads
*/ */
else { else {
serverRead(this, i);
/** /**
* do some other processing * do some other processing
* @TODO: actually this will hard assume that our stream reader * @TODO: actually this will hard assume that our stream reader
* is a http parser and it has its queue...think about more * is a http parser and it has its queue...think about more
* generalizing here. * generalizing here.
*/ */
{
int size;
if (0 < (size=serverRead(this, i))) {
int j; int j;
HttpRequestQueue queue = HttpRequestQueue queue =
((HttpRequestParser)(this->conns)[fd].reader)->request_queue; ((HttpRequestParser)(this->conns)[fd].reader)->request_queue;
@ -143,7 +142,6 @@ serverRun(Server this)
"write error, closing connection"); "write error, closing connection");
} }
(this->fds)[i].events = (this->fds)[i].events & ~POLLOUT;
serverCloseConn(this, i); serverCloseConn(this, i);
} }
else { else {

Loading…
Cancel
Save