GNU libmicrohttpd
0.9.72
|
Macros | |
#define | MHD_get_fdset(daemon, read_fd_set, write_fd_set, except_fd_set, max_fd) |
Functions | |
_MHD_EXTERN struct MHD_Daemon * | MHD_start_daemon_va (unsigned int flags, uint16_t port, MHD_AcceptPolicyCallback apc, void *apc_cls, MHD_AccessHandlerCallback dh, void *dh_cls, va_list ap) |
_MHD_EXTERN struct MHD_Daemon * | MHD_start_daemon (unsigned int flags, uint16_t port, MHD_AcceptPolicyCallback apc, void *apc_cls, MHD_AccessHandlerCallback dh, void *dh_cls,...) |
_MHD_EXTERN void | MHD_stop_daemon (struct MHD_Daemon *daemon) |
_MHD_EXTERN enum MHD_Result | MHD_get_fdset (struct MHD_Daemon *daemon, fd_set *read_fd_set, fd_set *write_fd_set, fd_set *except_fd_set, MHD_socket *max_fd) |
_MHD_EXTERN enum MHD_Result | MHD_get_fdset2 (struct MHD_Daemon *daemon, fd_set *read_fd_set, fd_set *write_fd_set, fd_set *except_fd_set, MHD_socket *max_fd, unsigned int fd_setsize) |
_MHD_EXTERN enum MHD_Result | MHD_get_timeout (struct MHD_Daemon *daemon, MHD_UNSIGNED_LONG_LONG *timeout) |
_MHD_EXTERN enum MHD_Result | MHD_run (struct MHD_Daemon *daemon) |
_MHD_EXTERN enum MHD_Result | MHD_run_from_select (struct MHD_Daemon *daemon, const fd_set *read_fd_set, const fd_set *write_fd_set, const fd_set *except_fd_set) |
void | MHD_daemon_destroy (struct MHD_Daemon *daemon) |
enum MHD_StatusCode | MHD_daemon_get_timeout (struct MHD_Daemon *daemon, MHD_UNSIGNED_LONG_LONG *timeout) |
enum MHD_StatusCode | MHD_daemon_run (struct MHD_Daemon *daemon) |
enum MHD_StatusCode | MHD_daemon_get_fdset (struct MHD_Daemon *daemon, fd_set *read_fd_set, fd_set *write_fd_set, fd_set *except_fd_set, MHD_socket *max_fd) |
static enum MHD_StatusCode | internal_get_fdset2 (struct MHD_Daemon *daemon, fd_set *read_fd_set, fd_set *write_fd_set, fd_set *except_fd_set, MHD_socket *max_fd, unsigned int fd_setsize) |
enum MHD_StatusCode | MHD_daemon_get_fdset2 (struct MHD_Daemon *daemon, fd_set *read_fd_set, fd_set *write_fd_set, fd_set *except_fd_set, MHD_socket *max_fd, unsigned int fd_setsize) |
static enum MHD_StatusCode | internal_run_from_select (struct MHD_Daemon *daemon, const fd_set *read_fd_set, const fd_set *write_fd_set, const fd_set *except_fd_set) |
enum MHD_StatusCode | MHD_daemon_run_from_select (struct MHD_Daemon *daemon, const fd_set *read_fd_set, const fd_set *write_fd_set, const fd_set *except_fd_set) |
enum MHD_StatusCode | MHD_daemon_start (struct MHD_Daemon *daemon) |
MHD API to start and stop the HTTP server and manage the event loop.
#define MHD_get_fdset | ( | daemon, | |
read_fd_set, | |||
write_fd_set, | |||
except_fd_set, | |||
max_fd | |||
) |
Obtain the select()
sets for this daemon. Daemon's FDs will be added to fd_sets. To get only daemon FDs in fd_sets, call FD_ZERO for each fd_set before calling this function. Size of fd_set is determined by current value of FD_SETSIZE. It's necessary to use MHD_get_timeout() in combination with this function.
This function could be called only for daemon started without MHD_USE_INTERNAL_POLLING_THREAD flag.
daemon | daemon to get sets from |
read_fd_set | read set |
write_fd_set | write set |
except_fd_set | except set |
max_fd | increased to largest FD added (if larger than existing value); can be NULL |
Definition at line 2616 of file microhttpd.h.
|
static |
Internal version of MHD_daemon_get_fdset2().
daemon | daemon to get sets from |
read_fd_set | read set |
write_fd_set | write set |
except_fd_set | except set |
max_fd | increased to largest FD added (if larger than existing value); can be NULL |
fd_setsize | value of FD_SETSIZE |
Definition at line 1 of file daemon_select.c.
References _MHD_SYS_DEFAULT_FD_SETSIZE, and MHD_daemon_get_fdset2().
|
static |
Internal version of MHD_run_from_select().
daemon | daemon to run select loop for |
read_fd_set | read set |
write_fd_set | write set |
except_fd_set | except set |
Definition at line 1 of file daemon_select.c.
void MHD_daemon_destroy | ( | struct MHD_Daemon * | daemon | ) |
Shutdown and destroy an HTTP daemon.
daemon | daemon to stop |
Definition at line 95 of file daemon_destroy.c.
References _, MHD_Daemon::cleanup_connection_mutex, MHD_Daemon::event_loop_syscall, fd, MHD_Daemon::itc, MHD_Daemon::listen_socket, MHD_Daemon::master, mhd_assert, MHD_daemon_close_all_connections_(), MHD_INVALID_SOCKET, MHD_itc_destroy_chk_, MHD_mutex_destroy_chk_, MHD_PANIC, MHD_socket_close_chk_, NULL, MHD_Daemon::per_ip_connection_mutex, MHD_Daemon::pid, MHD_Daemon::shutdown, stop_workers(), MHD_Daemon::threading_mode, MHD_Daemon::was_quiesced, MHD_Daemon::worker_pool, and MHD_Daemon::worker_pool_size.
Referenced by stop_workers().
enum MHD_StatusCode MHD_daemon_get_fdset | ( | struct MHD_Daemon * | daemon, |
fd_set * | read_fd_set, | ||
fd_set * | write_fd_set, | ||
fd_set * | except_fd_set, | ||
MHD_socket * | max_fd | ||
) |
We defined a macro with the same name as a function we are implementing here. Need to undef the macro to avoid causing a conflict. Obtain the select()
sets for this daemon. Daemon's FDs will be added to fd_sets. To get only daemon FDs in fd_sets, call FD_ZERO for each fd_set before calling this function. FD_SETSIZE is assumed to be platform's default.
This function should only be called in when MHD is configured to use external select with 'select()' or with 'epoll'. In the latter case, it will only add the single 'epoll()' file descriptor used by MHD to the sets. It's necessary to use MHD_daemon_get_timeout() in combination with this function.
This function must be called only for daemon started without MHD_USE_INTERNAL_POLLING_THREAD flag.
daemon | daemon to get sets from |
read_fd_set | read set |
write_fd_set | write set |
except_fd_set | except set |
max_fd | increased to largest FD added (if larger than existing value); can be NULL |
Definition at line 1 of file daemon_select.c.
enum MHD_StatusCode MHD_daemon_get_fdset2 | ( | struct MHD_Daemon * | daemon, |
fd_set * | read_fd_set, | ||
fd_set * | write_fd_set, | ||
fd_set * | except_fd_set, | ||
MHD_socket * | max_fd, | ||
unsigned int | fd_setsize | ||
) |
Obtain the select()
sets for this daemon. Daemon's FDs will be added to fd_sets. To get only daemon FDs in fd_sets, call FD_ZERO for each fd_set before calling this function.
Passing custom FD_SETSIZE as fd_setsize allow usage of larger/smaller than platform's default fd_sets.
This function should only be called in when MHD is configured to use external select with 'select()' or with 'epoll'. In the latter case, it will only add the single 'epoll' file descriptor used by MHD to the sets. It's necessary to use MHD_get_timeout() in combination with this function.
This function must be called only for daemon started without MHD_USE_INTERNAL_POLLING_THREAD flag.
daemon | daemon to get sets from |
read_fd_set | read set |
write_fd_set | write set |
except_fd_set | except set |
max_fd | increased to largest FD added (if larger than existing value); can be NULL |
fd_setsize | value of FD_SETSIZE |
Definition at line 1 of file daemon_select.c.
Referenced by internal_get_fdset2().
enum MHD_StatusCode MHD_daemon_get_timeout | ( | struct MHD_Daemon * | daemon, |
MHD_UNSIGNED_LONG_LONG * | timeout | ||
) |
Obtain timeout value for polling function for this daemon. This function set value to amount of milliseconds for which polling function (select()
or poll()
) should at most block, not the timeout value set for connections. It is important to always use this function, even if connection timeout is not set, as in some cases MHD may already have more data to process on next turn (data pending in TLS buffers, connections are already ready with epoll etc.) and returned timeout will be zero.
daemon | daemon to query for timeout |
timeout | set to the timeout (in milliseconds) |
Definition at line 1 of file daemon_get_timeout.c.
References _, MHD_Connection::connection_timeout, MHD_Connection::daemon, MHD_Daemon::data_already_pending, MHD_Daemon::event_loop_syscall, MHD_Connection::last_activity, MHD_Daemon::manual_timeout_tail, MHD_monotonic_sec_counter(), MHD_Daemon::normal_timeout_tail, NULL, MHD_Connection::prevX, MHD_Daemon::threading_mode, and ULLONG_MAX.
enum MHD_StatusCode MHD_daemon_run | ( | struct MHD_Daemon * | daemon | ) |
Run webserver operations (without blocking unless in client callbacks). This method should be called by clients in combination with MHD_get_fdset if the client-controlled select method is used and MHD_get_timeout().
This function is a convenience method, which is useful if the fd_sets from MHD_get_fdset were not directly passed to select()
; with this function, MHD will internally do the appropriate select()
call itself again. While it is always safe to call MHD_run (if MHD_USE_INTERNAL_POLLING_THREAD is not set), you should call MHD_run_from_select if performance is important (as it saves an expensive call to select()
).
daemon | daemon to run |
Definition at line 1 of file daemon_run.c.
References MHD_Daemon::event_loop_syscall, MHD_connection_cleanup_(), MHD_daemon_poll_(), MHD_daemon_select_(), MHD_NO, MHD_Daemon::shutdown, and MHD_Daemon::threading_mode.
enum MHD_StatusCode MHD_daemon_run_from_select | ( | struct MHD_Daemon * | daemon, |
const fd_set * | read_fd_set, | ||
const fd_set * | write_fd_set, | ||
const fd_set * | except_fd_set | ||
) |
Run webserver operations. This method should be called by clients in combination with MHD_get_fdset and MHD_get_timeout() if the client-controlled select method is used.
You can use this function instead of MHD_run if you called select()
on the result from MHD_get_fdset. File descriptors in the sets that are not controlled by MHD will be ignored. Calling this function instead of MHD_run is more efficient as MHD will not have to call select()
again to determine which operations are ready.
This function cannot be used with daemon started with MHD_USE_INTERNAL_POLLING_THREAD flag.
daemon | daemon to run select loop for |
read_fd_set | read set |
write_fd_set | write set |
except_fd_set | except set |
Definition at line 1 of file daemon_select.c.
enum MHD_StatusCode MHD_daemon_start | ( | struct MHD_Daemon * | daemon | ) |
Start a webserver.
daemon | daemon to start; you can no longer set options on this daemon after this call! |
Definition at line 619 of file daemon_start.c.
References MHD_Daemon::disallow_suspend_resume, MHD_Daemon::event_loop_syscall, MHD_connection_cleanup_(), MHD_daemon_close_all_connections_(), MHD_daemon_poll_(), MHD_daemon_select_(), MHD_PANIC, MHD_resume_suspended_connections_(), MHD_YES, MHD_Daemon::pid, and MHD_Daemon::shutdown.
enum MHD_Result MHD_get_fdset | ( | struct MHD_Daemon * | daemon, |
fd_set * | read_fd_set, | ||
fd_set * | write_fd_set, | ||
fd_set * | except_fd_set, | ||
MHD_socket * | max_fd | ||
) |
Obtain the select()
sets for this daemon. Daemon's FDs will be added to fd_sets. To get only daemon FDs in fd_sets, call FD_ZERO for each fd_set before calling this function. FD_SETSIZE is assumed to be platform's default.
This function should only be called in when MHD is configured to use external select with 'select()' or with 'epoll'. In the latter case, it will only add the single 'epoll()' file descriptor used by MHD to the sets. It's necessary to use MHD_get_timeout() in combination with this function.
This function must be called only for daemon started without MHD_USE_INTERNAL_POLLING_THREAD flag.
daemon | daemon to get sets from |
read_fd_set | read set |
write_fd_set | write set |
except_fd_set | except set |
max_fd | increased to largest FD added (if larger than existing value); can be NULL |
Obtain the select()
sets for this daemon. Daemon's FDs will be added to fd_sets. To get only daemon FDs in fd_sets, call FD_ZERO for each fd_set before calling this function. FD_SETSIZE is assumed to be platform's default.
This function should only be called in when MHD is configured to use external select with 'select()' or with 'epoll'. In the latter case, it will only add the single 'epoll' file descriptor used by MHD to the sets. It's necessary to use MHD_get_timeout() in combination with this function.
This function must be called only for daemon started without MHD_USE_INTERNAL_POLLING_THREAD flag.
daemon | daemon to get sets from |
read_fd_set | read set |
write_fd_set | write set |
except_fd_set | except set |
max_fd | increased to largest FD added (if larger than existing value); can be NULL |
enum MHD_Result MHD_get_fdset2 | ( | struct MHD_Daemon * | daemon, |
fd_set * | read_fd_set, | ||
fd_set * | write_fd_set, | ||
fd_set * | except_fd_set, | ||
MHD_socket * | max_fd, | ||
unsigned int | fd_setsize | ||
) |
Obtain the select()
sets for this daemon. Daemon's FDs will be added to fd_sets. To get only daemon FDs in fd_sets, call FD_ZERO for each fd_set before calling this function.
Passing custom FD_SETSIZE as fd_setsize allow usage of larger/smaller than platform's default fd_sets.
This function should only be called in when MHD is configured to use external select with 'select()' or with 'epoll'. In the latter case, it will only add the single 'epoll' file descriptor used by MHD to the sets. It's necessary to use MHD_get_timeout() in combination with this function.
This function must be called only for daemon started without MHD_USE_INTERNAL_POLLING_THREAD flag.
daemon | daemon to get sets from |
read_fd_set | read set |
write_fd_set | write set |
except_fd_set | except set |
max_fd | increased to largest FD added (if larger than existing value); can be NULL |
fd_setsize | value of FD_SETSIZE |
enum MHD_Result MHD_get_timeout | ( | struct MHD_Daemon * | daemon, |
MHD_UNSIGNED_LONG_LONG * | timeout | ||
) |
Obtain timeout value for polling function for this daemon. This function set value to amount of milliseconds for which polling function (select()
or poll()
) should at most block, not the timeout value set for connections. It is important to always use this function, even if connection timeout is not set, as in some cases MHD may already have more data to process on next turn (data pending in TLS buffers, connections are already ready with epoll etc.) and returned timeout will be zero.
daemon | daemon to query for timeout |
timeout | set to the timeout (in milliseconds) |
Obtain timeout value for polling function for this daemon. This function set value to amount of milliseconds for which polling function (select()
or poll()
) should at most block, not the timeout value set for connections. It is important to always use this function, even if connection timeout is not set as in some cases MHD may already have more data to process on next turn (data pending in TLS buffers, connections are already ready with epoll etc.) and returned timeout will be zero.
daemon | daemon to query for timeout |
timeout | set to the timeout (in milliseconds) |
enum MHD_Result MHD_run | ( | struct MHD_Daemon * | daemon | ) |
Run webserver operations (without blocking unless in client callbacks). This method should be called by clients in combination with MHD_get_fdset if the client-controlled select method is used and MHD_get_timeout().
This function is a convenience method, which is useful if the fd_sets from MHD_get_fdset were not directly passed to select()
; with this function, MHD will internally do the appropriate select()
call itself again. While it is always safe to call MHD_run (if MHD_USE_INTERNAL_POLLING_THREAD is not set), you should call MHD_run_from_select if performance is important (as it saves an expensive call to select()
).
daemon | daemon to run |
Run webserver operations (without blocking unless in client callbacks). This method should be called by clients in combination with MHD_get_fdset if the client-controlled select method is used and MHD_get_timeout().
This function is a convenience method, which is useful if the fd_sets from MHD_get_fdset were not directly passed to select()
; with this function, MHD will internally do the appropriate select()
call itself again. While it is always safe to call MHD_run (in external select mode), you should call MHD_run_from_select if performance is important (as it saves an expensive call to select()
).
daemon | daemon to run |
enum MHD_Result MHD_run_from_select | ( | struct MHD_Daemon * | daemon, |
const fd_set * | read_fd_set, | ||
const fd_set * | write_fd_set, | ||
const fd_set * | except_fd_set | ||
) |
Run webserver operations. This method should be called by clients in combination with MHD_get_fdset and MHD_get_timeout() if the client-controlled select method is used.
You can use this function instead of MHD_run if you called select()
on the result from MHD_get_fdset. File descriptors in the sets that are not controlled by MHD will be ignored. Calling this function instead of MHD_run is more efficient as MHD will not have to call select()
again to determine which operations are ready.
This function cannot be used with daemon started with MHD_USE_INTERNAL_POLLING_THREAD flag.
daemon | daemon to run select loop for |
read_fd_set | read set |
write_fd_set | write set |
except_fd_set | except set |
Run webserver operations. This method should be called by clients in combination with MHD_get_fdset and MHD_get_timeout() if the client-controlled select method is used.
You can use this function instead of MHD_run if you called select()
on the result from MHD_get_fdset. File descriptors in the sets that are not controlled by MHD will be ignored. Calling this function instead of MHD_run is more efficient as MHD will not have to call select()
again to determine which operations are ready.
This function cannot be used with daemon started with MHD_USE_INTERNAL_POLLING_THREAD flag.
daemon | daemon to run select loop for |
read_fd_set | read set |
write_fd_set | write set |
except_fd_set | except set |
struct MHD_Daemon * MHD_start_daemon | ( | unsigned int | flags, |
uint16_t | port, | ||
MHD_AcceptPolicyCallback | apc, | ||
void * | apc_cls, | ||
MHD_AccessHandlerCallback | dh, | ||
void * | dh_cls, | ||
... | |||
) |
Start a webserver on the given port. Variadic version of MHD_start_daemon_va.
flags | combination of enum MHD_FLAG values |
port | port to bind to (in host byte order), use '0' to bind to random free port, ignored if MHD_OPTION_SOCK_ADDR or MHD_OPTION_LISTEN_SOCKET is provided or MHD_USE_NO_LISTEN_SOCKET is specified |
apc | callback to call to check which clients will be allowed to connect; you can pass NULL in which case connections from any IP will be accepted |
apc_cls | extra argument to apc |
dh | handler called for all requests (repeatedly) |
dh_cls | extra argument to dh |
Start a webserver on the given port. Variadic version of MHD_start_daemon_va.
flags | combination of enum MHD_FLAG values |
port | port to bind to (in host byte order), use '0' to bind to random free port, ignored if MHD_OPTION_SOCK_ADDR or MHD_OPTION_LISTEN_SOCKET is provided or MHD_USE_NO_LISTEN_SOCKET is specified |
apc | callback to call to check which clients will be allowed to connect; you can pass NULL in which case connections from any IP will be accepted |
apc_cls | extra argument to apc |
dh | handler called for all requests (repeatedly) |
dh_cls | extra argument to dh |
Definition at line 5205 of file daemon.c.
References MHD_Daemon::apc, MHD_Daemon::apc_cls, MHD_start_daemon_va(), and MHD_Daemon::port.
struct MHD_Daemon * MHD_start_daemon_va | ( | unsigned int | flags, |
uint16_t | port, | ||
MHD_AcceptPolicyCallback | apc, | ||
void * | apc_cls, | ||
MHD_AccessHandlerCallback | dh, | ||
void * | dh_cls, | ||
va_list | ap | ||
) |
Start a webserver on the given port.
flags | combination of enum MHD_FLAG values |
port | port to bind to (in host byte order), use '0' to bind to random free port, ignored if MHD_OPTION_SOCK_ADDR or MHD_OPTION_LISTEN_SOCKET is provided or MHD_USE_NO_LISTEN_SOCKET is specified |
apc | callback to call to check which clients will be allowed to connect; you can pass NULL in which case connections from any IP will be accepted |
apc_cls | extra argument to apc |
dh | handler called for all requests (repeatedly) |
dh_cls | extra argument to dh |
ap | list of options (type-value pairs, terminated with MHD_OPTION_END). |
Start a webserver on the given port.
flags | combination of enum MHD_FLAG values |
port | port to bind to (in host byte order), use '0' to bind to random free port, ignored if MHD_OPTION_SOCK_ADDR or MHD_OPTION_LISTEN_SOCKET is provided or MHD_USE_NO_LISTEN_SOCKET is specified |
apc | callback to call to check which clients will be allowed to connect; you can pass NULL in which case connections from any IP will be accepted |
apc_cls | extra argument to apc |
dh | handler called for all requests (repeatedly) |
dh_cls | extra argument to dh |
ap | list of options (type-value pairs, terminated with MHD_OPTION_END). |
Definition at line 6078 of file daemon.c.
References _, MHD_Daemon::apc, MHD_Daemon::apc_cls, MHD_Daemon::cleanup_connection_mutex, MHD_Daemon::connection_limit, MHD_Daemon::connection_timeout, MHD_Daemon::connections, MHD_Daemon::default_handler, MHD_Daemon::default_handler_cls, MHD_Daemon::itc, MHD_Daemon::listen_backlog_size, MHD_Daemon::listen_fd, MHD_Daemon::listening_address_reuse, MHD_Daemon::master, MHD_ALLOW_SUSPEND_RESUME, MHD_ALLOW_UPGRADE, mhd_assert, MHD_BUF_INC_SIZE, MHD_calloc_(), MHD_check_global_init_(), MHD_create_named_thread_, MHD_INVALID_SOCKET, MHD_itc_destroy_chk_, MHD_MAX_CONNECTIONS_DEFAULT, MHD_mutex_destroy_chk_, MHD_mutex_init_, MHD_NO, MHD_PANIC, MHD_polling_thread(), MHD_POOL_SIZE_DEFAULT, MHD_SCKT_FD_FITS_FDSET_, MHD_socket_close_chk_, MHD_socket_create_listen_(), MHD_socket_last_strerr_, MHD_socket_nonblocking_(), MHD_stop_daemon(), MHD_strerror_, MHD_USE_AUTO, MHD_USE_DUAL_STACK, MHD_USE_EPOLL, MHD_USE_INTERNAL_POLLING_THREAD, MHD_USE_IPv6, MHD_USE_ITC, MHD_USE_NO_LISTEN_SOCKET, MHD_USE_PEDANTIC_CHECKS, MHD_USE_POLL, MHD_USE_TCP_FASTOPEN, MHD_USE_THREAD_PER_CONNECTION, MHD_USE_TLS, MHD_Daemon::notify_completed, NULL, MHD_Daemon::options, parse_options_va(), MHD_Daemon::per_ip_connection_mutex, MHD_Daemon::pid, MHD_Daemon::pool_increment, MHD_Daemon::pool_size, MHD_Daemon::port, MHD_Daemon::sigpipe_blocked, MHD_Daemon::strict_for_client, MHD_Daemon::unescape_callback, unescape_wrapper(), MHD_Daemon::worker_pool, and MHD_Daemon::worker_pool_size.
Referenced by MHD_start_daemon().
void MHD_stop_daemon | ( | struct MHD_Daemon * | daemon | ) |
Shutdown an HTTP daemon.
daemon | daemon to stop |
Definition at line 7318 of file daemon.c.
References _, MHD_Daemon::cleanup_connection_mutex, MHD_Daemon::cleanup_head, close_all_connections(), MHD_Daemon::connections_head, MHD_Connection::daemon, fd, MHD_Daemon::itc, MHD_Daemon::listen_fd, MHD_Daemon::master, mhd_assert, MHD_INVALID_SOCKET, MHD_itc_destroy_chk_, MHD_ITC_IS_INVALID_, MHD_mutex_destroy_chk_, MHD_PANIC, MHD_socket_close_chk_, MHD_USE_EPOLL, MHD_USE_INTERNAL_POLLING_THREAD, MHD_USE_TLS, MHD_Daemon::new_connections_head, NULL, MHD_Daemon::options, MHD_Daemon::per_ip_connection_mutex, MHD_Daemon::pid, MHD_Daemon::shutdown, MHD_Daemon::suspended_connections_head, MHD_Daemon::was_quiesced, MHD_Daemon::worker_pool, and MHD_Daemon::worker_pool_size.
Referenced by MHD_start_daemon_va().