mirror of
https://github.com/hufrea/byedpi.git
synced 2025-01-03 04:49:47 +00:00
Fix double close, signal error check
This commit is contained in:
parent
86217408fc
commit
4914491fe4
2
main.c
2
main.c
@ -153,7 +153,7 @@ char *ftob(char *name, ssize_t *sl)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int get_addr(char *str, struct sockaddr_ina *addr)
|
int get_addr(const char *str, struct sockaddr_ina *addr)
|
||||||
{
|
{
|
||||||
struct addrinfo hints = {0}, *res = 0;
|
struct addrinfo hints = {0}, *res = 0;
|
||||||
|
|
||||||
|
15
proxy.c
15
proxy.c
@ -553,14 +553,21 @@ int big_loop(int srvfd)
|
|||||||
struct poolhd *pool = init_pool(params.max_open * 2 + 1);
|
struct poolhd *pool = init_pool(params.max_open * 2 + 1);
|
||||||
if (!pool) {
|
if (!pool) {
|
||||||
perror("init pool");
|
perror("init pool");
|
||||||
|
close(srvfd);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (!add_event(pool, EV_ACCEPT, srvfd, 0)) {
|
||||||
|
perror("add event");
|
||||||
|
destroy_pool(pool);
|
||||||
|
close(srvfd);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
char *buffer = malloc(params.bfsize);
|
char *buffer = malloc(params.bfsize);
|
||||||
if (!buffer) {
|
if (!buffer) {
|
||||||
perror("malloc");
|
perror("malloc");
|
||||||
|
destroy_pool(pool);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
add_event(pool, EV_ACCEPT, srvfd, 0);
|
|
||||||
|
|
||||||
struct eval *val;
|
struct eval *val;
|
||||||
int i = -1, etype;
|
int i = -1, etype;
|
||||||
@ -620,7 +627,7 @@ int big_loop(int srvfd)
|
|||||||
int listener(struct sockaddr_ina srv)
|
int listener(struct sockaddr_ina srv)
|
||||||
{
|
{
|
||||||
#ifdef SIGPIPE
|
#ifdef SIGPIPE
|
||||||
if (signal(SIGPIPE, SIG_IGN))
|
if (signal(SIGPIPE, SIG_IGN) == SIG_ERR)
|
||||||
uniperror("signal SIGPIPE!");
|
uniperror("signal SIGPIPE!");
|
||||||
#endif
|
#endif
|
||||||
signal(SIGINT, on_cancel);
|
signal(SIGINT, on_cancel);
|
||||||
@ -647,7 +654,5 @@ int listener(struct sockaddr_ina srv)
|
|||||||
close(srvfd);
|
close(srvfd);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
int status = big_loop(srvfd);
|
return big_loop(srvfd);
|
||||||
close(srvfd);
|
|
||||||
return status;
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user