summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-07-06 02:20:58 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-07-06 02:20:58 +0000
commit2e0680f22100e8fc46c8efb43ff1a1b875a9e306 (patch)
tree9d04f8151a61f0b1fd4b13e627f2882441c238e0
parent04826ff77b2b2ad7fdce4ae76ad7261bdea0b85d (diff)
* win32/win32.c (open_ifs_socket): new function.
* win32/win32.c (StartSockets, rb_w32_socket): use open_ifs_socket() instead of socket(). all changes are derived from [ruby-core:5388]. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8731 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog14
-rw-r--r--test/sdbm/test_sdbm.rb14
-rw-r--r--win32/win32.c60
3 files changed, 62 insertions, 26 deletions
diff --git a/ChangeLog b/ChangeLog
index 3dbdfe0..cb8f568 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,9 +1,17 @@
+Wed Jul 6 11:15:21 2005 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * win32/win32.c (open_ifs_socket): new function.
+
+ * win32/win32.c (StartSockets, rb_w32_socket): use open_ifs_socket()
+ instead of socket().
+ all changes are derived from [ruby-core:5388].
+
Wed Jul 6 00:15:00 2005 NARUSE, Yui <naruse@ruby-lang.org>
- * ext/nkf/nkf-utf8/{nkf.c,utf8tbl.c,config.h}:
- imported nkf.c 1.70 (support UTF-8-MAC)
+ * ext/nkf/nkf-utf8/{nkf.c,utf8tbl.c,config.h}:
+ imported nkf.c 1.70 (support UTF-8-MAC)
- * ext/nkf/lib/kconv.rb: add :utf8mac and :internalunicode
+ * ext/nkf/lib/kconv.rb: add :utf8mac and :internalunicode
Tue Jul 5 23:44:06 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
diff --git a/test/sdbm/test_sdbm.rb b/test/sdbm/test_sdbm.rb
index 58c2123..3cc75bf 100644
--- a/test/sdbm/test_sdbm.rb
+++ b/test/sdbm/test_sdbm.rb
@@ -31,14 +31,14 @@ class TestSDBM < Test::Unit::TestCase
end
end
- def have_fork?
- begin
- fork{}
- true
- rescue NotImplementedError
- false
- end
+ def have_fork?
+ begin
+ fork{}
+ true
+ rescue NotImplementedError
+ false
end
+ end
def test_version
assert(! SDBM.const_defined?(:VERSION))
diff --git a/win32/win32.c b/win32/win32.c
index 4c916f1..c8393e9 100644
--- a/win32/win32.c
+++ b/win32/win32.c
@@ -1996,21 +1996,6 @@ StartSockets(void)
atexit((void (*)(void)) WSACleanup);
-#ifndef SO_SYNCHRONOUS_NONALERT
-#define SO_SYNCHRONOUS_NONALERT 0x20
-#endif
-
- iSockOpt = SO_SYNCHRONOUS_NONALERT;
- /*
- * Enable the use of sockets as filehandles
- */
-#ifndef SO_OPENTYPE
-#define SO_OPENTYPE 0x7008
-#endif
-
- setsockopt(INVALID_SOCKET, SOL_SOCKET, SO_OPENTYPE,
- (char *)&iSockOpt, sizeof(iSockOpt));
-
main_thread.handle = GetCurrentThreadHandle();
main_thread.id = GetCurrentThreadId();
@@ -2274,6 +2259,49 @@ rb_w32_shutdown(int s, int how)
return r;
}
+static SOCKET
+open_ifs_socket(int af, int type, int protocol)
+{
+ char *s;
+ unsigned long proto_buffers_len = 0;
+ int error_code;
+ SOCKET out = INVALID_SOCKET;
+
+ if (WSAEnumProtocols(NULL, NULL, &proto_buffers_len) == SOCKET_ERROR) {
+ error_code = WSAGetLastError();
+ if (error_code == WSAENOBUFS) {
+ WSAPROTOCOL_INFO *proto_buffers;
+ int protocols_available = 0;
+
+ proto_buffers = (WSAPROTOCOL_INFO *)malloc(proto_buffers_len);
+
+ protocols_available =
+ WSAEnumProtocols(NULL, proto_buffers, &proto_buffers_len);
+ if (protocols_available != SOCKET_ERROR) {
+ int i;
+ for (i = 0; i < protocols_available; i++) {
+ WSAPROTOCOL_INFO proto_info;
+
+ if ((af != AF_UNSPEC && af != proto_buffers[i].iAddressFamily) ||
+ (type != proto_buffers[i].iSocketType) ||
+ (protocol != 0 && protocol != proto_buffers[i].iProtocol))
+ continue;
+
+ if ((proto_buffers[i].dwServiceFlags1 & XP1_IFS_HANDLES) == 0)
+ continue;
+
+ out = WSASocket(af, type, protocol, &(proto_buffers[i]), 0, 0);
+ break;
+ }
+ }
+
+ free(proto_buffers);
+ }
+ }
+
+ return out;
+}
+
#undef socket
int
@@ -2286,7 +2314,7 @@ rb_w32_socket(int af, int type, int protocol)
StartSockets();
}
RUBY_CRITICAL({
- s = socket(af, type, protocol);
+ s = open_ifs_socket(af, type, protocol);
if (s == INVALID_SOCKET) {
errno = map_errno(WSAGetLastError());
fd = -1;