mirror of
https://github.com/bol-van/zapret.git
synced 2024-11-30 05:50:53 +03:00
tpws: use accept4 instead of accept
This commit is contained in:
parent
7f5fe99ad5
commit
d5b104d781
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1200,7 +1200,12 @@ int event_loop(const int *listen_fd, size_t listen_fd_ct)
|
|||||||
|
|
||||||
accept_salen = sizeof(accept_sa);
|
accept_salen = sizeof(accept_sa);
|
||||||
//Accept new connection
|
//Accept new connection
|
||||||
|
#if defined (__APPLE__)
|
||||||
|
// macos does not have accept4()
|
||||||
tmp_fd = accept(conn->fd, (struct sockaddr*)&accept_sa, &accept_salen);
|
tmp_fd = accept(conn->fd, (struct sockaddr*)&accept_sa, &accept_salen);
|
||||||
|
#else
|
||||||
|
tmp_fd = accept4(conn->fd, (struct sockaddr*)&accept_sa, &accept_salen, SOCK_NONBLOCK);
|
||||||
|
#endif
|
||||||
if (tmp_fd < 0)
|
if (tmp_fd < 0)
|
||||||
{
|
{
|
||||||
perror("Failed to accept connection");
|
perror("Failed to accept connection");
|
||||||
@ -1210,12 +1215,14 @@ int event_loop(const int *listen_fd, size_t listen_fd_ct)
|
|||||||
close(tmp_fd);
|
close(tmp_fd);
|
||||||
VPRINT("Too many local legs : %d", legs_local)
|
VPRINT("Too many local legs : %d", legs_local)
|
||||||
}
|
}
|
||||||
|
#if defined (__APPLE__)
|
||||||
// separate fcntl call to comply with macos
|
// separate fcntl call to comply with macos
|
||||||
else if (fcntl(tmp_fd, F_SETFL, O_NONBLOCK) < 0)
|
else if (fcntl(tmp_fd, F_SETFL, O_NONBLOCK) < 0)
|
||||||
{
|
{
|
||||||
perror("socket set O_NONBLOCK (accept)");
|
perror("socket set O_NONBLOCK (accept)");
|
||||||
close(tmp_fd);
|
close(tmp_fd);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
else if (!(conn=add_tcp_connection(efd, &conn_list, tmp_fd, (struct sockaddr*)&accept_sa, params.port, params.proxy_type)))
|
else if (!(conn=add_tcp_connection(efd, &conn_list, tmp_fd, (struct sockaddr*)&accept_sa, params.port, params.proxy_type)))
|
||||||
{
|
{
|
||||||
// add_tcp_connection closes fd in case of failure
|
// add_tcp_connection closes fd in case of failure
|
||||||
|
Loading…
Reference in New Issue
Block a user