Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

have_sys_socket.c: support for MacOS added #470

Merged
merged 6 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
vasiliyk marked this conversation as resolved.
Show resolved Hide resolved
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)
Expand Down
1 change: 1 addition & 0 deletions include/private/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@

/* function support checks */
#cmakedefine SUPPORT_ABSTRACT_SOCKET_NAMES 1
#cmakedefine SUPPORT_DISALLOW_SIGNAL_DURING_SENDING 1
vasiliyk marked this conversation as resolved.
Show resolved Hide resolved
#cmakedefine SUPPORT_GETHOSTBYNAME 1
#cmakedefine SUPPORT_UNISTD_SYSCONF_GETPAGESIZE 1
#cmakedefine SUPPORT_WINDOWS_GET_NOW 1
Expand Down
10 changes: 10 additions & 0 deletions include/private/config/wrapper/socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -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__)
vasiliyk marked this conversation as resolved.
Show resolved Hide resolved
# 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

vasiliyk marked this conversation as resolved.
Show resolved Hide resolved
#endif /* __STUMPLESS_PRIVATE_CONFIG_WRAPPER_SOCKET_H */
5 changes: 3 additions & 2 deletions src/config/have_sys_socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
goatshriek marked this conversation as resolved.
Show resolved Hide resolved
#include "private/error.h"
#include "private/target/network.h"

Expand Down Expand Up @@ -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,
Expand All @@ -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 );
Expand Down