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

ruby-changes:6679

From: usa <ko1@a...>
Date: Thu, 24 Jul 2008 16:06:06 +0900 (JST)
Subject: [ruby-changes:6679] Ruby:r18195 (trunk): * win32/win32.c (overlapped_socket_io): avoid warnings.

usa	2008-07-24 16:05:49 +0900 (Thu, 24 Jul 2008)

  New Revision: 18195

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

  Log:
    * win32/win32.c (overlapped_socket_io): avoid warnings.
    
    * thread_win32.c (ubf_handle): refactoring.

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

Index: thread_win32.c
===================================================================
--- thread_win32.c	(revision 18194)
+++ thread_win32.c	(revision 18195)
@@ -519,17 +519,17 @@
 static void
 ubf_handle(void *ptr)
 {
-    static int checked = 0;
     typedef BOOL (WINAPI *cancel_io_func_t)(HANDLE);
     static cancel_io_func_t cancel_func = NULL;
     rb_thread_t *th = (rb_thread_t *)ptr;
     thread_debug("ubf_handle: %p\n", th);
 
-    if (!checked) {
+    if (!cancel_func) {
 	cancel_func = (cancel_io_func_t)GetProcAddress(GetModuleHandle("kernel32"), "CancelSynchronousIo");
-	checked = 1;
+	if (!cancel_func)
+	    cancel_func = (cancel_io_func_t)-1;
     }
-    if (cancel_func)
+    if (cancel_func != (cancel_io_func_t)-1)
 	cancel_func((HANDLE)th->thread_id);
 
     w32_set_event(th->native_thread_data.interrupt_event);
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 18194)
+++ ChangeLog	(revision 18195)
@@ -1,3 +1,9 @@
+Thu Jul 24 16:05:02 2008  NAKAMURA Usaku  <usa@r...>
+
+	* win32/win32.c (overlapped_socket_io): avoid warnings.
+
+	* thread_win32.c (ubf_handle): refactoring.
+
 Thu Jul 24 07:01:13 2008  Nobuyoshi Nakada  <nobu@r...>
 
 	* ext/win32ole/win32ole.c: got rid of improper casts.
Index: win32/win32.c
===================================================================
--- win32/win32.c	(revision 18194)
+++ win32/win32.c	(revision 18195)
@@ -2448,6 +2448,7 @@
 	});
     }
     else {
+	DWORD size;
 	wbuf.len = len;
 	wbuf.buf = buf;
 	memset(&wol, 0, sizeof(wol));
@@ -2456,29 +2457,33 @@
 	    if (input) {
 		flg = flags;
 		if (addr && addrlen)
-		    ret = WSARecvFrom(s, &wbuf, 1, &r, &flg, addr, addrlen, &wol,
-				      NULL);
+		    ret = WSARecvFrom(s, &wbuf, 1, &size, &flg, addr, addrlen,
+				      &wol, NULL);
 		else
-		    ret = WSARecv(s, &wbuf, 1, &r, &flg, &wol, NULL);
+		    ret = WSARecv(s, &wbuf, 1, &size, &flg, &wol, NULL);
 	    }
 	    else {
 		if (addr && addrlen)
-		    ret = WSASendTo(s, &wbuf, 1, &r, flags, addr, *addrlen, &wol,
-				    NULL);
+		    ret = WSASendTo(s, &wbuf, 1, &size, flags, addr, *addrlen,
+				    &wol, NULL);
 		else
-		    ret = WSASend(s, &wbuf, 1, &r, flags, &wol, NULL);
+		    ret = WSASend(s, &wbuf, 1, &size, flags, &wol, NULL);
 	    }
-	    err = WSAGetLastError();
 	});
 
-	if (ret == SOCKET_ERROR && err == WSA_IO_PENDING) {
+	if (ret != SOCKET_ERROR) {
+	    r = size;
+	}
+	else if ((err = WSAGetLastError()) == WSA_IO_PENDING) {
 	    switch (rb_w32_wait_events_blocking(&wol.hEvent, 1, INFINITE)) {
 	      case WAIT_OBJECT_0:
 		RUBY_CRITICAL(
-		    ret = WSAGetOverlappedResult(s, &wol, &r, TRUE, &flg)
+		    ret = WSAGetOverlappedResult(s, &wol, &size, TRUE, &flg)
 		    );
-		if (ret)
+		if (ret) {
+		    r = size;
 		    break;
+		}
 		/* thru */
 	      default:
 		errno = map_errno(err);
@@ -2490,7 +2495,7 @@
 		break;
 	    }
 	}
-	else if (ret == SOCKET_ERROR) {
+	else {
 	    errno = map_errno(err);
 	    r = -1;
 	}

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

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