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

ruby-changes:38424

From: usa <ko1@a...>
Date: Sat, 16 May 2015 20:00:15 +0900 (JST)
Subject: [ruby-changes:38424] usa:r50505 (trunk): * win32/win32.c (rb_w32_accept): simplified.

usa	2015-05-16 20:00:07 +0900 (Sat, 16 May 2015)

  New Revision: 50505

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

  Log:
    * win32/win32.c (rb_w32_accept): simplified.

  Modified files:
    trunk/ChangeLog
    trunk/win32/win32.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 50504)
+++ ChangeLog	(revision 50505)
@@ -1,3 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sat May 16 19:59:24 2015  NAKAMURA Usaku  <usa@r...>
+
+	* win32/win32.c (rb_w32_accept): simplified.
+
 Fri May 15 18:28:20 2015  Nobuyoshi Nakada  <nobu@r...>
 
 	* array.c (rb_ary_assoc, rb_ary_rassoc): [DOC] the result when key
Index: win32/win32.c
===================================================================
--- win32/win32.c	(revision 50504)
+++ win32/win32.c	(revision 50505)
@@ -3027,26 +3027,19 @@ rb_w32_accept(int s, struct sockaddr *ad https://github.com/ruby/ruby/blob/trunk/win32/win32.c#L3027
 	StartSockets();
     }
     RUBY_CRITICAL({
-	HANDLE h = CreateFile("NUL", 0, 0, NULL, OPEN_ALWAYS, 0, NULL);
-	fd = rb_w32_open_osfhandle((intptr_t)h, O_RDWR|O_BINARY|O_NOINHERIT);
-	if (fd != -1) {
-	    r = accept(TO_SOCKET(s), addr, addrlen);
-	    if (r != INVALID_SOCKET) {
-		SetHandleInformation((HANDLE)r, HANDLE_FLAG_INHERIT, 0);
-		rb_acrt_lowio_lock_fh(fd);
-		_set_osfhnd(fd, r);
-		rb_acrt_lowio_unlock_fh(fd);
-		CloseHandle(h);
+	r = accept(TO_SOCKET(s), addr, addrlen);
+	if (r != INVALID_SOCKET) {
+	    SetHandleInformation((HANDLE)r, HANDLE_FLAG_INHERIT, 0);
+	    fd = rb_w32_open_osfhandle((intptr_t)r, O_RDWR|O_BINARY|O_NOINHERIT);
+	    if (fd != -1)
 		socklist_insert(r, 0);
-	    }
-	    else {
-		errno = map_errno(WSAGetLastError());
-		close(fd);
-		fd = -1;
-	    }
+	    else
+		closesocket(r);
+	}
+	else {
+	    errno = map_errno(WSAGetLastError());
+	    fd = -1;
 	}
-	else
-	    CloseHandle(h);
     });
     return fd;
 }

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

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