ruby-changes:21590
From: akr <ko1@a...>
Date: Sat, 5 Nov 2011 17:57:13 +0900 (JST)
Subject: [ruby-changes:21590] akr:r33639 (trunk): * ext/socket/init.c (rsock_socket0): don't clear try_sock_cloexec if
akr 2011-11-05 17:56:50 +0900 (Sat, 05 Nov 2011) New Revision: 33639 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=33639 Log: * ext/socket/init.c (rsock_socket0): don't clear try_sock_cloexec if SOCK_CLOEXEC is not a reason for EINVAL. Modified files: trunk/ChangeLog trunk/ext/socket/init.c Index: ChangeLog =================================================================== --- ChangeLog (revision 33638) +++ ChangeLog (revision 33639) @@ -1,3 +1,8 @@ +Sat Nov 5 17:55:52 2011 Tanaka Akira <akr@f...> + + * ext/socket/init.c (rsock_socket0): don't clear try_sock_cloexec if + SOCK_CLOEXEC is not a reason for EINVAL. + Sat Nov 5 16:27:52 2011 Kazuki Tsujimoto <kazuki@c...> * ext/pathname/lib/pathname.rb, ext/tk/lib/multi-tk.rb, Index: ext/socket/init.c =================================================================== --- ext/socket/init.c (revision 33638) +++ ext/socket/init.c (revision 33639) @@ -240,34 +240,30 @@ } static int -rsock_socket0(int domain, int type0, int proto) +rsock_socket0(int domain, int type, int proto) { - int ret, type; + int ret; #ifdef SOCK_CLOEXEC static int try_sock_cloexec = 1; - if (try_sock_cloexec) - type = type0|SOCK_CLOEXEC; - else - type = type0; - retry_without_sock_cloexec:; + if (try_sock_cloexec) { + ret = socket(domain, type|SOCK_CLOEXEC, proto); + if (ret == -1 && errno == EINVAL) { + /* SOCK_CLOEXEC is available since Linux 2.6.27. Linux 2.6.18 fails with EINVAL */ + ret = socket(domain, type, proto); + if (ret != -1) { + try_sock_cloexec = 0; + } + } + } + else { + ret = socket(domain, type, proto); + } #else - type = type0; -#endif - ret = socket(domain, type, proto); - - if (ret == -1) { -#ifdef SOCK_CLOEXEC - /* SOCK_CLOEXEC is available since Linux 2.6.27. Linux 2.6.18 fails with EINVAL */ - if (try_sock_cloexec && errno == EINVAL) { - try_sock_cloexec = 0; - type = type0; - goto retry_without_sock_cloexec; - } #endif + if (ret == -1) return -1; - } rb_fd_fix_cloexec(ret); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/