libmicrohttpd

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

commit 59268ccff1583c06d215baef5423aac5c78c0c02
parent 1855c73cd340ae6273251728e8d6d500b2c1119b
Author: Christian Grothoff <christian@grothoff.org>
Date:   Tue, 14 Mar 2017 02:40:10 +0100

Still there is an issue with re-open a file. Patch applied below to
avoid it.

Also iterate_post() always returns MHD_OK, because the app's logic
driven
from the value of con_info->answercode().
And in case if fwrite() fails we also update the answer code & page  and
MHD_post_process() overwrite them (fileioerror becomes postprocerror).

Diffstat:
Mdoc/examples/largepost.c | 10++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/doc/examples/largepost.c b/doc/examples/largepost.c @@ -138,6 +138,8 @@ iterate_post (void *coninfo_cls, if (! con_info->fp) { + if (0 != con_info->answercode) /* something went wrong */ + return MHD_YES; if (NULL != (fp = fopen (filename, "rb"))) { fclose (fp); @@ -161,7 +163,7 @@ iterate_post (void *coninfo_cls, { con_info->answerstring = fileioerror; con_info->answercode = MHD_HTTP_INTERNAL_SERVER_ERROR; - return MHD_NO; + return MHD_YES; } } @@ -325,7 +327,11 @@ main () MHD_OPTION_NOTIFY_COMPLETED, &request_completed, NULL, MHD_OPTION_END); if (NULL == daemon) - return 1; + { + fprintf (stderr, + "Failed to start daemon\n"); + return 1; + } (void) getchar (); MHD_stop_daemon (daemon); return 0;