Showing
6 changed files
with
16 additions
and
11 deletions
1 | +2012-02-10 12:42:04 +0100 Georg Hopp | ||
2 | + | ||
3 | + * fixed bug at server destructor (HEAD, master) | ||
4 | + | ||
1 | 2012-02-10 09:59:41 +0100 Georg Hopp | 5 | 2012-02-10 09:59:41 +0100 Georg Hopp |
2 | 6 | ||
3 | - * reset keep_live flag on connection close (HEAD, master) | 7 | + * reset keep_live flag on connection close |
4 | 8 | ||
5 | 2012-02-10 09:52:27 +0100 Georg Hopp | 9 | 2012-02-10 09:52:27 +0100 Georg Hopp |
6 | 10 |
@@ -35,7 +35,6 @@ CLASS(Server) { | @@ -35,7 +35,6 @@ CLASS(Server) { | ||
35 | * von poll beruecksichtigen. | 35 | * von poll beruecksichtigen. |
36 | */ | 36 | */ |
37 | nfds_t nfds; | 37 | nfds_t nfds; |
38 | - nfds_t ndel; | ||
39 | struct pollfd fds[POLL_FD_NSIZE]; | 38 | struct pollfd fds[POLL_FD_NSIZE]; |
40 | 39 | ||
41 | struct { | 40 | struct { |
@@ -43,6 +42,7 @@ CLASS(Server) { | @@ -43,6 +42,7 @@ CLASS(Server) { | ||
43 | void * reader; | 42 | void * reader; |
44 | 43 | ||
45 | char keep_alive; | 44 | char keep_alive; |
45 | + | ||
46 | char wbuf[2048]; | 46 | char wbuf[2048]; |
47 | char * rbuf; | 47 | char * rbuf; |
48 | unsigned int rpos; | 48 | unsigned int rpos; |
@@ -36,12 +36,14 @@ dtor(void * _this) | @@ -36,12 +36,14 @@ dtor(void * _this) | ||
36 | Server this = _this; | 36 | Server this = _this; |
37 | int i; | 37 | int i; |
38 | 38 | ||
39 | + printf("nfds: %d\n", this->nfds); | ||
40 | + | ||
39 | for (i=1; i<this->nfds; i++) { | 41 | for (i=1; i<this->nfds; i++) { |
40 | /* | 42 | /* |
41 | * @TODO do some finalization...buffer handling...etc. | 43 | * @TODO do some finalization...buffer handling...etc. |
42 | */ | 44 | */ |
43 | - delete(&(this->conns[i]).sock); | ||
44 | - delete(&(this->conns[i]).reader); | 45 | + delete(&(this->conns[(this->fds)[i].fd]).sock); |
46 | + delete(&(this->conns[(this->fds)[i].fd]).reader); | ||
45 | } | 47 | } |
46 | 48 | ||
47 | delete(&this->sock); | 49 | delete(&this->sock); |
@@ -17,10 +17,6 @@ serverCloseConn(Server this, unsigned int i) | @@ -17,10 +17,6 @@ serverCloseConn(Server this, unsigned int i) | ||
17 | (this->fds)[i].events = 0; | 17 | (this->fds)[i].events = 0; |
18 | (this->fds)[i].revents = 0; | 18 | (this->fds)[i].revents = 0; |
19 | (this->fds)[i].fd = 0; | 19 | (this->fds)[i].fd = 0; |
20 | - | ||
21 | - this->ndel++; | ||
22 | -// CLEAR_CONN(this, i); | ||
23 | -// this->nfds--; | ||
24 | } | 20 | } |
25 | 21 | ||
26 | // vim: set ts=4 sw=4: | 22 | // vim: set ts=4 sw=4: |
@@ -26,8 +26,8 @@ serverPoll(Server this) { | @@ -26,8 +26,8 @@ serverPoll(Server this) { | ||
26 | int events; | 26 | int events; |
27 | 27 | ||
28 | qsort(this->fds, this->nfds, sizeof(struct pollfd), sortEvents); | 28 | qsort(this->fds, this->nfds, sizeof(struct pollfd), sortEvents); |
29 | - this->nfds -= this->ndel; | ||
30 | - this->ndel = 0; | 29 | + while((this->fds)[this->nfds].fd == 0 && this->nfds > 0) this->nfds--; |
30 | + this->nfds++; | ||
31 | 31 | ||
32 | /* | 32 | /* |
33 | * wait for handles to become ready | 33 | * wait for handles to become ready |
@@ -49,7 +49,9 @@ serverPoll(Server this) { | @@ -49,7 +49,9 @@ serverPoll(Server this) { | ||
49 | } | 49 | } |
50 | } | 50 | } |
51 | 51 | ||
52 | - qsort(this->fds, this->nfds, sizeof(struct pollfd), sortRevents); | 52 | + if (-1 != events) { |
53 | + qsort(this->fds, this->nfds, sizeof(struct pollfd), sortRevents); | ||
54 | + } | ||
53 | 55 | ||
54 | return events; | 56 | return events; |
55 | } | 57 | } |
@@ -74,6 +74,7 @@ serverRun(Server this) | @@ -74,6 +74,7 @@ serverRun(Server this) | ||
74 | * generalizing here. | 74 | * generalizing here. |
75 | */ | 75 | */ |
76 | int size; | 76 | int size; |
77 | + | ||
77 | if (0 < (size=serverRead(this, i))) { | 78 | if (0 < (size=serverRead(this, i))) { |
78 | int j; | 79 | int j; |
79 | HttpRequestQueue queue = | 80 | HttpRequestQueue queue = |
Please
register
or
login
to post a comment