Remove tcp_closer

This commit is contained in:
2022-12-31 11:20:29 +01:00
parent 33feabdec0
commit 9cb278eb2a
7 changed files with 21 additions and 46 deletions

View File

@ -44,8 +44,6 @@ typedef struct {
void tcp_acceptor_func(client_ctx_t *ctx);
void tcp_closer_func(client_ctx_t *ctx);
void request_handler_func(client_ctx_t *ctx);
void local_handler_func(client_ctx_t *ctx);
@ -58,6 +56,8 @@ void ws_frame_handler_func(ws_ctx_t *ctx);
int respond(client_ctx_t *ctx);
int request_complete(client_ctx_t *ctx);
void request_complete(client_ctx_t *ctx);
void tcp_close(client_ctx_t *ctx);
#endif //SESIMOS_FUNC_H

View File

@ -350,7 +350,7 @@ int respond(client_ctx_t *ctx) {
return 0;
}
int request_complete(client_ctx_t *ctx) {
void request_complete(client_ctx_t *ctx) {
// FIXME
//if (close_proxy && proxy.socket != 0) {
// info(BLUE_STR "Closing proxy connection");
@ -364,6 +364,4 @@ int request_complete(client_ctx_t *ctx) {
uri_free(&ctx->uri);
http_free_req(&ctx->req);
http_free_res(&ctx->res);
return 0;
}

View File

@ -116,3 +116,15 @@ static int tcp_acceptor(client_ctx_t *ctx) {
return 0;
}
void tcp_close(client_ctx_t *ctx) {
logger_set_prefix("[%*s]%s", INET6_ADDRSTRLEN, ctx->socket.s_addr, ctx->log_prefix);
sock_close(&ctx->socket);
ctx->cnx_e = clock_micros();
char buf[32];
info("Connection closed (%s)", format_duration(ctx->cnx_e - ctx->cnx_s, buf));
memset(ctx, 0, sizeof(*ctx));
}

View File

@ -1,25 +0,0 @@
/**
* sesimos - secure, simple, modern web server
* @brief TCP closer
* @file src/worker/tcp_closer.c
* @author Lorenz Stechauner
* @date 2022-12-28
*/
#include "func.h"
#include "../logger.h"
#include "../lib/utils.h"
#include <memory.h>
void tcp_closer_func(client_ctx_t *ctx) {
logger_set_prefix("[%*s]%s", INET6_ADDRSTRLEN, ctx->socket.s_addr, ctx->log_prefix);
sock_close(&ctx->socket);
ctx->cnx_e = clock_micros();
char buf[32];
info("Connection closed (%s)", format_duration(ctx->cnx_e - ctx->cnx_s, buf));
memset(ctx, 0, sizeof(*ctx));
}