Graceful shutdown of netconn-httpd on error

This commit is contained in:
goldsimon 2010-01-29 23:11:06 +00:00
parent aa0ae95b4e
commit 003f79774e
1 changed files with 11 additions and 4 deletions

View File

@ -7,6 +7,10 @@
#if LWIP_NETCONN
#ifndef HTTPD_DEBUG
#define HTTPD_DEBUG LWIP_DBG_OFF
#endif
const static char http_html_hdr[] = "HTTP/1.1 200 OK\r\nContent-type: text/html\r\n\r\n";
const static char http_index_html[] = "<html><head><title>Congrats!</title></head><body><h1>Welcome to our lwIP HTTP server!</h1><p>This is a small test page, served by httpserver-netconn.</body></html>";
@ -71,15 +75,18 @@ http_server_netconn_thread(void *arg)
/* Put the connection into LISTEN state */
netconn_listen(conn);
while(1) {
do {
err = netconn_accept(conn, &newconn);
LWIP_ASSERT("err == ERR_OK", err == ERR_OK);
if (err == ERR_OK) {
http_server_netconn_serve(newconn);
netconn_delete(newconn);
}
}
return;
} while(err == ERR_OK);
LWIP_DEBUGF(HTTPD_DEBUG,
("http_server_netconn_thread: netconn_accept received error %d, shutting down",
err));
netconn_close(conn);
netconn_delete(conn);
}
/** Initialize the HTTP server (start its thread) */