[前][次][番号順一覧][スレッド一覧]

ruby-changes:6641

From: usa <ko1@a...>
Date: Tue, 22 Jul 2008 17:22:46 +0900 (JST)
Subject: [ruby-changes:6641] Ruby:r18157 (trunk): * win32/win32.c (init_func): new function to get API's address which

usa	2008-07-22 17:22:32 +0900 (Tue, 22 Jul 2008)

  New Revision: 18157

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=18157

  Log:
    * 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.

  Modified files:
    trunk/ChangeLog
    trunk/win32/win32.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 18156)
+++ ChangeLog	(revision 18157)
@@ -1,3 +1,11 @@
+Tue Jul 22 17:20:25 2008  NAKAMURA Usaku  <usa@r...>
+
+	* 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@r...>
 
 	* include/ruby/intern.h, sprintf.c (rb_str_catf, rb_str_vcatf): new
Index: win32/win32.c
===================================================================
--- win32/win32.c	(revision 18156)
+++ win32/win32.c	(revision 18157)
@@ -408,6 +408,18 @@
     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 @@
 
     init_env();
 
+    init_func();
+
     init_stdhandle();
 
     InitializeCriticalSection(&select_mutex);
@@ -2392,23 +2406,6 @@
     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 @@
 
     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)

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]