feat(lnm): switch to epoll
All checks were successful
ci/woodpecker/push/build Pipeline was successful
ci/woodpecker/push/docker Pipeline was successful

This commit is contained in:
Jef Roosens 2023-12-12 22:22:55 +01:00
parent 89cc41f28a
commit d53a949946
Signed by: Jef Roosens
GPG key ID: B75D4F293C7052DB
8 changed files with 117 additions and 95 deletions

View file

@ -81,7 +81,7 @@ lnm_err lnm_http_route_init_regex(lnm_http_route **out, lnm_http_method method,
*/
lnm_err lnm_http_loop_route_add(lnm_http_loop *hl, lnm_http_route *route);
lnm_err lnm_http_loop_run(lnm_http_loop *hl, uint16_t port);
lnm_err lnm_http_loop_run(lnm_http_loop *hl, uint16_t port, int thread_count);
void lnm_http_loop_set_api_key(lnm_http_loop *hl, const char *api_key);

View file

@ -1,13 +1,13 @@
#ifndef LNM_LOOP
#define LNM_LOOP
#include <stdatomic.h>
#include <stdint.h>
#include <stdlib.h>
#include "lnm/common.h"
#define LNM_LOOP_BUF_SIZE 2048
#define LNM_LOOP_INITIAL_CONNS 16
typedef enum {
lnm_loop_state_req = 0,
@ -32,11 +32,8 @@ typedef struct lnm_loop_conn {
typedef struct lnm_loop {
int listen_fd;
struct {
lnm_loop_conn **arr;
size_t len;
size_t open;
} conns;
int epoll_fd;
atomic_int open;
void *gctx;
lnm_err (*ctx_init)(void **out, void *gctx);
void (*ctx_free)(void *ctx);
@ -52,6 +49,6 @@ lnm_err lnm_loop_init(lnm_loop **out, void *gctx,
lnm_err lnm_loop_setup(lnm_loop *l, uint16_t port);
lnm_err lnm_loop_run(lnm_loop *l);
lnm_err lnm_loop_run(lnm_loop *l, int thread_count);
#endif