Skip to content

Commit

Permalink
issue: 3586273 Use XLIO_DEFERRED_CLOSE by default
Browse files Browse the repository at this point in the history
For incoming sockets - no change.
For outgoing sockets - since outgoing sockets occupy a local port, we
should release it on the socket destructor to prevent race from another
socket to use the same port.
This race might cause XLIO to hold 2 sockets with the same RFS object at
the same time, and this is fatal (particularly for TCP).

Signed-off-by: Iftah Levi <iftahl@nvidia.com>
  • Loading branch information
iftahl committed Apr 14, 2024
1 parent 1e18c6a commit b70ab11
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
9 changes: 3 additions & 6 deletions src/core/sock/sock-redirect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ char *sprintf_sockaddr(char *buf, int buflen, const struct sockaddr *_addr, sock

bool handle_close(int fd, bool cleanup, bool passthrough)
{
bool to_close_now = true;
bool to_close_now = !safe_mce_sys().deferred_close;
bool is_for_udp_pool = false;

srdr_logfunc("Cleanup fd=%d cleanup=%d", fd, !!cleanup);
Expand All @@ -253,15 +253,12 @@ bool handle_close(int fd, bool cleanup, bool passthrough)
sockinfo *sockfd = fd_collection_get_sockfd(fd);
if (sockfd) {
// Don't call close(2) for objects without a shadow socket (TCP incoming sockets).
to_close_now = !passthrough && sockfd->is_shadow_socket_present();
to_close_now &= !passthrough && sockfd->is_shadow_socket_present();
#if defined(DEFINED_NGINX)
// Save this value before pointer is destructed
is_for_udp_pool = sockfd->m_is_for_socket_pool;
#endif
g_p_fd_collection->del_sockfd(fd, is_for_udp_pool);
if (safe_mce_sys().deferred_close) {
to_close_now = false;
}
}
if (fd_collection_get_epfd(fd)) {
g_p_fd_collection->del_epfd(fd, cleanup);
Expand All @@ -270,7 +267,7 @@ bool handle_close(int fd, bool cleanup, bool passthrough)
#if defined(DEFINED_NGINX)
if (g_p_app && g_p_app->type == APP_NGINX && is_for_udp_pool) {
g_p_fd_collection->push_socket_pool(sockfd);
to_close_now = false;
return false;
}
#else
NOT_IN_USE(is_for_udp_pool);
Expand Down
2 changes: 1 addition & 1 deletion src/core/util/sys_vars.h
Original file line number Diff line number Diff line change
Expand Up @@ -872,7 +872,7 @@ extern mce_sys_var &safe_mce_sys();
#endif /* DEFINED_UTLS */

#define MCE_DEFAULT_LRO (option_3::AUTO)
#define MCE_DEFAULT_DEFERRED_CLOSE (false)
#define MCE_DEFAULT_DEFERRED_CLOSE (true)
#define MCE_DEFAULT_TCP_ABORT_ON_CLOSE (false)
#define MCE_DEFAULT_RX_POLL_ON_TX_TCP (false)
#define MCE_DEFAULT_TRIGGER_DUMMY_SEND_GETSOCKNAME (false)
Expand Down

0 comments on commit b70ab11

Please sign in to comment.