Small cleanups backported from Plan 9 from User Space. [rsc] --rw-rw-r-- M 399900 glenda sys 737 Sep 26 16:28 sys/src/libhttpd/gethead.c /n/sourcesdump/2005/0926/plan9/sys/src/libhttpd/gethead.c:19,25 - /n/sourcesdump/2005/0927/plan9/sys/src/libhttpd/gethead.c:19,25 s = (char*)hin->pos; pp = s; while(p = memchr(pp, '\n', (char*)hin->stop - pp)){ - if(!many || p == pp || p == pp + 1 && *pp == '\r'){ + if(!many || p == pp || (p == pp + 1 && *pp == '\r')){ pp = p + 1; break; } /n/sourcesdump/2005/0926/plan9/sys/src/libhttpd/gethead.c:28,40 - /n/sourcesdump/2005/0927/plan9/sys/src/libhttpd/gethead.c:28,40 hin->pos = (uchar*)pp; n = pp - s; if(c->hstop + n > &c->header[HBufSize]) - return 0; + return -1; memmove(c->hstop, s, n); c->hstop += n; *c->hstop = '\0'; if(p != nil) - return 1; - if(hreadbuf(hin, hin->pos) == nil || hin->state == Hend) return 0; + if(hreadbuf(hin, hin->pos) == nil || hin->state == Hend) + return -1; } } [rsc] --rw-rw-r-- M 399900 glenda sys 18965 Sep 26 16:28 sys/src/libhttpd/parse.c /n/sourcesdump/2005/0926/plan9/sys/src/libhttpd/parse.c:198,207 - /n/sourcesdump/2005/0927/plan9/sys/src/libhttpd/parse.c:198,209 memset(&h, 0, sizeof(h)); h.c = c; - alarm(timeout); - if(!hgethead(c, 1)) + if(timeout) + alarm(timeout); + if(hgethead(c, 1) < 0) return -1; - alarm(0); + if(timeout) + alarm(0); h.hstart = c->hpos; if(setjmp(h.jmp) == -1) [rsc] --rw-rw-r-- M 399900 glenda sys 5071 Sep 26 16:28 sys/src/libhttpd/parsereq.c /n/sourcesdump/2005/0926/plan9/sys/src/libhttpd/parsereq.c:15,21 - /n/sourcesdump/2005/0927/plan9/sys/src/libhttpd/parsereq.c:15,20 static int getc(HConnect*); static char* getword(HConnect*); static Strings parseuri(HConnect *c, char*); - static Strings stripmagic(char*); static Strings stripsearch(char*); /* /n/sourcesdump/2005/0926/plan9/sys/src/libhttpd/parsereq.c:41,50 - /n/sourcesdump/2005/0927/plan9/sys/src/libhttpd/parsereq.c:40,51 * later requests have to come quickly. * only works for http/1.1 or later. */ - alarm(timeout); - if(!hgethead(c, 0)) - return 0; - alarm(0); + if(timeout) + alarm(timeout); + if(hgethead(c, 0) < 0) + return -1; + if(timeout) + alarm(0); c->reqtime = time(nil); c->req.meth = getword(c); if(c->req.meth == nil){ /n/sourcesdump/2005/0926/plan9/sys/src/libhttpd/parsereq.c:284,290 - /n/sourcesdump/2005/0927/plan9/sys/src/libhttpd/parsereq.c:285,291 } ch = getc(c); } - return nil; + return nil; /* stupid 8c */ } static int [sys] --rwxrwxr-x M 399900 glenda sys 245198 Sep 26 23:08 386/bin/venti/venti [sys] --rwxrwxr-x M 399900 glenda sys 291589 Sep 26 23:08 386/bin/ip/httpd/httpd /sys/src/libhttpd/gethead.c:hgethead /sys/src/libhttpd/parse.c:hparseheaders /sys/src/libhttpd/parsereq.c:hparsereq [sys] --rwxrwxr-x M 399900 glenda sys 114798 Sep 26 23:08 386/bin/ip/httpd/imagemap [sys] --rwxrwxr-x M 399900 glenda sys 123085 Sep 26 23:08 386/bin/ip/httpd/man2html /sys/src/libhttpd/gethead.c:hgethead /sys/src/libhttpd/parse.c:hparseheaders [sys] --rwxrwxr-x M 399900 rsc sys 115643 Sep 26 23:08 386/bin/ip/httpd/netlib_find /sys/src/cmd/ip/httpd/log.c:writelog /sys/src/libhttpd/gethead.c:hgethead /sys/src/libhttpd/parse.c:getc /sys/src/libhttpd/parse.c:hparseheaders /sys/src/libhttpd/parse.c:hreqcleanup /sys/src/libhttpd/parse.c:mimeauthorization [sys] --rwxrwxr-x M 399900 rsc sys 114439 Sep 26 23:08 386/bin/ip/httpd/netlib_history [sys] --rwxrwxr-x M 399900 glenda sys 131094 Sep 26 23:08 386/bin/ip/httpd/save [sys] --rwxrwxr-x M 399900 presotto sys 131239 Sep 26 23:08 386/bin/ip/httpd/webls [sys] --rwxrwxr-x M 399900 glenda sys 112677 Sep 26 23:08 386/bin/ip/httpd/wikipost /sys/src/libhttpd/gethead.c:hgethead /sys/src/libhttpd/parse.c:hparseheaders [sys] --rw-rw-r-- M 399900 glenda sys 99596 Sep 26 23:08 386/lib/libhttpd.a