From 736f3c1dee4e62d92e6a5fd22b5a069d7eb3cc12 Mon Sep 17 00:00:00 2001 From: Vasiliy Kiryanov Date: Mon, 21 Oct 2024 22:07:59 -0400 Subject: [PATCH 1/6] have_sys_socket.c: support for MacOS added --- CMakeLists.txt | 8 ++++++++ include/private/config.h.in | 1 + include/private/config/wrapper/socket.h | 10 ++++++++++ src/config/have_sys_socket.c | 5 +++-- 4 files changed, 22 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6db68a49e..a6c82908b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -294,6 +294,14 @@ endif() # configuration-specific source files + +# we don't check for win32 as on win32 socket operations are handled directly through return values +if(APPLE) # MacOS, iOS + set(SUPPORT_DISALLOW_SIGNAL_DURING_SENDING TRUE) +elseif(UNIX) # Linux/BSD/other UNIX-like systems + set(SUPPORT_DISALLOW_SIGNAL_DURING_SENDING TRUE) +endif() + if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") set(SUPPORT_ABSTRACT_SOCKET_NAMES TRUE) list(APPEND STUMPLESS_SOURCES ${PROJECT_SOURCE_DIR}/src/config/abstract_socket_names_supported.c) diff --git a/include/private/config.h.in b/include/private/config.h.in index 60f25ce68..159c59ea2 100644 --- a/include/private/config.h.in +++ b/include/private/config.h.in @@ -46,6 +46,7 @@ /* function support checks */ #cmakedefine SUPPORT_ABSTRACT_SOCKET_NAMES 1 +#cmakedefine SUPPORT_DISALLOW_SIGNAL_DURING_SENDING 1 #cmakedefine SUPPORT_GETHOSTBYNAME 1 #cmakedefine SUPPORT_UNISTD_SYSCONF_GETPAGESIZE 1 #cmakedefine SUPPORT_WINDOWS_GET_NOW 1 diff --git a/include/private/config/wrapper/socket.h b/include/private/config/wrapper/socket.h index dc75596c2..f9e480126 100644 --- a/include/private/config/wrapper/socket.h +++ b/include/private/config/wrapper/socket.h @@ -41,4 +41,14 @@ # define config_get_local_socket_name no_abstract_socket_names_get_local_socket_name # endif +# ifdef SUPPORT_DISALLOW_SIGNAL_DURING_SENDING +# if defined(__APPLE__) +# define config_disallow_signal_during_sending_flag SO_NOSIGPIPE +# elif defined(__linux__) +# define config_disallow_signal_during_sending_flag MSG_NOSIGNAL +# elif defined(unix) || defined(__unix__) +# define config_disallow_signal_during_sending_flag MSG_NOSIGNAL +# endif +# endif + #endif /* __STUMPLESS_PRIVATE_CONFIG_WRAPPER_SOCKET_H */ diff --git a/src/config/have_sys_socket.c b/src/config/have_sys_socket.c index e7bba5ccb..9893533a4 100644 --- a/src/config/have_sys_socket.c +++ b/src/config/have_sys_socket.c @@ -27,6 +27,7 @@ #include "private/config/wrapper/locale.h" #include "private/config/wrapper/int_connect.h" #include "private/config/wrapper/thread_safety.h" +#include "private/config/wrapper/socket.h" #include "private/error.h" #include "private/target/network.h" @@ -204,7 +205,7 @@ sys_socket_sendto_tcp_target( struct network_target *target, send_result = send( target->handle, msg, msg_size - sent_bytes, - MSG_NOSIGNAL ); + config_disallow_signal_during_sending_flag ); if( unlikely( send_result == -1 ) ){ raise_socket_send_failure( L10N_SEND_SYS_SOCKET_FAILED_ERROR_MESSAGE, @@ -231,7 +232,7 @@ sys_socket_sendto_udp_target( const struct network_target *target, send_result = send( target->handle, msg, msg_size, - MSG_NOSIGNAL ); + config_disallow_signal_during_sending_flag ); if( unlikely( send_result == -1 ) ){ unlock_network_target( target ); From 0e0ff0e8622f96149beec25026c8bf3a7285f61a Mon Sep 17 00:00:00 2001 From: Vasiliy Kiryanov Date: Tue, 22 Oct 2024 21:59:51 -0400 Subject: [PATCH 2/6] CmakeList.txt: check_symbol_exists used instead of APPLE check is used HAVE_DISALLOW_SIGNAL_DURING_SENDING definition is used instead of SUPPORT_DISALLOW_SIGNAL_DURING_SENDING --- CMakeLists.txt | 12 ++++++++---- include/private/config.h.in | 2 +- include/private/config/wrapper/socket.h | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a6c82908b..e998a2cc4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -296,10 +296,14 @@ endif() # configuration-specific source files # we don't check for win32 as on win32 socket operations are handled directly through return values -if(APPLE) # MacOS, iOS - set(SUPPORT_DISALLOW_SIGNAL_DURING_SENDING TRUE) -elseif(UNIX) # Linux/BSD/other UNIX-like systems - set(SUPPORT_DISALLOW_SIGNAL_DURING_SENDING TRUE) +# Check if SO_NOSIGPIPE exists +check_symbol_exists(SO_NOSIGPIPE "sys/socket.h" HAVE_SO_NOSIGPIPE) + +# Check if MSG_NOSIGNAL exists +check_symbol_exists(MSG_NOSIGNAL "sys/socket.h" HAVE_MSG_NOSIGNAL) + +if(HAVE_SO_NOSIGPIPE OR HAVE_MSG_NOSIGNAL) + set(HAVE_DISALLOW_SIGNAL_DURING_SENDING TRUE) endif() if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") diff --git a/include/private/config.h.in b/include/private/config.h.in index 159c59ea2..1b9858cdd 100644 --- a/include/private/config.h.in +++ b/include/private/config.h.in @@ -46,7 +46,7 @@ /* function support checks */ #cmakedefine SUPPORT_ABSTRACT_SOCKET_NAMES 1 -#cmakedefine SUPPORT_DISALLOW_SIGNAL_DURING_SENDING 1 +#cmakedefine HAVE_DISALLOW_SIGNAL_DURING_SENDING 1 #cmakedefine SUPPORT_GETHOSTBYNAME 1 #cmakedefine SUPPORT_UNISTD_SYSCONF_GETPAGESIZE 1 #cmakedefine SUPPORT_WINDOWS_GET_NOW 1 diff --git a/include/private/config/wrapper/socket.h b/include/private/config/wrapper/socket.h index f9e480126..7d4bdf302 100644 --- a/include/private/config/wrapper/socket.h +++ b/include/private/config/wrapper/socket.h @@ -41,7 +41,7 @@ # define config_get_local_socket_name no_abstract_socket_names_get_local_socket_name # endif -# ifdef SUPPORT_DISALLOW_SIGNAL_DURING_SENDING +# ifdef HAVE_DISALLOW_SIGNAL_DURING_SENDING # if defined(__APPLE__) # define config_disallow_signal_during_sending_flag SO_NOSIGPIPE # elif defined(__linux__) From 073efc6de74dbd013d93cc640668a4433d11af22 Mon Sep 17 00:00:00 2001 From: Vasiliy Kiryanov Date: Wed, 23 Oct 2024 08:59:22 -0400 Subject: [PATCH 3/6] removed unnecessary HAVE_DISALLOW_SIGNAL_DURING_SENDING --- CMakeLists.txt | 4 ---- include/private/config.h.in | 4 +++- include/private/config/wrapper/socket.h | 12 ++++-------- 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e998a2cc4..567b3ba7b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -302,10 +302,6 @@ check_symbol_exists(SO_NOSIGPIPE "sys/socket.h" HAVE_SO_NOSIGPIPE) # Check if MSG_NOSIGNAL exists check_symbol_exists(MSG_NOSIGNAL "sys/socket.h" HAVE_MSG_NOSIGNAL) -if(HAVE_SO_NOSIGPIPE OR HAVE_MSG_NOSIGNAL) - set(HAVE_DISALLOW_SIGNAL_DURING_SENDING TRUE) -endif() - if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") set(SUPPORT_ABSTRACT_SOCKET_NAMES TRUE) list(APPEND STUMPLESS_SOURCES ${PROJECT_SOURCE_DIR}/src/config/abstract_socket_names_supported.c) diff --git a/include/private/config.h.in b/include/private/config.h.in index 1b9858cdd..a6d96d266 100644 --- a/include/private/config.h.in +++ b/include/private/config.h.in @@ -43,10 +43,12 @@ #cmakedefine HAVE_VSNPRINTF_S 1 #cmakedefine HAVE_WCSRTOMBS_S 1 #cmakedefine HAVE_WCSTOMBS_S 1 +#cmakedefine HAVE_SO_NOSIGPIPE 1 +#cmakedefine HAVE_MSG_NOSIGNAL 1 + /* function support checks */ #cmakedefine SUPPORT_ABSTRACT_SOCKET_NAMES 1 -#cmakedefine HAVE_DISALLOW_SIGNAL_DURING_SENDING 1 #cmakedefine SUPPORT_GETHOSTBYNAME 1 #cmakedefine SUPPORT_UNISTD_SYSCONF_GETPAGESIZE 1 #cmakedefine SUPPORT_WINDOWS_GET_NOW 1 diff --git a/include/private/config/wrapper/socket.h b/include/private/config/wrapper/socket.h index 7d4bdf302..a85da8049 100644 --- a/include/private/config/wrapper/socket.h +++ b/include/private/config/wrapper/socket.h @@ -41,14 +41,10 @@ # define config_get_local_socket_name no_abstract_socket_names_get_local_socket_name # endif -# ifdef HAVE_DISALLOW_SIGNAL_DURING_SENDING -# if defined(__APPLE__) -# define config_disallow_signal_during_sending_flag SO_NOSIGPIPE -# elif defined(__linux__) -# define config_disallow_signal_during_sending_flag MSG_NOSIGNAL -# elif defined(unix) || defined(__unix__) -# define config_disallow_signal_during_sending_flag MSG_NOSIGNAL -# endif +# ifdef HAVE_SO_NOSIGPIPE +# define config_disallow_signal_during_sending_flag SO_NOSIGPIPE +# elif defined(HAVE_MSG_NOSIGNAL) +# define config_disallow_signal_during_sending_flag MSG_NOSIGNAL # endif #endif /* __STUMPLESS_PRIVATE_CONFIG_WRAPPER_SOCKET_H */ From 35d039a549fb7846a72bc7160830538bbb263e12 Mon Sep 17 00:00:00 2001 From: Vasiliy Kiryanov Date: Thu, 24 Oct 2024 08:18:42 -0400 Subject: [PATCH 4/6] sys/socket.h include added to private/config/have_sys_socket.h --- include/private/config/have_sys_socket.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/private/config/have_sys_socket.h b/include/private/config/have_sys_socket.h index ea6c2bd0a..97be11c13 100644 --- a/include/private/config/have_sys_socket.h +++ b/include/private/config/have_sys_socket.h @@ -20,6 +20,7 @@ # define __STUMPLESS_PRIVATE_CONFIG_HAVE_SYS_SOCKET_H # include +# include # include "private/target/network.h" void From 2f436e4618c02ae4d801b2dbe59d74ee3feedfb0 Mon Sep 17 00:00:00 2001 From: Vasiliy Kiryanov Date: Thu, 24 Oct 2024 18:12:55 -0400 Subject: [PATCH 5/6] "config_disallow_signal_during_sending_flag" definition moved to have_sys_socket.h --- include/private/config/have_sys_socket.h | 6 ++++++ include/private/config/wrapper/socket.h | 6 ------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/private/config/have_sys_socket.h b/include/private/config/have_sys_socket.h index 97be11c13..00fe89bef 100644 --- a/include/private/config/have_sys_socket.h +++ b/include/private/config/have_sys_socket.h @@ -23,6 +23,12 @@ # include # include "private/target/network.h" +# ifdef HAVE_SO_NOSIGPIPE +# define config_disallow_signal_during_sending_flag SO_NOSIGPIPE +# elif defined(HAVE_MSG_NOSIGNAL) +# define config_disallow_signal_during_sending_flag MSG_NOSIGNAL +# endif + void sys_socket_close_network_target( const struct network_target *target ); diff --git a/include/private/config/wrapper/socket.h b/include/private/config/wrapper/socket.h index a85da8049..dc75596c2 100644 --- a/include/private/config/wrapper/socket.h +++ b/include/private/config/wrapper/socket.h @@ -41,10 +41,4 @@ # define config_get_local_socket_name no_abstract_socket_names_get_local_socket_name # endif -# ifdef HAVE_SO_NOSIGPIPE -# define config_disallow_signal_during_sending_flag SO_NOSIGPIPE -# elif defined(HAVE_MSG_NOSIGNAL) -# define config_disallow_signal_during_sending_flag MSG_NOSIGNAL -# endif - #endif /* __STUMPLESS_PRIVATE_CONFIG_WRAPPER_SOCKET_H */ From d4664e35917c4041a4697095df62576d22a9d41c Mon Sep 17 00:00:00 2001 From: Vasiliy Kiryanov Date: Fri, 25 Oct 2024 12:36:48 -0400 Subject: [PATCH 6/6] unnecessary include removed --- src/config/have_sys_socket.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/config/have_sys_socket.c b/src/config/have_sys_socket.c index 9893533a4..268abf57f 100644 --- a/src/config/have_sys_socket.c +++ b/src/config/have_sys_socket.c @@ -27,7 +27,6 @@ #include "private/config/wrapper/locale.h" #include "private/config/wrapper/int_connect.h" #include "private/config/wrapper/thread_safety.h" -#include "private/config/wrapper/socket.h" #include "private/error.h" #include "private/target/network.h"