Nilorea Library
C utilities for networking, threading, graphics
Loading...
Searching...
No Matches
n_network_accept_pool.c File Reference

Accept pool for parallel connection acceptance (nginx-style) More...

#include "nilorea/n_network_accept_pool.h"
#include <errno.h>
#include <string.h>
+ Include dependency graph for n_network_accept_pool.c:

Go to the source code of this file.

Functions

NETW_ACCEPT_POOLnetw_accept_pool_create (NETWORK *server, size_t nb_threads, int accept_timeout, netw_accept_callback_t callback, void *user_data)
 Create a new accept pool.
 
int netw_accept_pool_destroy (NETW_ACCEPT_POOL **pool)
 Destroy an accept pool.
 
int netw_accept_pool_get_stats (NETW_ACCEPT_POOL *pool, NETW_ACCEPT_POOL_STATS *stats)
 Get a snapshot of pool statistics.
 
int netw_accept_pool_start (NETW_ACCEPT_POOL *pool)
 Start the accept pool (launches accept threads)
 
int netw_accept_pool_stop (NETW_ACCEPT_POOL *pool)
 Request the accept pool to stop.
 
static void * netw_accept_pool_thread_func (void *arg)
 Thread function for accept pool workers.
 
int netw_accept_pool_wait (NETW_ACCEPT_POOL *pool, int timeout_sec)
 Wait for all accept threads to finish after a stop request.
 

Detailed Description

Accept pool for parallel connection acceptance (nginx-style)

Author
Castagnier Mickael
Version
1.0
Date
11/03/2026

Definition in file n_network_accept_pool.c.

Function Documentation

◆ netw_accept_pool_thread_func()

static void * netw_accept_pool_thread_func ( void *  arg)
static

Thread function for accept pool workers.

Each thread loops calling accept on the shared listening socket and invokes the user callback for each accepted connection.

Parameters
argpointer to the NETW_ACCEPT_POOL
Returns
NULL

Definition at line 39 of file n_network_accept_pool.c.

References __n_assert, LOG_ERR, n_log, netw_accept_from_ex(), netw_accept_pool_atomic_read_state, NETW_ACCEPT_POOL_RUNNING, netw_close(), pool, and u_sleep().

Referenced by netw_accept_pool_start().

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