From fbb29bc08c76c00b963e5587e8e9e4b7c580ea95 Mon Sep 17 00:00:00 2001 From: akr Date: Fri, 5 Apr 2013 16:40:36 +0000 Subject: [PATCH] * ext/socket/init.c (cloexec_accept): Fix a compile error on Debian GNU/kFreeBSD. Consider HAVE_ACCEPT4 is defined but SOCK_CLOEXEC is not defined. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40136 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ ext/socket/init.c | 6 +++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 6a59b5069e..dd6d07d4f2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Sat Apr 6 01:21:56 2013 Tanaka Akira + + * ext/socket/init.c (cloexec_accept): Fix a compile error on + Debian GNU/kFreeBSD. Consider HAVE_ACCEPT4 is defined + but SOCK_CLOEXEC is not defined. + Sat Apr 6 00:19:30 2013 Hiroshi Shirosaki * load.c (features_index_add): use rb_str_subseq() to specify C string diff --git a/ext/socket/init.c b/ext/socket/init.c index 44228d3463..33ddc05fa4 100644 --- a/ext/socket/init.c +++ b/ext/socket/init.c @@ -497,7 +497,11 @@ cloexec_accept(int socket, struct sockaddr *address, socklen_t *address_len) if (address_len) len0 = *address_len; #ifdef HAVE_ACCEPT4 if (try_accept4) { - ret = accept4(socket, address, address_len, SOCK_CLOEXEC); + int flags = 0; +#ifdef SOCK_CLOEXEC + flags |= SOCK_CLOEXEC; +#endif + ret = accept4(socket, address, address_len, flags); /* accept4 is available since Linux 2.6.28, glibc 2.10. */ if (ret != -1) { if (ret <= 2)