summaryrefslogtreecommitdiff
path: root/ext/socket/init.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-02-04 06:19:40 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-02-04 06:19:40 +0000
commita9cbe8c7219759aace315c7671bbb1681d0ae4b0 (patch)
tree20c2c953da0f2239cc63780fdc087dd5160aa4b2 /ext/socket/init.c
parent523292d61294d4496c593ad530eb520b469c0f02 (diff)
init.c: declaration-after-statement
* ext/socket/init.c (cloexec_accept): fix declaration-after-statement. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39040 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/socket/init.c')
-rw-r--r--ext/socket/init.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/ext/socket/init.c b/ext/socket/init.c
index 43d21cc..4c1d17d 100644
--- a/ext/socket/init.c
+++ b/ext/socket/init.c
@@ -482,9 +482,11 @@ cloexec_accept(int socket, struct sockaddr *address, socklen_t *address_len)
{
int ret;
socklen_t len0 = 0;
- if (address_len) len0 = *address_len;
#ifdef HAVE_ACCEPT4
static int try_accept4 = 1;
+#endif
+ if (address_len) len0 = *address_len;
+#ifdef HAVE_ACCEPT4
if (try_accept4) {
ret = accept4(socket, address, address_len, SOCK_CLOEXEC);
/* accept4 is available since Linux 2.6.28, glibc 2.10. */
@@ -494,17 +496,13 @@ cloexec_accept(int socket, struct sockaddr *address, socklen_t *address_len)
if (address_len && len0 < *address_len) *address_len = len0;
return ret;
}
- if (errno == ENOSYS) {
- try_accept4 = 0;
- ret = accept(socket, address, address_len);
+ if (errno != ENOSYS) {
+ return -1;
}
+ try_accept4 = 0;
}
- else {
- ret = accept(socket, address, address_len);
- }
-#else
- ret = accept(socket, address, address_len);
#endif
+ ret = accept(socket, address, address_len);
if (ret == -1) return -1;
if (address_len && len0 < *address_len) *address_len = len0;
rb_maygvl_fd_fix_cloexec(ret);