UDP: remove events from TCP socket

This commit is contained in:
ruti 2024-05-04 22:57:38 +03:00
parent 6651427f3a
commit 9429008264
2 changed files with 14 additions and 10 deletions

View File

@ -55,7 +55,7 @@ struct eval *add_event(struct poolhd *pool, enum eid type,
val->type = type;
#ifndef NOEPOLL
struct epoll_event ev = { .events = e, .data = {val} };
struct epoll_event ev = { .events = EPOLLRDHUP | e, .data = {val} };
if (epoll_ctl(pool->efd, EPOLL_CTL_ADD, fd, &ev)) {
return 0;
}

22
proxy.c
View File

@ -405,7 +405,7 @@ int udp_associate(struct poolhd *pool,
int ufd = nb_socket(params.baddr.sin6_family, SOCK_DGRAM);
if (ufd < 0) {
perror("socket");
uniperror("socket");
return -1;
}
if (params.protect_path
@ -417,7 +417,7 @@ int udp_associate(struct poolhd *pool,
int no = 0;
if (setsockopt(ufd, IPPROTO_IPV6,
IPV6_V6ONLY, (char *)&no, sizeof(no))) {
perror("setsockopt IPV6_V6ONLY");
uniperror("setsockopt IPV6_V6ONLY");
close(ufd);
return -1;
}
@ -436,7 +436,7 @@ int udp_associate(struct poolhd *pool,
int cfd = nb_socket(addr.sa.sa_family, SOCK_DGRAM);
if (cfd < 0) {
perror("socket");
uniperror("socket");
del_event(pool, pair);
return -1;
}
@ -463,7 +463,7 @@ int udp_associate(struct poolhd *pool,
socklen_t sz = sizeof(addr);
if (getsockname(cfd, &addr.sa, &sz)) {
perror("getsockname");
uniperror("getsockname");
return -1;
}
struct s5_req s5r = {
@ -474,7 +474,11 @@ int udp_associate(struct poolhd *pool,
return -1;
}
if (send(val->fd, (char *)&s5r, len, 0) < 0) {
perror("send");
uniperror("send");
return -1;
}
if (mod_etype(pool, val, 0)) {
uniperror("mod_etype");
return -1;
}
return 0;
@ -620,7 +624,7 @@ int on_udp_tunnel(struct eval *val, char *buffer, size_t bfsize)
if (n < 1) {
if (n && errno == EAGAIN)
break;
perror("recv udp");
uniperror("recv udp");
return -1;
}
ssize_t ns;
@ -661,7 +665,7 @@ int on_udp_tunnel(struct eval *val, char *buffer, size_t bfsize)
ns = send(val->pair->pair->fd, data - offs, offs + n, 0);
}
if (ns < 0) {
perror("sendto");
uniperror("sendto");
return -1;
}
} while(1);
@ -716,7 +720,7 @@ static inline int on_request(struct poolhd *pool, struct eval *val,
}
if (s5e < 0) {
if (resp_s5_error(val->fd, -s5e) < 0)
perror("send");
uniperror("send");
return -1;
}
}
@ -726,7 +730,7 @@ static inline int on_request(struct poolhd *pool, struct eval *val,
error = s4_get_addr(buffer, n, &dst);
if (error) {
if (resp_error(val->fd, error, FLAG_S4) < 0)
perror("send");
uniperror("send");
return -1;
}
error = connect_hook(pool, val, &dst, EV_CONNECT);