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 | 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 | 9 | 2012-02-10 09:52:27 +0100 Georg Hopp |
6 | 10 | ... | ... |
... | ... | @@ -35,7 +35,6 @@ CLASS(Server) { |
35 | 35 | * von poll beruecksichtigen. |
36 | 36 | */ |
37 | 37 | nfds_t nfds; |
38 | - nfds_t ndel; | |
39 | 38 | struct pollfd fds[POLL_FD_NSIZE]; |
40 | 39 | |
41 | 40 | struct { |
... | ... | @@ -43,6 +42,7 @@ CLASS(Server) { |
43 | 42 | void * reader; |
44 | 43 | |
45 | 44 | char keep_alive; |
45 | + | |
46 | 46 | char wbuf[2048]; |
47 | 47 | char * rbuf; |
48 | 48 | unsigned int rpos; | ... | ... |
... | ... | @@ -36,12 +36,14 @@ dtor(void * _this) |
36 | 36 | Server this = _this; |
37 | 37 | int i; |
38 | 38 | |
39 | + printf("nfds: %d\n", this->nfds); | |
40 | + | |
39 | 41 | for (i=1; i<this->nfds; i++) { |
40 | 42 | /* |
41 | 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 | 49 | delete(&this->sock); | ... | ... |
... | ... | @@ -26,8 +26,8 @@ serverPoll(Server this) { |
26 | 26 | int events; |
27 | 27 | |
28 | 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 | 33 | * wait for handles to become ready |
... | ... | @@ -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 | 56 | return events; |
55 | 57 | } | ... | ... |
Please
register
or
login
to post a comment