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

have_sys_socket.c: support for MacOS added #470

merged 6 commits into from
Oct 25, 2024

Conversation

vasiliyk
Copy link
Contributor

Added support for MacOS:

  1. CMakeList.txt: check if system is MacOS or Unix/Linux and set "SUPPORT_DISALLOW_SIGNAL_DURING_SENDING"
  2. config.h.in: set SUPPORT_DISALLOW_SIGNAL_DURING_SENDING to be accessible for C preprocessor.
  3. socket.h: if SUPPORT_DISALLOW_SIGNAL_DURING_SENDING is defined set "config_disallow_signal_during_sending_flag" flag to "SO_NOSIGPIPE" or "MSG_NOSIGNAL"
  4. updated "sys_socket_sendto_tcp_target" and "sys_socket_sendto_udp_target" procedures of have_sys_socket.c to use flag config_disallow_signal_during_sending_flag

@goatshriek goatshriek self-assigned this Oct 23, 2024
Copy link
Owner

@goatshriek goatshriek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is almost there, just one change outlined below to use CMake's check_symbol_exists function to instead determine what symbols are available for use, so that the platform detection doesn't become as much of a dependency for this to work as intended.

CMakeLists.txt Outdated Show resolved Hide resolved
include/private/config.h.in Outdated Show resolved Hide resolved
include/private/config/wrapper/socket.h Outdated Show resolved Hide resolved
HAVE_DISALLOW_SIGNAL_DURING_SENDING definition is used instead of SUPPORT_DISALLOW_SIGNAL_DURING_SENDING
@vasiliyk
Copy link
Contributor Author

Joel, thank you for review. The code is updated based on your comments.

include/private/config.h.in Outdated Show resolved Hide resolved
include/private/config/wrapper/socket.h Outdated Show resolved Hide resolved
@vasiliyk
Copy link
Contributor Author

Joel, the code was updated based on the last recommendations. Thank you!

Copy link

codecov bot commented Oct 24, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.60%. Comparing base (1d2df58) to head (d4664e3).
Report is 3 commits behind head on latest.

Additional details and impacted files
@@            Coverage Diff             @@
##           latest     #470      +/-   ##
==========================================
+ Coverage   90.59%   90.60%   +0.01%     
==========================================
  Files          47       47              
  Lines        4379     4385       +6     
  Branches      587      587              
==========================================
+ Hits         3967     3973       +6     
  Misses        279      279              
  Partials      133      133              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@goatshriek
Copy link
Owner

Thanks for sticking with this one! There is just one last change needed - an include sys/socket.h is needed for the wrapped symbols, which is why the static analyzer has failed. It would probably be best to move the wrapper #defines to include/private/config/have_sys_socket.h to ensure this header is available for include, but I can take care of this later if you'd prefer to be done. At a minimum, adding this include should resolve the static analysis errors.

@vasiliyk
Copy link
Contributor Author

Joel, I added sys/socket.h include to include/private/config/have_sys_socket.h as you suggested.

@goatshriek
Copy link
Owner

Sorry, I should have also mentioned that you'll need to move the code from ...wrapper/socket.h to have_sys_socket.h as well.

@vasiliyk
Copy link
Contributor Author

No problem, I have moved the definition of config_disallow_signal_during_sending_flag from ...wrapper/socket.h to have_sys_socket.h as well.

Copy link
Owner

@goatshriek goatshriek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one more failing check now - there is an include that is no longer necessary with the last refactoring. I believe once you take out this line it should be good to go.

Thanks again for your patience with this!

src/config/have_sys_socket.c Outdated Show resolved Hide resolved
@vasiliyk
Copy link
Contributor Author

Joel, I have removed unnecessary include.

@goatshriek goatshriek merged commit 5f68b8f into goatshriek:latest Oct 25, 2024
56 checks passed
@goatshriek goatshriek added the hacktoberfest-accepted accepted work that is valid for hacktoberfest label Oct 25, 2024
@goatshriek
Copy link
Owner

Thanks very much for not only raising this issue but putting together a fix and sticking with it through the review process! Portability is a primary goal of this project and it's always great to see progress made towards that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hacktoberfest-accepted accepted work that is valid for hacktoberfest
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants