mirror of
				https://github.com/ruby/ruby.git
				synced 2022-11-09 12:17:21 -05:00 
			
		
		
		
	* win32/win32.c (overlapped_socket_io): avoid warnings.
* thread_win32.c (ubf_handle): refactoring. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18195 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
		
							parent
							
								
									f8f7f884c1
								
							
						
					
					
						commit
						f92478c0fb
					
				
					 3 changed files with 26 additions and 15 deletions
				
			
		| 
						 | 
				
			
			@ -1,3 +1,9 @@
 | 
			
		|||
Thu Jul 24 16:05:02 2008  NAKAMURA Usaku  <usa@ruby-lang.org>
 | 
			
		||||
 | 
			
		||||
	* win32/win32.c (overlapped_socket_io): avoid warnings.
 | 
			
		||||
 | 
			
		||||
	* thread_win32.c (ubf_handle): refactoring.
 | 
			
		||||
 | 
			
		||||
Thu Jul 24 07:01:13 2008  Nobuyoshi Nakada  <nobu@ruby-lang.org>
 | 
			
		||||
 | 
			
		||||
	* ext/win32ole/win32ole.c: got rid of improper casts.
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -519,17 +519,17 @@ native_thread_apply_priority(rb_thread_t *th)
 | 
			
		|||
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);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2448,6 +2448,7 @@ overlapped_socket_io(BOOL input, int fd, char *buf, int len, int flags,
 | 
			
		|||
	});
 | 
			
		||||
    }
 | 
			
		||||
    else {
 | 
			
		||||
	DWORD size;
 | 
			
		||||
	wbuf.len = len;
 | 
			
		||||
	wbuf.buf = buf;
 | 
			
		||||
	memset(&wol, 0, sizeof(wol));
 | 
			
		||||
| 
						 | 
				
			
			@ -2456,29 +2457,33 @@ overlapped_socket_io(BOOL input, int fd, char *buf, int len, int flags,
 | 
			
		|||
	    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 @@ overlapped_socket_io(BOOL input, int fd, char *buf, int len, int flags,
 | 
			
		|||
		break;
 | 
			
		||||
	    }
 | 
			
		||||
	}
 | 
			
		||||
	else if (ret == SOCKET_ERROR) {
 | 
			
		||||
	else {
 | 
			
		||||
	    errno = map_errno(err);
 | 
			
		||||
	    r = -1;
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue