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

Set _DEFAULT_SOURCE to ensure SO_REUSEPORT is present #43

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sternenseemann
Copy link

This resolves an issue with glibc 2.31 I experienced where SO_REUSEPORT
would be missing because glibc only includes linux headers if __USE_MISC
is set which is caused by _DEFAULT_SOURCE in features.h.

To be precise test/main.c wouldn't compile on NixOS with glibc 2.31.

This resolves an issue with glibc 2.31 I experienced where SO_REUSEPORT
would be missing because glibc only includes linux headers if __USE_MISC
is set which is caused by _DEFAULT_SOURCE in features.h.
@sternenseemann
Copy link
Author

Adding -D_DEFAULT_SOURCE to CFLAGS also resolves the issue. Below is the offending bits/socket.h snippet for glibc 2.31 as found on my system. I'm actually not sure if this may be just a NixOS-specific oddity.

#ifdef __USE_MISC
# include <bits/types/time_t.h>
# include <asm/socket.h>
#else
# define SO_DEBUG 1
# include <bits/socket-constants.h>
#endif

asm/socket.h defines SO_REUSEPORT (it includes something from linux-headers), but bits/socket-constants.h does not.

@lindevel lindevel mentioned this pull request Mar 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant