diff options
author | Christian Grothoff <christian@grothoff.org> | 2017-09-23 21:48:30 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2017-09-23 21:48:30 +0200 |
commit | 421e485f4a781f0ad851a8d5bef8733ddd33f517 (patch) | |
tree | 1a76b2eedc59281e20d0384751d41d4205a1f8d1 | |
parent | 5efa7a5246c263a0f59be7f2a4ed1b1614b2b193 (diff) | |
download | libmicrohttpd-421e485f4a781f0ad851a8d5bef8733ddd33f517.tar.gz libmicrohttpd-421e485f4a781f0ad851a8d5bef8733ddd33f517.zip |
more changes based on ongoing discussions
-rw-r--r-- | src/include/microhttpd2.h | 105 |
1 files changed, 79 insertions, 26 deletions
diff --git a/src/include/microhttpd2.h b/src/include/microhttpd2.h index 63d3d47e..887d17d0 100644 --- a/src/include/microhttpd2.h +++ b/src/include/microhttpd2.h | |||
@@ -80,7 +80,9 @@ enum MHD_Bool | |||
80 | MHD_NO = 0, | 80 | MHD_NO = 0, |
81 | 81 | ||
82 | /** | 82 | /** |
83 | * MHD-internal return code for "YES". | 83 | * MHD-internal return code for "YES". All non-zero values |
84 | * will be interpreted as "YES", but MHD will only ever | ||
85 | * return #MHD_YES or #MHD_NO. | ||
84 | */ | 86 | */ |
85 | MHD_YES = 1 | 87 | MHD_YES = 1 |
86 | }; | 88 | }; |
@@ -289,19 +291,24 @@ MHD_daemon_suppress_date_no_clock (struct MHD_Daemon *daemon); | |||
289 | 291 | ||
290 | 292 | ||
291 | /** | 293 | /** |
292 | * Use inter-thread communication channel. #MHD_daemon_enable_itc() | 294 | * Disable use of inter-thread communication channel. |
293 | * can be used with #MHD_daemon_thread_internal() and is ignored with | 295 | * #MHD_daemon_disable_itc() can be used with |
294 | * any "external" mode. It's required for use of | 296 | * #MHD_daemon_thread_internal() to perform some additional |
295 | * #MHD_daemon_quiesce() or #MHD_connection_add(). This option is | 297 | * optimizations (in particular, not creating a pipe for IPC |
296 | * enforced by #MHD_daemon_allow_suspend_resume() and if there is no | 298 | * signalling). If it is used, certain functions like |
297 | * listen socket. #MHD_daemon_enable_itc() is always used | 299 | * #MHD_daemon_quiesce() or #MHD_connection_add() or |
298 | * automatically on platforms where select()/poll()/other ignore | 300 | * #MHD_action_suspend() cannot be used anymore. |
299 | * shutdown() of a listen socket. | 301 | * #MHD_daemon_disable_itc() is not beneficial on platforms where |
302 | * select()/poll()/other signal shutdown() of a listen socket. | ||
300 | * | 303 | * |
301 | * @param daemon which instance to enable itc for | 304 | * You should only use this function if you are sure you do |
305 | * satisfy all of its requirements and need a generally minor | ||
306 | * boost in performance. | ||
307 | * | ||
308 | * @param daemon which instance to disable itc for | ||
302 | */ | 309 | */ |
303 | _MHD_EXTERN void | 310 | _MHD_EXTERN void |
304 | MHD_daemon_enable_itc (struct MHD_Daemon *daemon); | 311 | MHD_daemon_disable_itc (struct MHD_Daemon *daemon); |
305 | 312 | ||
306 | 313 | ||
307 | /** | 314 | /** |
@@ -317,24 +324,31 @@ MHD_daemon_enable_turbo (struct MHD_Daemon *daemon); | |||
317 | 324 | ||
318 | 325 | ||
319 | /** | 326 | /** |
320 | * Enable suspend/resume functions, which also implies setting up | 327 | * Disable #MHD_action_suspend() functionality. |
321 | * #MHD_daemon_enable_itc() to signal resume. | ||
322 | * | 328 | * |
323 | * @param daemon which instance to enable suspend/resume for | 329 | * You should only use this function if you are sure you do |
330 | * satisfy all of its requirements and need a generally minor | ||
331 | * boost in performance. | ||
332 | * | ||
333 | * @param daemon which instance to disable suspend for | ||
324 | */ | 334 | */ |
325 | _MHD_EXTERN void | 335 | _MHD_EXTERN void |
326 | MHD_daemon_allow_suspend_resume (struct MHD_Daemon *daemon); | 336 | MHD_daemon_disallow_suspend_resume (struct MHD_Daemon *daemon); |
327 | 337 | ||
328 | 338 | ||
329 | /** | 339 | /** |
330 | * You need to set this option if you want to use HTTP "Upgrade". | 340 | * You need to set this option if you want to disable use of HTTP "Upgrade". |
331 | * "Upgrade" may require usage of additional internal resources, | 341 | * "Upgrade" may require usage of additional internal resources, |
332 | * which we do not want to use unless necessary. | 342 | * which we can avoid providing if they will not be used. |
343 | * | ||
344 | * You should only use this function if you are sure you do | ||
345 | * satisfy all of its requirements and need a generally minor | ||
346 | * boost in performance. | ||
333 | * | 347 | * |
334 | * @param daemon which instance to enable suspend/resume for | 348 | * @param daemon which instance to enable suspend/resume for |
335 | */ | 349 | */ |
336 | _MHD_EXTERN void | 350 | _MHD_EXTERN void |
337 | MHD_daemon_allow_upgrade (struct MHD_Daemon *daemon); | 351 | MHD_daemon_disallow_upgrade (struct MHD_Daemon *daemon); |
338 | 352 | ||
339 | 353 | ||
340 | /** | 354 | /** |
@@ -384,7 +398,35 @@ MHD_daemon_tcp_fastopen (struct MHD_Daemon *daemon, | |||
384 | 398 | ||
385 | 399 | ||
386 | /** | 400 | /** |
387 | * Bind to the given TCP port and address family. | 401 | * Address family to be used by MHD. |
402 | */ | ||
403 | enum MHD_AddressFamily | ||
404 | { | ||
405 | /** | ||
406 | * Pick "best" available method automatically. | ||
407 | */ | ||
408 | MHD_AF_AUTO, | ||
409 | |||
410 | /** | ||
411 | * Use IPv4. | ||
412 | */ | ||
413 | MHD_AF_INET4, | ||
414 | |||
415 | /** | ||
416 | * Use IPv6. | ||
417 | */ | ||
418 | MHD_AF_INET6, | ||
419 | |||
420 | /** | ||
421 | * Use dual stack. | ||
422 | */ | ||
423 | MHD_AF_DUAL | ||
424 | }; | ||
425 | |||
426 | |||
427 | /** | ||
428 | * Bind to the given TCP port and address family. | ||
429 | * | ||
388 | * Ineffective in conjunction with #MHD_daemon_listen_socket(). | 430 | * Ineffective in conjunction with #MHD_daemon_listen_socket(). |
389 | * Ineffective in conjunction with #MHD_daemon_bind_sa(). | 431 | * Ineffective in conjunction with #MHD_daemon_bind_sa(). |
390 | * | 432 | * |
@@ -398,7 +440,7 @@ MHD_daemon_tcp_fastopen (struct MHD_Daemon *daemon, | |||
398 | */ | 440 | */ |
399 | _MHD_EXTERN void | 441 | _MHD_EXTERN void |
400 | MHD_daemon_bind_port (struct MHD_Daemon *daemon, | 442 | MHD_daemon_bind_port (struct MHD_Daemon *daemon, |
401 | int af, | 443 | enum MHD_AddressFamily af, |
402 | uint16_t port); | 444 | uint16_t port); |
403 | 445 | ||
404 | 446 | ||
@@ -409,10 +451,12 @@ MHD_daemon_bind_port (struct MHD_Daemon *daemon, | |||
409 | * @param daemon which instance to configure the binding address for | 451 | * @param daemon which instance to configure the binding address for |
410 | * @param sa address to bind to; can be IPv4 (AF_INET), IPv6 (AF_INET6) | 452 | * @param sa address to bind to; can be IPv4 (AF_INET), IPv6 (AF_INET6) |
411 | * or even a UNIX domain socket (AF_UNIX) | 453 | * or even a UNIX domain socket (AF_UNIX) |
454 | * @param sa_len number of bytes in @a sa | ||
412 | */ | 455 | */ |
413 | _MHD_EXTERN void | 456 | _MHD_EXTERN void |
414 | MHD_daemon_bind_socket_address (struct MHD_Daemon *daemon, | 457 | MHD_daemon_bind_socket_address (struct MHD_Daemon *daemon, |
415 | const struct sockaddr *sa); | 458 | const struct sockaddr *sa, |
459 | size_t sa_lem); | ||
416 | 460 | ||
417 | 461 | ||
418 | /** | 462 | /** |
@@ -493,8 +537,9 @@ enum MHD_EventLoopSyscall | |||
493 | * | 537 | * |
494 | * @param daemon daemon to set event loop style for | 538 | * @param daemon daemon to set event loop style for |
495 | * @param els event loop syscall to use | 539 | * @param els event loop syscall to use |
540 | * @return #MHD_NO on failure, #MHD_YES on success | ||
496 | */ | 541 | */ |
497 | _MHD_EXTERN void | 542 | _MHD_EXTERN enum MHD_Bool |
498 | MHD_daemon_event_loop (struct MHD_Daemon *daemon, | 543 | MHD_daemon_event_loop (struct MHD_Daemon *daemon, |
499 | enum MHD_EventLoopSyscall els); | 544 | enum MHD_EventLoopSyscall els); |
500 | 545 | ||
@@ -669,7 +714,7 @@ enum MHD_ThreadingModel | |||
669 | * requests among the workers. | 714 | * requests among the workers. |
670 | * | 715 | * |
671 | * A good way to express the use of a thread pool | 716 | * A good way to express the use of a thread pool |
672 | * in your code would be to write "4 * MHD_TM_WORKER_THREADS" | 717 | * in your code would be to write "MHD_TM_THREAD_POOL(4)" |
673 | * to indicate four threads. | 718 | * to indicate four threads. |
674 | * | 719 | * |
675 | * If a positive value is set, * #MHD_daemon_run() and | 720 | * If a positive value is set, * #MHD_daemon_run() and |
@@ -678,8 +723,16 @@ enum MHD_ThreadingModel | |||
678 | MHD_TM_WORKER_THREADS = 1 | 723 | MHD_TM_WORKER_THREADS = 1 |
679 | 724 | ||
680 | }; | 725 | }; |
681 | 726 | ||
682 | 727 | ||
728 | /** | ||
729 | * Use a thread pool of size @a n. | ||
730 | * | ||
731 | * @return an `enum MHD_ThreadingModel` for a thread pool of size @a n | ||
732 | */ | ||
733 | #define MHD_TM_THREAD_POOL(n) ((enum MHD_ThreadingModel)(n)) | ||
734 | |||
735 | |||
683 | /** | 736 | /** |
684 | * Specify threading model to use. | 737 | * Specify threading model to use. |
685 | * | 738 | * |
@@ -704,7 +757,7 @@ MHD_daemon_threading_model (struct MHD_Daemon *daemon, | |||
704 | typedef enum MHD_Bool | 757 | typedef enum MHD_Bool |
705 | (*MHD_AcceptPolicyCallback) (void *cls, | 758 | (*MHD_AcceptPolicyCallback) (void *cls, |
706 | const struct sockaddr *addr, | 759 | const struct sockaddr *addr, |
707 | socklen_t addrlen); | 760 | size_t addrlen); |
708 | 761 | ||
709 | 762 | ||
710 | /** | 763 | /** |