harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From odea...@apache.org
Subject svn commit: r638328 - /harmony/enhanced/jdktools/trunk/modules/jpda/src/main/native/jdwp/windows/transport/dt_shmem/SharedMemTransport.cpp
Date Tue, 18 Mar 2008 11:36:09 GMT
Author: odeakin
Date: Tue Mar 18 04:36:08 2008
New Revision: 638328

URL: http://svn.apache.org/viewvc?rev=638328&view=rev
Log:
Add some cleanup to shared memory shutdown.

Modified:
    harmony/enhanced/jdktools/trunk/modules/jpda/src/main/native/jdwp/windows/transport/dt_shmem/SharedMemTransport.cpp

Modified: harmony/enhanced/jdktools/trunk/modules/jpda/src/main/native/jdwp/windows/transport/dt_shmem/SharedMemTransport.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/src/main/native/jdwp/windows/transport/dt_shmem/SharedMemTransport.cpp?rev=638328&r1=638327&r2=638328&view=diff
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/src/main/native/jdwp/windows/transport/dt_shmem/SharedMemTransport.cpp
(original)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/src/main/native/jdwp/windows/transport/dt_shmem/SharedMemTransport.cpp
Tue Mar 18 04:36:08 2008
@@ -73,7 +73,6 @@
     int addressSuffixInt = 1;
     HANDLE handle = NULL;
 
-    resultAddress = "";
     while (true) {
         /* Create an incrementing number to add to the end of baseAddress to create the shared
memory address */
         char addressSuffixString[5];
@@ -438,9 +437,27 @@
  * Clean up all the allocated memory in the internalEnv structure
  */
 static jdwpTransportError
-Cleanup(jdwpTransportEnv* env)
+CleanupTransport(jdwpTransportEnv* env)
 {
     /* TODO: close handles and free allocated structures */
+    sharedMemTransport *transport = ((internalEnv*)env->functions->reserved1)->transport;
+
+    if (NULL == transport) return JDWPTRANSPORT_ERROR_NONE;
+
+    /* Free the listener structure */
+    if (transport->listener) {
+        (((internalEnv*)env->functions->reserved1)->free)(transport->listener);
+    }
+
+    /* Close handles stored in the transport structure */
+    if (transport->mutexHandle) CloseHandle(transport->mutexHandle);
+    if (transport->acceptEventHandle) CloseHandle(transport->acceptEventHandle);
+    if (transport->attachEventHandle) CloseHandle(transport->attachEventHandle);
+    if (transport->sharedMemoryHandle) CloseHandle(transport->sharedMemoryHandle);
+
+    (((internalEnv*)env->functions->reserved1)->free)(transport);
+    ((internalEnv*)env->functions->reserved1)->transport = NULL;
+
     return JDWPTRANSPORT_ERROR_NONE;
 }
 
@@ -450,7 +467,10 @@
 static jdwpTransportError JNICALL 
 ShMemTran_StopListening(jdwpTransportEnv* env)
 {
-    return Cleanup(env);
+    /* Call isOpen to check if there is a connection - if not, just return */
+    if (!env->IsOpen()) return JDWPTRANSPORT_ERROR_NONE;
+
+    return CleanupTransport(env);
 } // ShMemTran_StopListening
 
 /**
@@ -459,9 +479,13 @@
 static jboolean JNICALL 
 ShMemTran_IsOpen(jdwpTransportEnv* env)
 {
-    /* TODO: return an indication of whether the shared memory stream is open */
-
-    return JNI_TRUE;
+    /* Simple check to see if transport structure and shared memory handle is initialised
*/
+    sharedMemTransport *transport = ((internalEnv*)env->functions->reserved1)->transport;
+    if ((transport) && (transport->sharedMemoryHandle)) {
+        return JNI_TRUE;
+    } else {
+        return JNI_FALSE;
+    }
 } // ShMemTran_IsOpen
 
 /**
@@ -470,7 +494,10 @@
 static jdwpTransportError JNICALL 
 ShMemTran_Close(jdwpTransportEnv* env)
 {
-    return Cleanup(env);
+    /* Call isOpen to check if there is a connection - if not, just return */
+    if (!env->IsOpen()) return JDWPTRANSPORT_ERROR_NONE;
+
+    return CleanupTransport(env);
 } // ShMemTran_Close
 
 /**



Mime
View raw message