cwist
Modern C web framework with libttak runtime
Loading...
Searching...
No Matches
async_server.h File Reference
Include dependency graph for async_server.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

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.
 

Function Documentation

◆ cwist_async_server_loop()

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.

Parameters
server_fdListening socket to serve; set non-blocking on entry.
appApplication object; NULL or partially configured apps fall back to plain HTTP.
Returns
cwist_error_t with 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().