rewrite socket to rk_socket of there is SOCK_CLOEXEC and there is linux, prompted by Harald Barth
This commit is contained in:
@@ -1033,6 +1033,11 @@ void
|
||||
rk_qsort(void *, size_t, size_t, int (*)(const void *, const void *));
|
||||
#endif
|
||||
|
||||
#if defined(__LINUX__) && SOCK_CLOEXEC && !defined(SOCKET_WRAPPER_REPLACE)
|
||||
#undef socket
|
||||
#define socket(_fam,_type,_prot) rk_socket(_fam,_type,_prot)
|
||||
#endif
|
||||
|
||||
#ifdef SOCKET_WRAPPER_REPLACE
|
||||
#include <socket_wrapper.h>
|
||||
#endif
|
||||
|
@@ -315,3 +315,23 @@ socket_to_fd(rk_socket_t sock, int flags)
|
||||
return _open_osfhandle((intptr_t) sock, flags);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef HEIMAL_SMALLER
|
||||
|
||||
int rk_socket(int, int, int);
|
||||
|
||||
int
|
||||
rk_socket(int domain, int type, int protocol)
|
||||
{
|
||||
int s;
|
||||
s = socket (domain, type, protocol);
|
||||
#ifdef SOCK_CLOEXEC
|
||||
if ((SOCK_CLOEXEC & protocol) && s < 0 && errno == EINVAL) {
|
||||
protocol &= ~SOCK_CLOEXEC;
|
||||
s = socket (domain, type, protocol);
|
||||
}
|
||||
#endif
|
||||
return s;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user