src/windows/native/sun/nio/ch/WindowsAsynchronousSocketChannelImpl.c

Print this page

        

*** 155,172 **** { SOCKET s = (SOCKET) jlong_to_ptr(socket); WSABUF* lpWsaBuf = (WSABUF*) jlong_to_ptr(address); OVERLAPPED* lpOverlapped = (OVERLAPPED*) jlong_to_ptr(ov); BOOL res; - DWORD nread = 0; DWORD flags = 0; ZeroMemory((PVOID)lpOverlapped, sizeof(OVERLAPPED)); res = WSARecv(s, lpWsaBuf, (DWORD)count, ! &nread, &flags, lpOverlapped, NULL); if (res == SOCKET_ERROR) { --- 155,171 ---- { SOCKET s = (SOCKET) jlong_to_ptr(socket); WSABUF* lpWsaBuf = (WSABUF*) jlong_to_ptr(address); OVERLAPPED* lpOverlapped = (OVERLAPPED*) jlong_to_ptr(ov); BOOL res; DWORD flags = 0; ZeroMemory((PVOID)lpOverlapped, sizeof(OVERLAPPED)); res = WSARecv(s, lpWsaBuf, (DWORD)count, ! NULL, &flags, lpOverlapped, NULL); if (res == SOCKET_ERROR) {
*** 173,193 **** int error = WSAGetLastError(); if (error == WSA_IO_PENDING) { return IOS_UNAVAILABLE; } if (error == WSAESHUTDOWN) { ! return 0; // input shutdown } JNU_ThrowIOExceptionWithLastError(env, "WSARecv failed"); return IOS_THROWN; } - if (nread == 0) { - // Handle graceful close or bytes not yet available cases - // via completion port notification. return IOS_UNAVAILABLE; - } - return (jint)nread; } JNIEXPORT jint JNICALL Java_sun_nio_ch_WindowsAsynchronousSocketChannelImpl_write0(JNIEnv* env, jclass this, jlong socket, jint count, jlong address, jlong ov) --- 172,187 ---- int error = WSAGetLastError(); if (error == WSA_IO_PENDING) { return IOS_UNAVAILABLE; } if (error == WSAESHUTDOWN) { ! return IOS_EOF; // input shutdown } JNU_ThrowIOExceptionWithLastError(env, "WSARecv failed"); return IOS_THROWN; } return IOS_UNAVAILABLE; } JNIEXPORT jint JNICALL Java_sun_nio_ch_WindowsAsynchronousSocketChannelImpl_write0(JNIEnv* env, jclass this, jlong socket, jint count, jlong address, jlong ov)
*** 194,210 **** { SOCKET s = (SOCKET) jlong_to_ptr(socket); WSABUF* lpWsaBuf = (WSABUF*) jlong_to_ptr(address); OVERLAPPED* lpOverlapped = (OVERLAPPED*) jlong_to_ptr(ov); BOOL res; - DWORD nwritten; ZeroMemory((PVOID)lpOverlapped, sizeof(OVERLAPPED)); res = WSASend(s, lpWsaBuf, (DWORD)count, ! &nwritten, 0, lpOverlapped, NULL); if (res == SOCKET_ERROR) { --- 188,203 ---- { SOCKET s = (SOCKET) jlong_to_ptr(socket); WSABUF* lpWsaBuf = (WSABUF*) jlong_to_ptr(address); OVERLAPPED* lpOverlapped = (OVERLAPPED*) jlong_to_ptr(ov); BOOL res; ZeroMemory((PVOID)lpOverlapped, sizeof(OVERLAPPED)); res = WSASend(s, lpWsaBuf, (DWORD)count, ! NULL, 0, lpOverlapped, NULL); if (res == SOCKET_ERROR) {
*** 216,222 **** return IOS_EOF; // output shutdown } JNU_ThrowIOExceptionWithLastError(env, "WSASend failed"); return IOS_THROWN; } ! return (jint)nwritten; } --- 209,215 ---- return IOS_EOF; // output shutdown } JNU_ThrowIOExceptionWithLastError(env, "WSASend failed"); return IOS_THROWN; } ! return IOS_UNAVAILABLE; }