improve server loop

This commit is contained in:
2025-08-02 16:19:34 +02:00
parent fd8d7b1f17
commit bcbcb10d1c
4 changed files with 40 additions and 31 deletions

View File

@@ -43,7 +43,7 @@ typedef struct cws_http_t {
* @param[in] request_str The http request sent to the server
* @return Returns a http_t pointer to the request
*/
cws_http *cws_http_parse(char *request_str, int sockfd, cws_config *config);
cws_http *cws_http_parse(mcl_string *request_str, int sockfd, cws_config *config);
int cws_http_get_content_type(cws_http *request, char *content_type);

View File

@@ -19,6 +19,8 @@
/* Wait forever (epoll_wait()) */
#define CWS_SERVER_EPOLL_TIMEOUT -1
#define CWS_SERVER_MAX_REQUEST_SIZE (64 * 1024) /* 64 KB */
/* Main server loop */
extern volatile sig_atomic_t cws_server_run;
@@ -40,6 +42,8 @@ typedef enum cws_server_ret_t {
CWS_SERVER_FD_NONBLOCKING_ERROR,
CWS_SERVER_ACCEPT_CLIENT_ERROR,
CWS_SERVER_HASHMAP_INIT,
CWS_SERVER_MALLOC_ERROR,
CWS_SERVER_REQUEST_TOO_LARGE,
} cws_server_ret;
/**
@@ -63,7 +67,7 @@ cws_server_ret cws_server_start(cws_config *config);
*
* @param[in,out] sockfd Socket of the commincation endpoint
*/
int cws_server_loop(int sockfd, cws_config *config);
cws_server_ret cws_server_loop(int sockfd, cws_config *config);
/**
* @brief Adds a file descriptor to the interest list