diff --git a/src/core/sock/sock-redirect.cpp b/src/core/sock/sock-redirect.cpp index 16ead07fa..a6e045721 100644 --- a/src/core/sock/sock-redirect.cpp +++ b/src/core/sock/sock-redirect.cpp @@ -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); @@ -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); @@ -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); diff --git a/src/core/util/sys_vars.h b/src/core/util/sys_vars.h index c97c1f9da..cb04d61df 100644 --- a/src/core/util/sys_vars.h +++ b/src/core/util/sys_vars.h @@ -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)