* win32/win32.c (init_func): new function to get API's address which
is often used and not supported on all Windows. * win32/win32.c (overlapped_socket_io): shouldn't use overlapped I/O if CancelIo() is not supported. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18157 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
70b317b9da
commit
ee560dc68f
@ -1,3 +1,11 @@
|
||||
Tue Jul 22 17:20:25 2008 NAKAMURA Usaku <usa@ruby-lang.org>
|
||||
|
||||
* win32/win32.c (init_func): new function to get API's address which
|
||||
is often used and not supported on all Windows.
|
||||
|
||||
* win32/win32.c (overlapped_socket_io): shouldn't use overlapped I/O if
|
||||
CancelIo() is not supported.
|
||||
|
||||
Tue Jul 22 16:47:57 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* include/ruby/intern.h, sprintf.c (rb_str_catf, rb_str_vcatf): new
|
||||
|
@ -408,6 +408,18 @@ init_env(void)
|
||||
NTLoginName = strdup(env);
|
||||
}
|
||||
|
||||
|
||||
typedef BOOL (WINAPI *cancel_io_t)(HANDLE);
|
||||
static cancel_io_t cancel_io = NULL;
|
||||
|
||||
static void
|
||||
init_func(void)
|
||||
{
|
||||
if (!cancel_io)
|
||||
cancel_io = (cancel_io_t)GetProcAddress(GetModuleHandle("kernel32"),
|
||||
"CancelIo");
|
||||
}
|
||||
|
||||
static void init_stdhandle(void);
|
||||
|
||||
#if _MSC_VER >= 1400
|
||||
@ -485,6 +497,8 @@ rb_w32_sysinit(int *argc, char ***argv)
|
||||
|
||||
init_env();
|
||||
|
||||
init_func();
|
||||
|
||||
init_stdhandle();
|
||||
|
||||
InitializeCriticalSection(&select_mutex);
|
||||
@ -2392,23 +2406,6 @@ rb_w32_listen(int s, int backlog)
|
||||
return r;
|
||||
}
|
||||
|
||||
typedef BOOL (WINAPI *cancel_io_t)(HANDLE);
|
||||
static inline void
|
||||
cancel_io(HANDLE f)
|
||||
{
|
||||
static cancel_io_t func = NULL;
|
||||
if (!func) {
|
||||
func = (cancel_io_t)GetProcAddress(GetModuleHandle("kernel32"),
|
||||
"CancelIo");
|
||||
if (!func)
|
||||
func = (cancel_io_t)-1;
|
||||
}
|
||||
else if (func != (cancel_io_t)-1)
|
||||
func(f);
|
||||
/* Win9x and NT3.x doesn't have CancelIo().
|
||||
We expect to cancel the I/O by close or ending the thread */
|
||||
}
|
||||
|
||||
#undef recv
|
||||
#undef recvfrom
|
||||
#undef send
|
||||
@ -2432,7 +2429,7 @@ overlapped_socket_io(BOOL input, int fd, char *buf, int len, int flags,
|
||||
|
||||
s = TO_SOCKET(fd);
|
||||
st_lookup(socklist, (st_data_t)s, (st_data_t *)&mode);
|
||||
if (mode & O_NONBLOCK) {
|
||||
if (!cancel_io || (mode & O_NONBLOCK)) {
|
||||
RUBY_CRITICAL({
|
||||
if (input) {
|
||||
if (addr && addrlen)
|
||||
|
Loading…
x
Reference in New Issue
Block a user