|
cwist
Modern C web framework with libttak runtime
|
#include <cwist/sys/app/app.h>#include <cwist/sys/io/reactor.h>#include <cwist/net/http/http.h>#include <cwist/net/http/https.h>#include <cwist/net/http/http2.h>#include <cwist/core/mem/alloc.h>#include <cwist/sys/app/shutdown.h>#include "../../sys/io/reactor_rx.h"#include "sockopts.h"#include <fcntl.h>#include <errno.h>#include <unistd.h>#include <stdio.h>#include <string.h>#include <time.h>#include <sys/socket.h>#include <arpa/inet.h>#include <netinet/tcp.h>
Go to the source code of this file.
Macros | |
| #define | _POSIX_C_SOURCE 200809L |
Functions | |
| cwist_error_t | cwist_async_server_loop (int server_fd, cwist_app *app) |
| Run the async (reactor-based) HTTP/HTTPS server loop for C1M scale. | |
Definition at line 1 of file async_server.c.
| cwist_error_t cwist_async_server_loop | ( | int | server_fd, |
| cwist_app * | app | ||
| ) |
Run the async (reactor-based) HTTP/HTTPS server loop for C1M scale.
Initializes the HTTPS thread pool when the app serves HTTPS, otherwise the HTTP thread pool (without re-reading CWIST_C1M_MODE, which cwist_app_listen_ex() may have overridden). Sets the server socket non-blocking, enables SO_REUSEPORT when available, creates the reactor, and registers the accept callback on server_fd. Blocks in cwist_reactor_run() until the reactor is stopped (e.g. on shutdown), then tears down the reactor and the thread pool that was initialized.
| server_fd | Listening socket to serve; set non-blocking on entry. |
| app | Application object; NULL or partially configured apps fall back to plain HTTP. |
err_i16 set to 0 on orderly shutdown, or -1 if setup failed (pool init, fcntl, or reactor creation); on the -1 path any initialized resources are cleaned up first and a message is printed to stderr. Definition at line 174 of file async_server.c.
References cap, CWIST_ERR_INT16, cwist_http_pool_destroy(), cwist_http_pool_init_mode(), cwist_reactor_add(), cwist_reactor_create(), cwist_reactor_destroy(), cwist_reactor_run(), cwist_reuseport_enabled(), g_cwist_listen_fd, https_pool_destroy(), and https_pool_init().