mirror of
https://github.com/hufrea/byedpi.git
synced 2024-11-21 14:35:22 +03:00
Delete broken event, log "pull is full" error (#132)
* Delete event with closed socket * Log "pull is full" error * Error logging inside add_event and init_pool
This commit is contained in:
parent
9b685ecbb9
commit
193737173b
3 changed files with 13 additions and 8 deletions
5
conev.c
5
conev.c
|
@ -4,12 +4,14 @@
|
|||
#include <string.h>
|
||||
#include <limits.h>
|
||||
#include <assert.h>
|
||||
#include "error.h"
|
||||
|
||||
|
||||
struct poolhd *init_pool(int count)
|
||||
{
|
||||
struct poolhd *pool = calloc(sizeof(struct poolhd), 1);
|
||||
if (!pool) {
|
||||
uniperror("init pool");
|
||||
return 0;
|
||||
}
|
||||
pool->max = count;
|
||||
|
@ -29,6 +31,7 @@ struct poolhd *init_pool(int count)
|
|||
pool->items = malloc(sizeof(*pool->items) * count);
|
||||
|
||||
if (!pool->pevents || !pool->links || !pool->items) {
|
||||
uniperror("init pool");
|
||||
destroy_pool(pool);
|
||||
return 0;
|
||||
}
|
||||
|
@ -45,6 +48,7 @@ struct eval *add_event(struct poolhd *pool, enum eid type,
|
|||
{
|
||||
assert(fd > 0);
|
||||
if (pool->count >= pool->max) {
|
||||
LOG(LOG_E, "add_event: pool is full\n");
|
||||
return 0;
|
||||
}
|
||||
struct eval *val = pool->links[pool->count];
|
||||
|
@ -58,6 +62,7 @@ struct eval *add_event(struct poolhd *pool, enum eid type,
|
|||
#ifndef NOEPOLL
|
||||
struct epoll_event ev = { .events = EPOLLRDHUP | e, .data = {val} };
|
||||
if (epoll_ctl(pool->efd, EPOLL_CTL_ADD, fd, &ev)) {
|
||||
uniperror("add event");
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
|
|
2
error.h
2
error.h
|
@ -11,6 +11,8 @@
|
|||
#include <android/log.h>
|
||||
#endif
|
||||
|
||||
#include "params.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#define get_e() \
|
||||
unie(WSAGetLastError())
|
||||
|
|
4
proxy.c
4
proxy.c
|
@ -614,7 +614,7 @@ static inline int on_accept(struct poolhd *pool, struct eval *val)
|
|||
rval->in6 = client.in6;
|
||||
#ifdef __linux__
|
||||
if (params.transparent && transp_conn(pool, rval) < 0) {
|
||||
close(c);
|
||||
del_event(pool, rval);
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
|
@ -904,12 +904,10 @@ int event_loop(int srvfd)
|
|||
|
||||
struct poolhd *pool = init_pool(params.max_open * 2 + 1);
|
||||
if (!pool) {
|
||||
uniperror("init pool");
|
||||
close(srvfd);
|
||||
return -1;
|
||||
}
|
||||
if (!add_event(pool, EV_ACCEPT, srvfd, POLLIN)) {
|
||||
uniperror("add event");
|
||||
destroy_pool(pool);
|
||||
close(srvfd);
|
||||
return -1;
|
||||
|
|
Loading…
Reference in a new issue