1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* 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
This commit is contained in:
usa 2005-07-06 02:20:58 +00:00
parent 04826ff77b
commit 2e0680f221
3 changed files with 62 additions and 26 deletions

View file

@ -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>

View file

@ -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))

View file

@ -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;