Replace perror calls, remove io from conev.c

This commit is contained in:
ruti 2024-02-25 00:40:54 +03:00
parent 97fb56955d
commit 86217408fc
3 changed files with 7 additions and 12 deletions

10
conev.c
View File

@ -1,10 +1,8 @@
#define CONEV_H #define CONEV_H
#include <conev.h> #include <conev.h>
#include <error.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <stdio.h>
struct poolhd *init_pool(int count) struct poolhd *init_pool(int count)
@ -19,7 +17,6 @@ struct poolhd *init_pool(int count)
#ifndef NOEPOLL #ifndef NOEPOLL
int efd = epoll_create(count); int efd = epoll_create(count);
if (efd < 0) { if (efd < 0) {
uniperror("epoll_create");
free(pool); free(pool);
return 0; return 0;
} }
@ -149,7 +146,6 @@ struct eval *next_event(struct poolhd *pool, int *offs, int *type)
if (i < 0) { if (i < 0) {
i = (epoll_wait(pool->efd, pool->pevents, pool->max, -1) - 1); i = (epoll_wait(pool->efd, pool->pevents, pool->max, -1) - 1);
if (i < 0) { if (i < 0) {
uniperror("epoll_wait");
return 0; return 0;
} }
} }
@ -169,10 +165,7 @@ int mod_etype(struct poolhd *pool, struct eval *val, int type, char add)
else else
ev.events &= ~type; ev.events &= ~type;
val->events = ev.events; val->events = ev.events;
int s = epoll_ctl(pool->efd, EPOLL_CTL_MOD, val->fd, &ev); return epoll_ctl(pool->efd, EPOLL_CTL_MOD, val->fd, &ev);
if (s)
uniperror("epoll_ctl");
return s;
} }
#else #else
@ -181,7 +174,6 @@ struct eval *next_event(struct poolhd *pool, int *offs, int *typel)
for (int i = *offs; ; i--) { for (int i = *offs; ; i--) {
if (i < 0) { if (i < 0) {
if (poll(pool->pevents, pool->count, -1) <= 0) { if (poll(pool->pevents, pool->count, -1) <= 0) {
uniperror("poll");
return 0; return 0;
} }
i = pool->count - 1; i = pool->count - 1;

View File

@ -98,7 +98,7 @@ int fake_attack(int sfd, char *buffer,
break; break;
} }
if (_sendfile(sfd, ffd, 0, pos) < 0) { if (_sendfile(sfd, ffd, 0, pos) < 0) {
perror("sendfile"); uniperror("sendfile");
break; break;
} }
struct timespec delay = { struct timespec delay = {
@ -111,7 +111,7 @@ int fake_attack(int sfd, char *buffer,
break; break;
} }
if (send(sfd, buffer + pos, n - pos, 0) < 0) { if (send(sfd, buffer + pos, n - pos, 0) < 0) {
perror("send"); uniperror("send");
break; break;
} }
status = 0; status = 0;
@ -165,7 +165,7 @@ int desync(int sfd, char *buffer, size_t bfsize,
if (type == IS_HTTP && params.mod_http) { if (type == IS_HTTP && params.mod_http) {
LOG(LOG_S, "modify HTTP: n=%ld\n", n); LOG(LOG_S, "modify HTTP: n=%ld\n", n);
if (mod_http(buffer, n, params.mod_http)) { if (mod_http(buffer, n, params.mod_http)) {
fprintf(stderr, "mod http error\n"); LOG(LOG_E, "mod http error\n");
return -1; return -1;
} }
} }

View File

@ -456,6 +456,7 @@ static inline int on_connect(struct poolhd *pool, struct eval *val,
return -1; return -1;
} }
if (mod_etype(pool, val, POLLOUT, 0)) { if (mod_etype(pool, val, POLLOUT, 0)) {
uniperror("mod_etype");
return -1; return -1;
} }
val->type = EV_TUNNEL; 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) || if (mod_etype(pool, val, POLLIN, 1) ||
mod_etype(pool, pair, POLLOUT, 0)) { mod_etype(pool, pair, POLLOUT, 0)) {
uniperror("mod_etype");
return -1; return -1;
} }
} }
@ -534,6 +536,7 @@ static inline int on_tunnel(struct poolhd *pool, struct eval *val,
if (mod_etype(pool, val, POLLIN, 0) || if (mod_etype(pool, val, POLLIN, 0) ||
mod_etype(pool, pair, POLLOUT, 1)) { mod_etype(pool, pair, POLLOUT, 1)) {
uniperror("mod_etype");
return -1; return -1;
} }
break; break;