GNU libmicrohttpd
0.9.29
|
daemon functionality More...
#include "platform.h"
#include "structures.h"
#include "internal.h"
#include "session.h"
#include "io.h"
Go to the source code of this file.
Functions | |
static void | spdyf_panic_std (void *cls, const char *file, unsigned int line, const char *reason) |
static void | spdyf_cleanup_sessions (struct SPDY_Daemon *daemon) |
static void | spdyf_close_all_sessions (struct SPDY_Daemon *daemon) |
static int | spdyf_parse_options_va (struct SPDY_Daemon *daemon, va_list valist) |
void | SPDY_set_panic_func (SPDY_PanicCallback cb, void *cls) |
struct SPDY_Daemon * | SPDYF_start_daemon_va (uint16_t port, const char *certfile, const char *keyfile, SPDY_NewSessionCallback nscb, SPDY_SessionClosedCallback sccb, SPDY_NewRequestCallback nrcb, SPDY_NewDataCallback npdcb, SPDYF_NewStreamCallback fnscb, SPDYF_NewDataCallback fndcb, void *cls, void *fcls, va_list valist) |
void | SPDYF_stop_daemon (struct SPDY_Daemon *daemon) |
int | SPDYF_get_timeout (struct SPDY_Daemon *daemon, unsigned long long *timeout) |
int | SPDYF_get_fdset (struct SPDY_Daemon *daemon, fd_set *read_fd_set, fd_set *write_fd_set, fd_set *except_fd_set, bool all) |
void | SPDYF_run (struct SPDY_Daemon *daemon) |
Variables | |
SPDY_PanicCallback | spdyf_panic = &spdyf_panic_std |
void * | spdyf_panic_cls |
daemon functionality
Definition in file daemon.c.
void SPDY_set_panic_func | ( | SPDY_PanicCallback | cb, |
void * | cls | ||
) |
Sets the global error handler to a different implementation. "cb" will only be called in the case of typically fatal, serious internal consistency issues. These issues should only arise in the case of serious memory corruption or similar problems with the architecture as well as failed assertions. While "cb" is allowed to return and the lib will then try to continue, this is never safe.
The default implementation that is used if no panic function is set simply prints an error message and calls "abort". Alternative implementations might call "exit" or other similar functions.
cb | new error handler |
cls | passed to error handler |
Definition at line 161 of file daemon.c.
References spdyf_panic, and spdyf_panic_cls.
|
static |
Free resources associated with all closed connections. (destroy responses, free buffers, etc.).
daemon | daemon to clean up |
Definition at line 74 of file daemon.c.
References SPDY_Daemon::cleanup_head, SPDY_Daemon::cleanup_tail, DLL_remove, NULL, and SPDYF_session_destroy().
Referenced by spdyf_close_all_sessions(), and SPDYF_run().
|
static |
Closing of all connections handled by the daemon.
daemon | SPDY daemon |
Definition at line 95 of file daemon.c.
References NULL, SPDY_Daemon::sessions_head, SPDY_GOAWAY_STATUS_OK, spdyf_cleanup_sessions(), SPDYF_prepare_goaway(), SPDYF_session_close(), and SPDYF_session_write().
Referenced by SPDYF_stop_daemon().
int SPDYF_get_fdset | ( | struct SPDY_Daemon * | daemon, |
fd_set * | read_fd_set, | ||
fd_set * | write_fd_set, | ||
fd_set * | except_fd_set, | ||
bool | all | ||
) |
Obtain the select sets for this daemon. The idea of SPDYF_get_fdset is to return such descriptors that the select in the application can return and SPDY_run can be called only when this is really needed. That means not all sockets will be added to write_fd_set.
daemon | daemon to get sets from |
read_fd_set | read set |
write_fd_set | write set |
except_fd_set | except set |
all | add all session's descriptors to write_fd_set or not |
Definition at line 432 of file daemon.c.
References SPDY_Session::fio_is_pending, SPDY_Session::last_activity, SPDY_Session::next, NULL, SPDY_Session::read_buffer_beginning, SPDY_Session::read_buffer_offset, SPDY_Session::response_queue_head, SPDY_Daemon::session_timeout, SPDY_Daemon::sessions_head, SPDY_Session::socket_fd, SPDY_Daemon::socket_fd, SPDY_SESSION_STATUS_CLOSING, SPDY_YES, SPDYF_monotonic_time(), SPDY_Session::status, and SPDY_Session::write_buffer.
Referenced by SPDY_get_fdset(), and SPDYF_run().
int SPDYF_get_timeout | ( | struct SPDY_Daemon * | daemon, |
unsigned long long * | timeout | ||
) |
Obtain timeout value for select for this daemon. The returned value is how long select should at most block, not the timeout value set for connections.
daemon | daemon to query for timeout |
timeout | set to the timeout (in milliseconds) |
Definition at line 392 of file daemon.c.
References SPDY_Session::fio_is_pending, SPDY_Session::last_activity, SPDY_Session::next, NULL, SPDY_Daemon::session_timeout, SPDY_Daemon::sessions_head, SPDY_NO, SPDY_YES, and SPDYF_monotonic_time().
Referenced by SPDY_get_timeout().
|
static |
|
static |
Parse a list of options given as varargs.
daemon | the daemon to initialize |
valist | the options |
Definition at line 120 of file daemon.c.
References SPDY_Daemon::address, SPDY_Daemon::flags, SPDY_Daemon::io_subsystem, SPDY_Daemon::max_num_frames, SPDY_Daemon::options, SPDY_Daemon::session_timeout, SPDY_DAEMON_OPTION_END, SPDY_DAEMON_OPTION_FLAGS, SPDY_DAEMON_OPTION_IO_SUBSYSTEM, SPDY_DAEMON_OPTION_MAX_NUM_FRAMES, SPDY_DAEMON_OPTION_SESSION_TIMEOUT, SPDY_DAEMON_OPTION_SOCK_ADDR, SPDY_NO, SPDY_YES, and SPDYF_DEBUG.
Referenced by SPDYF_start_daemon_va().
void SPDYF_run | ( | struct SPDY_Daemon * | daemon | ) |
Run webserver operations (without blocking unless in client callbacks). This method must be called in the client event loop.
daemon | daemon to run |
Definition at line 474 of file daemon.c.
References SPDY_Session::fio_is_pending, SPDY_Session::next, NULL, SPDY_Daemon::sessions_head, SPDY_Session::socket_fd, SPDY_Daemon::socket_fd, SPDY_NO, spdyf_cleanup_sessions(), SPDYF_get_fdset(), SPDYF_session_accept(), SPDYF_session_idle(), SPDYF_session_read(), and SPDYF_session_write().
Referenced by SPDY_run().
|
read |
Start a SPDDY webserver on the given port.
port | port to bind to |
certfile | path to the certificate that will be used by server |
keyfile | path to the keyfile for the certificate |
nscb | callback called when a new SPDY session is established by a client |
sccb | callback called when a client closes the session |
nrcb | callback called when a client sends request |
npdcb | callback called when HTTP POST params are received after request |
fnscb | callback called when new stream is opened by a client |
fndcb | callback called when new data – within a data frame – is received by the server |
cls | extra argument to all of the callbacks without those specific only for the framing layer |
fcls | extra argument to all of the callbacks, specific only for the framing layer (those vars starting with 'f'). |
valist | va_list of options (type-value pairs, terminated with SPDY_DAEMON_OPTION_END). |
Definition at line 170 of file daemon.c.
References SPDY_Daemon::address, SPDY_Daemon::certfile, SPDY_Daemon::cls, SPDY_Daemon::fcls, SPDY_Daemon::fio_init, SPDY_Daemon::flags, SPDY_Daemon::fnew_stream_cb, SPDY_Daemon::freceived_data_cb, SPDY_Daemon::io_subsystem, SPDY_Daemon::keyfile, SPDY_Daemon::max_num_frames, SPDY_Daemon::new_request_cb, SPDY_Daemon::new_session_cb, NULL, SPDY_Daemon::port, SPDY_Daemon::received_data_cb, SPDY_Daemon::session_closed_cb, SPDY_Daemon::socket_fd, SPDY_DAEMON_FLAG_ONLY_IPV6, SPDY_IO_SUBSYSTEM_OPENSSL, SPDY_IO_SUBSYSTEM_RAW, SPDY_YES, SPDYF_DEBUG, SPDYF_io_set_daemon(), SPDYF_NUM_SENT_FRAMES_AT_ONCE, and spdyf_parse_options_va().
Referenced by SPDY_start_daemon().
void SPDYF_stop_daemon | ( | struct SPDY_Daemon * | daemon | ) |
Shutdown the daemon.
daemon | daemon to stop |
Definition at line 373 of file daemon.c.
References SPDY_Daemon::address, SPDY_Daemon::certfile, SPDY_Daemon::fio_deinit, SPDY_Daemon::keyfile, SPDY_Daemon::options, SPDY_Daemon::socket_fd, SPDY_DAEMON_OPTION_SOCK_ADDR, and spdyf_close_all_sessions().
Referenced by SPDY_stop_daemon().
SPDY_PanicCallback spdyf_panic = &spdyf_panic_std |
Global handler for fatal errors.
Definition at line 58 of file daemon.c.
Referenced by SPDY_set_panic_func().
void* spdyf_panic_cls |
Global closure argument for "spdyf_panic".
Definition at line 64 of file daemon.c.
Referenced by SPDY_set_panic_func().