aboutsummaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2017-03-14 02:40:10 +0100
committerChristian Grothoff <christian@grothoff.org>2017-03-14 02:41:50 +0100
commit59268ccff1583c06d215baef5423aac5c78c0c02 (patch)
treec1724cb22919a12e840f63846fdbadb5f2960459 /doc
parent1855c73cd340ae6273251728e8d6d500b2c1119b (diff)
downloadlibmicrohttpd-59268ccff1583c06d215baef5423aac5c78c0c02.tar.gz
libmicrohttpd-59268ccff1583c06d215baef5423aac5c78c0c02.zip
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 (limited to 'doc')
-rw-r--r--doc/examples/largepost.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/doc/examples/largepost.c b/doc/examples/largepost.c
index 6846a536..1edf4d50 100644
--- a/doc/examples/largepost.c
+++ b/doc/examples/largepost.c
@@ -138,6 +138,8 @@ iterate_post (void *coninfo_cls,
138 138
139 if (! con_info->fp) 139 if (! con_info->fp)
140 { 140 {
141 if (0 != con_info->answercode) /* something went wrong */
142 return MHD_YES;
141 if (NULL != (fp = fopen (filename, "rb"))) 143 if (NULL != (fp = fopen (filename, "rb")))
142 { 144 {
143 fclose (fp); 145 fclose (fp);
@@ -161,7 +163,7 @@ iterate_post (void *coninfo_cls,
161 { 163 {
162 con_info->answerstring = fileioerror; 164 con_info->answerstring = fileioerror;
163 con_info->answercode = MHD_HTTP_INTERNAL_SERVER_ERROR; 165 con_info->answercode = MHD_HTTP_INTERNAL_SERVER_ERROR;
164 return MHD_NO; 166 return MHD_YES;
165 } 167 }
166 } 168 }
167 169
@@ -325,7 +327,11 @@ main ()
325 MHD_OPTION_NOTIFY_COMPLETED, &request_completed, NULL, 327 MHD_OPTION_NOTIFY_COMPLETED, &request_completed, NULL,
326 MHD_OPTION_END); 328 MHD_OPTION_END);
327 if (NULL == daemon) 329 if (NULL == daemon)
328 return 1; 330 {
331 fprintf (stderr,
332 "Failed to start daemon\n");
333 return 1;
334 }
329 (void) getchar (); 335 (void) getchar ();
330 MHD_stop_daemon (daemon); 336 MHD_stop_daemon (daemon);
331 return 0; 337 return 0;