aboutsummaryrefslogtreecommitdiff
path: root/src/include/microhttpd.h
diff options
context:
space:
mode:
authorEvgeny Grin (Karlson2k) <k2k@narod.ru>2023-11-08 17:58:04 +0300
committerEvgeny Grin (Karlson2k) <k2k@narod.ru>2023-11-08 20:15:01 +0300
commit32eae456fddba5b48d08f44dda956a0ea1ffffea (patch)
tree94eee654f7ede3adcd44b64e87241d6653e013ae /src/include/microhttpd.h
parent09b7e335d8adc36926543305f3ee8d1b4961b0ab (diff)
downloadlibmicrohttpd-32eae456fddba5b48d08f44dda956a0ea1ffffea.tar.gz
libmicrohttpd-32eae456fddba5b48d08f44dda956a0ea1ffffea.zip
Added new function MHD_run_from_select2() with FD_SETSIZE value
Added wrapper macro MHD_run_from_select() to automatically use current FD_SETSIZE value. This should complete the support for flexible FD_SETSIZE (which is used on most platforms with GNU/Linux as notable exception). This also fixes potential fd_set overrun when sockets with too large numbers are used.
Diffstat (limited to 'src/include/microhttpd.h')
-rw-r--r--src/include/microhttpd.h72
1 files changed, 72 insertions, 0 deletions
diff --git a/src/include/microhttpd.h b/src/include/microhttpd.h
index 221d24fc..9e7e23e2 100644
--- a/src/include/microhttpd.h
+++ b/src/include/microhttpd.h
@@ -3387,6 +3387,78 @@ MHD_run_from_select (struct MHD_Daemon *daemon,
3387 const fd_set *except_fd_set); 3387 const fd_set *except_fd_set);
3388 3388
3389 3389
3390/**
3391 * Run webserver operations. This method should be called by clients
3392 * in combination with #MHD_get_fdset and #MHD_get_timeout() if the
3393 * client-controlled select method is used.
3394 * This function specifies FD_SETSIZE used when provided fd_sets were
3395 * created. It is important on platforms where FD_SETSIZE can be
3396 * overridden.
3397 *
3398 * You can use this function instead of #MHD_run if you called
3399 * 'select()' on the result from #MHD_get_fdset2(). File descriptors in
3400 * the sets that are not controlled by MHD will be ignored. Calling
3401 * this function instead of #MHD_run() is more efficient as MHD will
3402 * not have to call 'select()' again to determine which operations are
3403 * ready.
3404 *
3405 * If #MHD_get_timeout() returned #MHD_YES, than this function must be
3406 * called right after 'select()' returns regardless of detected activity
3407 * on the daemon's FDs.
3408 *
3409 * This function cannot be used with daemon started with
3410 * #MHD_USE_INTERNAL_POLLING_THREAD flag.
3411 *
3412 * @param daemon the daemon to run select loop for
3413 * @param read_fd_set the read set
3414 * @param write_fd_set the write set
3415 * @param except_fd_set the except set
3416 * @param fd_setsize the value of FD_SETSIZE
3417 * @return #MHD_NO on serious errors, #MHD_YES on success
3418 * @sa #MHD_get_fdset2(), #MHD_OPTION_APP_FD_SETSIZE
3419 * @ingroup event
3420 */
3421_MHD_EXTERN enum MHD_Result
3422MHD_run_from_select2 (struct MHD_Daemon *daemon,
3423 const fd_set *read_fd_set,
3424 const fd_set *write_fd_set,
3425 const fd_set *except_fd_set,
3426 unsigned int fd_setsize);
3427
3428
3429/**
3430 * Run webserver operations. This method should be called by clients
3431 * in combination with #MHD_get_fdset and #MHD_get_timeout() if the
3432 * client-controlled select method is used.
3433 * This macro automatically substitutes current FD_SETSIZE value.
3434 * It is important on platforms where FD_SETSIZE can be overridden.
3435 *
3436 * You can use this function instead of #MHD_run if you called
3437 * 'select()' on the result from #MHD_get_fdset2(). File descriptors in
3438 * the sets that are not controlled by MHD will be ignored. Calling
3439 * this function instead of #MHD_run() is more efficient as MHD will
3440 * not have to call 'select()' again to determine which operations are
3441 * ready.
3442 *
3443 * If #MHD_get_timeout() returned #MHD_YES, than this function must be
3444 * called right after 'select()' returns regardless of detected activity
3445 * on the daemon's FDs.
3446 *
3447 * This function cannot be used with daemon started with
3448 * #MHD_USE_INTERNAL_POLLING_THREAD flag.
3449 *
3450 * @param daemon the daemon to run select loop for
3451 * @param read_fd_set the read set
3452 * @param write_fd_set the write set
3453 * @param except_fd_set the except set
3454 * @param fd_setsize the value of FD_SETSIZE
3455 * @return #MHD_NO on serious errors, #MHD_YES on success
3456 * @sa #MHD_get_fdset2(), #MHD_OPTION_APP_FD_SETSIZE
3457 * @ingroup event
3458 */
3459#define MHD_run_from_select(d,r,w,e) \
3460 MHD_run_from_select2((d),(r),(w),(e),(unsigned int)(FD_SETSIZE))
3461
3390/* **************** Connection handling functions ***************** */ 3462/* **************** Connection handling functions ***************** */
3391 3463
3392/** 3464/**