From 86217408fc282414fd34305cd0e49455c969eb53 Mon Sep 17 00:00:00 2001 From: ruti <> Date: Sun, 25 Feb 2024 00:40:54 +0300 Subject: [PATCH] Replace perror calls, remove io from conev.c --- conev.c | 10 +--------- desync.c | 6 +++--- proxy.c | 3 +++ 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/conev.c b/conev.c index af829d5..220eeb0 100644 --- a/conev.c +++ b/conev.c @@ -1,10 +1,8 @@ #define CONEV_H #include -#include #include #include -#include struct poolhd *init_pool(int count) @@ -19,7 +17,6 @@ struct poolhd *init_pool(int count) #ifndef NOEPOLL int efd = epoll_create(count); if (efd < 0) { - uniperror("epoll_create"); free(pool); return 0; } @@ -149,7 +146,6 @@ struct eval *next_event(struct poolhd *pool, int *offs, int *type) if (i < 0) { i = (epoll_wait(pool->efd, pool->pevents, pool->max, -1) - 1); if (i < 0) { - uniperror("epoll_wait"); return 0; } } @@ -169,10 +165,7 @@ int mod_etype(struct poolhd *pool, struct eval *val, int type, char add) else ev.events &= ~type; val->events = ev.events; - int s = epoll_ctl(pool->efd, EPOLL_CTL_MOD, val->fd, &ev); - if (s) - uniperror("epoll_ctl"); - return s; + return epoll_ctl(pool->efd, EPOLL_CTL_MOD, val->fd, &ev); } #else @@ -181,7 +174,6 @@ struct eval *next_event(struct poolhd *pool, int *offs, int *typel) for (int i = *offs; ; i--) { if (i < 0) { if (poll(pool->pevents, pool->count, -1) <= 0) { - uniperror("poll"); return 0; } i = pool->count - 1; diff --git a/desync.c b/desync.c index 2209d07..afd333d 100644 --- a/desync.c +++ b/desync.c @@ -98,7 +98,7 @@ int fake_attack(int sfd, char *buffer, break; } if (_sendfile(sfd, ffd, 0, pos) < 0) { - perror("sendfile"); + uniperror("sendfile"); break; } struct timespec delay = { @@ -111,7 +111,7 @@ int fake_attack(int sfd, char *buffer, break; } if (send(sfd, buffer + pos, n - pos, 0) < 0) { - perror("send"); + uniperror("send"); break; } status = 0; @@ -165,7 +165,7 @@ int desync(int sfd, char *buffer, size_t bfsize, if (type == IS_HTTP && params.mod_http) { LOG(LOG_S, "modify HTTP: n=%ld\n", n); if (mod_http(buffer, n, params.mod_http)) { - fprintf(stderr, "mod http error\n"); + LOG(LOG_E, "mod http error\n"); return -1; } } diff --git a/proxy.c b/proxy.c index 23150bf..96f1535 100644 --- a/proxy.c +++ b/proxy.c @@ -456,6 +456,7 @@ static inline int on_connect(struct poolhd *pool, struct eval *val, return -1; } if (mod_etype(pool, val, POLLOUT, 0)) { + uniperror("mod_etype"); return -1; } val->type = EV_TUNNEL; @@ -503,6 +504,7 @@ static inline int on_tunnel(struct poolhd *pool, struct eval *val, if (mod_etype(pool, val, POLLIN, 1) || mod_etype(pool, pair, POLLOUT, 0)) { + uniperror("mod_etype"); return -1; } } @@ -534,6 +536,7 @@ static inline int on_tunnel(struct poolhd *pool, struct eval *val, if (mod_etype(pool, val, POLLIN, 0) || mod_etype(pool, pair, POLLOUT, 1)) { + uniperror("mod_etype"); return -1; } break;