ext/kgio/missing/accept4.h in kgio-2.0.0 vs ext/kgio/missing/accept4.h in kgio-2.1.0
- old
+ new
@@ -11,14 +11,15 @@
# else
# define SOCK_CLOEXEC FD_CLOEXEC
# define SOCK_NONBLOCK O_NONBLOCK
# endif
# endif
+#endif /* !HAVE_ACCEPT4 */
/* accept4() is currently a Linux-only goodie */
static int
-accept4(int sockfd, struct sockaddr *addr, socklen_t *addrlen, int flags)
+my_accept4(int sockfd, struct sockaddr *addr, socklen_t *addrlen, int flags)
{
int fd = accept(sockfd, addr, addrlen);
if (fd >= 0) {
if ((flags & SOCK_CLOEXEC) == SOCK_CLOEXEC)
@@ -47,6 +48,12 @@
*/
errno = 0;
}
return fd;
}
-#endif /* !HAVE_ACCEPT4 */
+
+typedef int accept_fn_t(int, struct sockaddr *, socklen_t *, int);
+#ifdef HAVE_ACCEPT4
+static accept_fn_t *accept_fn = accept4;
+#else
+static accept_fn_t *accept_fn = my_accept4;
+#endif