Skip to content

Commit 4b47570

Browse files
committed
issue: 3586273 Use XLIO_DEFERRED_CLOSE by default
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 <[email protected]>
1 parent 1e18c6a commit 4b47570

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

src/core/sock/sock-redirect.cpp

+2-4
Original file line numberDiff line numberDiff line change
@@ -253,15 +253,13 @@ bool handle_close(int fd, bool cleanup, bool passthrough)
253253
sockinfo *sockfd = fd_collection_get_sockfd(fd);
254254
if (sockfd) {
255255
// Don't call close(2) for objects without a shadow socket (TCP incoming sockets).
256-
to_close_now = !passthrough && sockfd->is_shadow_socket_present();
256+
to_close_now = !safe_mce_sys().deferred_close && !passthrough &&
257+
sockfd->is_shadow_socket_present();
257258
#if defined(DEFINED_NGINX)
258259
// Save this value before pointer is destructed
259260
is_for_udp_pool = sockfd->m_is_for_socket_pool;
260261
#endif
261262
g_p_fd_collection->del_sockfd(fd, is_for_udp_pool);
262-
if (safe_mce_sys().deferred_close) {
263-
to_close_now = false;
264-
}
265263
}
266264
if (fd_collection_get_epfd(fd)) {
267265
g_p_fd_collection->del_epfd(fd, cleanup);

src/core/util/sys_vars.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -872,7 +872,7 @@ extern mce_sys_var &safe_mce_sys();
872872
#endif /* DEFINED_UTLS */
873873

874874
#define MCE_DEFAULT_LRO (option_3::AUTO)
875-
#define MCE_DEFAULT_DEFERRED_CLOSE (false)
875+
#define MCE_DEFAULT_DEFERRED_CLOSE (true)
876876
#define MCE_DEFAULT_TCP_ABORT_ON_CLOSE (false)
877877
#define MCE_DEFAULT_RX_POLL_ON_TX_TCP (false)
878878
#define MCE_DEFAULT_TRIGGER_DUMMY_SEND_GETSOCKNAME (false)

0 commit comments

Comments
 (0)