Skip to content

Commit

Permalink
Add Linux and OpenBSD support
Browse files Browse the repository at this point in the history
  • Loading branch information
devnexen committed Apr 13, 2022
1 parent e5b7e84 commit b7adc13
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/anet.c
Expand Up @@ -686,7 +686,7 @@ int anetPipe(int fds[2], int read_flags, int write_flags) {
int anetSockId(char *err, int fd, uint32_t id)
{
#ifdef HAVE_SOCKOPTID
if (setsockopt(fd, SOL_SOCKET, SO_USER_COOKIE, (void *)&id, sizeof(id)) == -1) {
if (setsockopt(fd, SOL_SOCKET, SOCKOPTID, (void *)&id, sizeof(id)) == -1) {
anetSetError(err, "setsockopt: %s", strerror(errno));
return ANET_ERR;
}
Expand Down
8 changes: 8 additions & 0 deletions src/config.h
Expand Up @@ -80,6 +80,8 @@
/* MSG_NOSIGNAL. */
#ifdef __linux__
#define HAVE_MSG_NOSIGNAL 1
#define HAVE_SOCKOPTID 1
#define SOCKOPTID SO_MARK
#endif

/* Test for polling API */
Expand Down Expand Up @@ -115,6 +117,12 @@

#if defined(__FreeBSD__)
#define HAVE_SOCKOPTID 1
#define SOCKOPTID SO_USER_COOKIE
#endif

#if defined(__OpenBSD__)
#define HAVE_SOCKOPTID 1
#define SOCKOPTID SO_RTABLE
#endif

#if __GNUC__ >= 4
Expand Down

0 comments on commit b7adc13

Please sign in to comment.