GNU libmicrohttpd 0.9.77
Loading...
Searching...
No Matches
daemon_start.c File Reference

functions to start a daemon More...

#include "internal.h"
#include "connection_cleanup.h"
#include "daemon_close_all_connections.h"
#include "daemon_select.h"
#include "daemon_poll.h"
#include "daemon_epoll.h"
#include "request_resume.h"
Include dependency graph for daemon_start.c:

Go to the source code of this file.

Functions

static enum MHD_StatusCode configure_listen_reuse (struct MHD_Daemon *daemon)
 
static enum MHD_StatusCode open_listen_socket (struct MHD_Daemon *daemon)
 
static void get_listen_port_number (struct MHD_Daemon *daemon)
 
static MHD_THRD_RTRN_TYPE_ MHD_THRD_CALL_SPEC_ MHD_polling_thread (void *cls)
 
static enum MHD_StatusCode setup_thread_pool (struct MHD_Daemon *daemon)
 
enum MHD_StatusCode MHD_daemon_start (struct MHD_Daemon *daemon)
 

Detailed Description

functions to start a daemon

Author
Christian Grothoff

Definition in file daemon_start.c.

Function Documentation

◆ configure_listen_reuse()

static enum MHD_StatusCode configure_listen_reuse ( struct MHD_Daemon daemon)
static

Set listen socket options to allow port rebinding (or not) depending on how MHD was configured.

Parameters
[in,out]daemonthe daemon with the listen socket to configure
Returns
#MHD_SC_OK on success (or non-fatal errors)

Definition at line 42 of file daemon_start.c.

References _, MHD_Daemon::allow_address_reuse, MHD_Daemon::listen_socket, and MHD_socket_last_strerr_.

Referenced by open_listen_socket().

Here is the caller graph for this function:

◆ get_listen_port_number()

static void get_listen_port_number ( struct MHD_Daemon daemon)
static

Obtain the listen port number from the socket (if it was not explicitly set by us, i.e. if we were given a listen socket or if the port was 0 and the OS picked a free one).

Parameters
[in,out]daemondaemon to obtain the port number for

Definition at line 422 of file daemon_start.c.

References _, MHD_Daemon::listen_port, MHD_Daemon::listen_socket, MHD_INVALID_SOCKET, and MHD_socket_last_strerr_.

Referenced by MHD_daemon_start().

Here is the caller graph for this function:

◆ MHD_polling_thread()

static MHD_THRD_RTRN_TYPE_ MHD_THRD_CALL_SPEC_ MHD_polling_thread ( void *  cls)
static

Thread that runs the polling loop until the daemon is explicitly shut down.

Parameters
clsstruct MHD_Deamon to run select loop in a thread for
Returns
always 0 (on shutdown)

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.

Referenced by MHD_daemon_start(), MHD_start_daemon_va(), and setup_thread_pool().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ open_listen_socket()

static enum MHD_StatusCode open_listen_socket ( struct MHD_Daemon daemon)
static

Open, configure and bind the listen socket (if required).

Parameters
[in,out]daemondaemon to open the socket for
Returns
#MHD_SC_OK on success

Definition at line 157 of file daemon_start.c.

References _, configure_listen_reuse(), MHD_Daemon::fast_open_method, MHD_Daemon::fo_queue_length, MHD_Daemon::listen_af, MHD_Daemon::listen_backlog, MHD_Daemon::listen_port, MHD_Daemon::listen_sa, MHD_Daemon::listen_sa_len, MHD_Daemon::listen_socket, mhd_assert, MHD_INVALID_SOCKET, MHD_socket_create_listen_(), MHD_socket_last_strerr_, and UINT_MAX.

Referenced by MHD_daemon_start().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setup_thread_pool()

static enum MHD_StatusCode setup_thread_pool ( struct MHD_Daemon daemon)
static