libmicrohttpd

HTTP/1.x server C library (MHD 1.x, stable)
Log | Files | Refs | Submodules | README | LICENSE

commit cff975d1ffb383575b38ad3eb8af90a102404a49
parent deb0b94b538a60f341d0f532c782549e7d4de808
Author: Christian Grothoff <christian@grothoff.org>
Date:   Sun, 24 Aug 2008 19:08:13 +0000

handle 0 as specified in documentation

Diffstat:
MChangeLog | 6++++++
Mdoc/microhttpd.texi | 9+++++----
Msrc/daemon/connection.c | 9+++++++++
Msrc/daemon/daemon.c | 3+++
Msrc/daemon/reason_phrase.c | 1-
5 files changed, 23 insertions(+), 5 deletions(-)

diff --git a/ChangeLog b/ChangeLog @@ -1,3 +1,9 @@ +Sun Aug 24 13:05:41 MDT 2008 + Now handling clients returning 0 from response callback + as specified in the documentation (abort if internal + select is used, retry immediately if a thread per + connection is used). -CG + Sun Aug 24 12:44:43 MDT 2008 Added missing reason phrase. -SG diff --git a/doc/microhttpd.texi b/doc/microhttpd.texi @@ -507,10 +507,11 @@ number of bytes that has been placed into @var{buf} should be returned. Note that returning zero will cause @mhd{} to try again, either ``immediately'' if in multi-threaded mode (in which case the callback -may want to do blocking operations) or in the next round if MHD_run is -used. Returning zero for a daemon that runs in internal -@cfunction{select} mode is an error (since it would result in busy -waiting) and will cause the program to be aborted (@cfunction{abort}). +may want to do blocking operations to avoid busy waiting) or in the +next round if @code{MHD_run} is used. Returning zero for a daemon +that runs in internal @cfunction{select} mode is an error (since it +would result in busy waiting) and cause the program to be aborted +(@cfunction{abort}). @table @var @item cls diff --git a/src/daemon/connection.c b/src/daemon/connection.c @@ -330,6 +330,9 @@ try_ready_normal_body (struct MHD_Connection *connection) MHD_MIN (response->data_buffer_size, response->total_size - connection->response_write_position)); + if ( (ret == 0) && + (0 != (connection->daemon->options & MHD_USE_SELECT_INTERNALLY)) ) + abort(); /* serious client API violation */ if (ret == -1) { /* either error or http 1.0 transfer, close @@ -1715,6 +1718,12 @@ MHD_connection_handle_write (struct MHD_Connection *connection) if (connection->socket_fd != -1) connection_close_error (connection); return MHD_NO; + case MHD_TLS_CONNECTION_INIT: + case MHD_TLS_HELLO_REQUEST: + case MHD_TLS_HANDSHAKE_FAILED: + case MHD_TLS_HANDSHAKE_COMPLETE: + EXTRA_CHECK(0); + break; } break; } diff --git a/src/daemon/daemon.c b/src/daemon/daemon.c @@ -251,6 +251,9 @@ MHD_handle_connection (void *data) tv.tv_sec = timeout - (now - con->last_activity); else tv.tv_sec = 0; + if ( (con->state == MHD_CONNECTION_NORMAL_BODY_UNREADY) || + (con->state == MHD_CONNECTION_CHUNKED_BODY_UNREADY) ) + timeout = 1; /* do not block */ num_ready = SELECT (max + 1, &rs, &ws, &es, (timeout != 0) ? &tv : NULL); if (num_ready < 0) diff --git a/src/daemon/reason_phrase.c b/src/daemon/reason_phrase.c @@ -2,7 +2,6 @@ This file is part of libmicrohttpd (C) 2007 Lymba - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either