tinywebd
diff src/tinyweb.c @ 8:121b991ccc1d
fixed the SIGPIPE bug
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Fri, 17 Apr 2015 12:02:59 +0300 |
parents | 5ec50ca0d071 |
children |
line diff
1.1 --- a/src/tinyweb.c Fri Apr 17 11:45:08 2015 +0300 1.2 +++ b/src/tinyweb.c Fri Apr 17 12:02:59 2015 +0300 1.3 @@ -124,11 +124,6 @@ 1.4 { 1.5 struct client *c, dummy; 1.6 1.7 - if(!socks) { 1.8 - /* just return the count */ 1.9 - return num_clients + 1; /* +1 for the listening socket */ 1.10 - } 1.11 - 1.12 /* first cleanup the clients marked for removal */ 1.13 dummy.next = clist; 1.14 c = &dummy; 1.15 @@ -147,6 +142,12 @@ 1.16 } 1.17 clist = dummy.next; 1.18 1.19 + 1.20 + if(!socks) { 1.21 + /* just return the count */ 1.22 + return num_clients + 1; /* +1 for the listening socket */ 1.23 + } 1.24 + 1.25 /* go through the client list and populate the array */ 1.26 maxfd = lis; 1.27 *socks++ = lis; 1.28 @@ -210,6 +211,7 @@ 1.29 c->bufsz = 0; 1.30 c->next = clist; 1.31 clist = c; 1.32 + ++num_clients; 1.33 return 0; 1.34 } 1.35 1.36 @@ -364,6 +366,7 @@ 1.37 int sz = cont_left < 4096 ? cont_left : 4096; 1.38 send(c->s, ptr, sz, 0); 1.39 ptr += sz; 1.40 + cont_left -= sz; 1.41 } 1.42 1.43 munmap(cont, st.st_size);