From f3a1c3253efa3a8577018e4d5bdae143a5d41a47 Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Fri, 4 Jun 2010 18:45:13 -0600 Subject: [PATCH] use closesocket instead of close on Windows MinGW's close apparently does nothing, and MSVC's headers don't even declare it, so closesocket is the way to go. --- classpath/java-nio.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/classpath/java-nio.cpp b/classpath/java-nio.cpp index 4b052d98b1..b8a2222bcb 100644 --- a/classpath/java-nio.cpp +++ b/classpath/java-nio.cpp @@ -56,13 +56,15 @@ charsToArray(JNIEnv* e, const char* s) return a; } -#ifdef _MSC_VER inline void -close(int socket) +doClose(int socket) { +#ifdef PLATFORM_WINDOWS closesocket(socket); -} +#else + close(socket); #endif +} inline jbyteArray errorString(JNIEnv* e, int n) @@ -528,7 +530,7 @@ Java_java_nio_channels_SocketChannel_natCloseSocket(JNIEnv *, jclass, jint socket) { - close(socket); + doClose(socket); } namespace { @@ -562,9 +564,9 @@ class Pipe { } void dispose() { - if (listener_ >= 0) ::close(listener_); - if (reader_ >= 0) ::close(reader_); - if (writer_ >= 0) ::close(writer_); + if (listener_ >= 0) ::doClose(listener_); + if (reader_ >= 0) ::doClose(reader_); + if (writer_ >= 0) ::doClose(writer_); } bool connected() { @@ -615,8 +617,8 @@ class Pipe { } void dispose() { - ::close(pipe[0]); - ::close(pipe[1]); + ::doClose(pipe[0]); + ::doClose(pipe[1]); open_ = false; }