Increased number of simultanious connections from two to three, fixed / streamlined 404.html handling and added logging on tcp resets.

This commit is contained in:
oliverschmidt 2007-11-22 11:25:08 +00:00
parent 257c45776b
commit 54b8d7ec82

View file

@ -30,7 +30,7 @@
* *
* Author: Adam Dunkels <adam@sics.se> * Author: Adam Dunkels <adam@sics.se>
* *
* $Id: httpd-cfs.c,v 1.3 2007/11/18 02:54:45 oliverschmidt Exp $ * $Id: httpd-cfs.c,v 1.4 2007/11/22 11:25:08 oliverschmidt Exp $
*/ */
#include <string.h> #include <string.h>
@ -46,7 +46,7 @@
#define STATE_OUTPUT 1 #define STATE_OUTPUT 1
#define SEND_STRING(s, str) PSOCK_SEND(s, (uint8_t *)str, strlen(str)) #define SEND_STRING(s, str) PSOCK_SEND(s, (uint8_t *)str, strlen(str))
MEMB(conns, struct httpd_state, 2); MEMB(conns, struct httpd_state, 3);
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static static
@ -106,19 +106,17 @@ PT_THREAD(handle_output(struct httpd_state *s))
s->fd = cfs_open("404.html", CFS_READ); s->fd = cfs_open("404.html", CFS_READ);
if(s->fd < 0) { if(s->fd < 0) {
uip_abort(); uip_abort();
webserver_log_file(&uip_conn->ripaddr, "reset (no 404.html)");
PT_EXIT(&s->outputpt); PT_EXIT(&s->outputpt);
} }
PT_WAIT_THREAD(&s->outputpt, PT_WAIT_THREAD(&s->outputpt,
send_headers(s, "HTTP/1.0 404 Not found\r\n")); send_headers(s, "HTTP/1.0 404 Not found\r\n"));
PT_WAIT_THREAD(&s->outputpt,
send_file(s));
} else { } else {
PT_WAIT_THREAD(&s->outputpt, PT_WAIT_THREAD(&s->outputpt,
send_headers(s, "HTTP/1.0 200 OK\r\n")); send_headers(s, "HTTP/1.0 200 OK\r\n"));
PT_WAIT_THREAD(&s->outputpt,
send_file(s));
cfs_close(s->fd);
} }
PT_WAIT_THREAD(&s->outputpt, send_file(s));
cfs_close(s->fd);
PSOCK_CLOSE(&s->sout); PSOCK_CLOSE(&s->sout);
PT_END(&s->outputpt); PT_END(&s->outputpt);
} }
@ -154,7 +152,7 @@ PT_THREAD(handle_input(struct httpd_state *s))
if(strncmp(s->inputbuf, "Referer:", 8) == 0) { if(strncmp(s->inputbuf, "Referer:", 8) == 0) {
s->inputbuf[PSOCK_DATALEN(&s->sin) - 2] = 0; s->inputbuf[PSOCK_DATALEN(&s->sin) - 2] = 0;
webserver_log(&s->inputbuf[9]); webserver_log(s->inputbuf);
} }
} }
@ -183,6 +181,7 @@ httpd_appcall(void *state)
s = (struct httpd_state *)memb_alloc(&conns); s = (struct httpd_state *)memb_alloc(&conns);
if(s == NULL) { if(s == NULL) {
uip_abort(); uip_abort();
webserver_log_file(&uip_conn->ripaddr, "reset (no memory block)");
return; return;
} }
tcp_markconn(uip_conn, s); tcp_markconn(uip_conn, s);
@ -196,6 +195,7 @@ httpd_appcall(void *state)
if(uip_poll()) { if(uip_poll()) {
if(timer_expired(&s->timer)) { if(timer_expired(&s->timer)) {
uip_abort(); uip_abort();
webserver_log_file(&uip_conn->ripaddr, "reset (timeout)");
} }
} else { } else {
timer_reset(&s->timer); timer_reset(&s->timer);