harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hinde...@apache.org
Subject svn commit: r785753 - /harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/unix/hysock.c
Date Wed, 17 Jun 2009 18:48:03 GMT
Author: hindessm
Date: Wed Jun 17 18:48:02 2009
New Revision: 785753

URL: http://svn.apache.org/viewvc?rev=785753&view=rev
Log:
Using errno in the INVALID_SOCKET case when no syscall is made is
pretty unhelpful.  I think it is simpler all round just to handle that
case up front.

Modified:
    harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/unix/hysock.c

Modified: harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/unix/hysock.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/unix/hysock.c?rev=785753&r1=785752&r2=785753&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/unix/hysock.c (original)
+++ harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/unix/hysock.c Wed
Jun 17 18:48:02 2009
@@ -640,19 +640,22 @@
 {
   I_32 rc = 0;
 
-  if ((*sock == INVALID_SOCKET) || (close (SOCKET_CAST (*sock)) < 0))
-    {
-      rc = errno;
-      HYSOCKDEBUG ("<closesocket failed, err=%d>\n", rc);
-      rc =
-        portLibrary->error_set_last_error (portLibrary, rc,
-                                           HYPORT_ERROR_SOCKET_BADSOCKET);
-    }
+  if (*sock == INVALID_SOCKET) {
+    HYSOCKDEBUGPRINT ("<closesocket failed, invalid socket>\n");
+    return portLibrary->error_set_last_error (portLibrary,
+                                              HYPORT_ERROR_SOCKET_UNIX_EBADF,
+                                              HYPORT_ERROR_SOCKET_BADSOCKET);
+  }
 
-  if (*sock != INVALID_SOCKET)
-    {
-      portLibrary->mem_free_memory (portLibrary, *sock);
-    }
+  if (close (SOCKET_CAST (*sock)) < 0) {
+    rc = errno;
+    HYSOCKDEBUG ("<closesocket failed, err=%d>\n", rc);
+    rc =
+      portLibrary->error_set_last_error (portLibrary, rc,
+                                         HYPORT_ERROR_SOCKET_BADSOCKET);
+  }
+
+  portLibrary->mem_free_memory (portLibrary, *sock);
   *sock = INVALID_SOCKET;
   return rc;
 }



Mime
View raw message