harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From apetre...@apache.org
Subject svn commit: r542962 - in /harmony/enhanced/classlib/trunk/modules: archive/src/main/java/java/util/zip/ archive/src/main/native/archive/shared/ luni/src/main/native/include/unix/ luni/src/main/native/include/windows/
Date Wed, 30 May 2007 22:36:33 GMT
Author: apetrenko
Date: Wed May 30 15:36:30 2007
New Revision: 542962

URL: http://svn.apache.org/viewvc?view=rev&rev=542962
Log:
Patch for HARMONY-3054 "[classlib][archive] EUT intermittently fail in org.eclipse.jdt.core.tests.compiler.parser.TestAll"

Modified:
    harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/ZipFile.java
    harmony/enhanced/classlib/trunk/modules/archive/src/main/native/archive/shared/archiveglob.c
    harmony/enhanced/classlib/trunk/modules/archive/src/main/native/archive/shared/zip.c
    harmony/enhanced/classlib/trunk/modules/archive/src/main/native/archive/shared/zip.h
    harmony/enhanced/classlib/trunk/modules/luni/src/main/native/include/unix/jclprots.h
    harmony/enhanced/classlib/trunk/modules/luni/src/main/native/include/windows/jclprots.h

Modified: harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/ZipFile.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/ZipFile.java?view=diff&rev=542962&r1=542961&r2=542962
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/ZipFile.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/ZipFile.java
Wed May 30 15:36:30 2007
@@ -134,10 +134,10 @@
 	/**
 	 * Closes this ZipFile.
 	 */
-	public void close() throws IOException {
-		if (fileName != null) {
+	public synchronized void close() throws IOException {
+		if (descriptor != -1 && fileName != null) {
 			// Only close initialized instances
-			closeZipImpl();
+			closeZipImpl(descriptor);
 			if ((mode & OPEN_DELETE) != 0) {
 				AccessController.doPrivileged(new PrivilegedAction<Object>() {
 					public Object run() {
@@ -147,7 +147,7 @@
 				});
 			}
 		}
-}
+	}
 
 	/**
 	 * Answers all of the zip entries contained in this ZipFile.
@@ -204,7 +204,7 @@
 
 	private synchronized native int openZipImpl(byte[] fileName1);
 
-	private synchronized native void closeZipImpl() throws IOException;
+	private native void closeZipImpl(long descriptor1) throws IOException;
 
 	private native ZipEntry getEntryImpl(long descriptor1, String entryName);
 

Modified: harmony/enhanced/classlib/trunk/modules/archive/src/main/native/archive/shared/archiveglob.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/archive/src/main/native/archive/shared/archiveglob.c?view=diff&rev=542962&r1=542961&r2=542962
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/archive/src/main/native/archive/shared/archiveglob.c
(original)
+++ harmony/enhanced/classlib/trunk/modules/archive/src/main/native/archive/shared/archiveglob.c
Wed May 30 15:36:30 2007
@@ -124,6 +124,7 @@
                   jclZipFile = next;
                 }
               jclmem_free_memory (env, zipfileHandles);
+              MUTEX_DESTROY (zipfileHandles->mutex);
             }
 
           /* Free any global references */

Modified: harmony/enhanced/classlib/trunk/modules/archive/src/main/native/archive/shared/zip.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/archive/src/main/native/archive/shared/zip.c?view=diff&rev=542962&r1=542961&r2=542962
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/archive/src/main/native/archive/shared/zip.c (original)
+++ harmony/enhanced/classlib/trunk/modules/archive/src/main/native/archive/shared/zip.c Wed
May 30 15:36:30 2007
@@ -96,11 +96,13 @@
    * free this on UnLoad if its not already free'd.
    */
   zipfileHandles = JCL_CACHE_GET (env, zipfile_handles);
+  MUTEX_ENTER (zipfileHandles->mutex);
   jclZipFile->last = (JCLZipFile *) zipfileHandles;
   jclZipFile->next = zipfileHandles->next;
   if (zipfileHandles->next != NULL)
     zipfileHandles->next->last = jclZipFile;
   zipfileHandles->next = jclZipFile;
+  MUTEX_EXIT (zipfileHandles->mutex);
 
   (*env)->SetLongField (env, recv,
                         JCL_CACHE_GET (env,
@@ -119,6 +121,7 @@
   PORT_ACCESS_FROM_ENV (env);
 
   I_32 retval;
+  I_32 extraval;
   HyZipFile *zipFile;
   HyZipEntry zipEntry;
   jobject java_ZipEntry, extra;
@@ -161,19 +164,26 @@
   extra = NULL;
   if (zipEntry.extraFieldLength > 0)
     {
+      extraval =
 #ifndef HY_ZIP_API
-      zip_getZipEntryExtraField (PORTLIB, zipFile, &zipEntry, NULL,
+        zip_getZipEntryExtraField (PORTLIB, zipFile, &zipEntry, NULL,
 #else /* HY_ZIP_API */
-	  zipFuncs->zip_getZipEntryExtraField (VMI, zipFile, &zipEntry, NULL,
+	    zipFuncs->zip_getZipEntryExtraField (VMI, zipFile, &zipEntry, NULL,
 #endif /* HY_ZIP_API */
                                  zipEntry.extraFieldLength);
-      if (zipEntry.extraField == NULL)
+      if (extraval || zipEntry.extraField == NULL)
         {
 #ifndef HY_ZIP_API
           zip_freeZipEntry (PORTLIB, &zipEntry);
 #else /* HY_ZIP_API */
     	  zipFuncs->zip_freeZipEntry (VMI, &zipEntry);
 #endif /* HY_ZIP_API */
+          if (extraval)
+            {
+              char buf[50];
+              sprintf (buf, "Error %d getting extra field of zip entry", extraval);
+              throwNewInternalError (env, buf);
+            }
           return (jobject) NULL;
         }
       extra = ((*env)->NewByteArray (env, zipEntry.extraFieldLength));
@@ -221,7 +231,7 @@
 }
 
 JNIEXPORT void JNICALL
-Java_java_util_zip_ZipFile_closeZipImpl (JNIEnv * env, jobject recv)
+Java_java_util_zip_ZipFile_closeZipImpl (JNIEnv * env, jobject recv, jlong zipPointer)
 {
   PORT_ACCESS_FROM_ENV (env);
 #ifdef HY_ZIP_API
@@ -229,14 +239,13 @@
 #endif /* HY_ZIP_API */
 
   I_32 retval = 0;
-  JCLZipFile *jclZipFile;
-  jfieldID descriptorFID =
-    JCL_CACHE_GET (env, FID_java_util_zip_ZipFile_descriptor);
+  jfieldID descriptorFID;
+  JCLZipFileLink *zipfileHandles;
+  JCLZipFile *jclZipFile = (JCLZipFile *) (IDATA) zipPointer;
 #ifdef HY_ZIP_API
   HyZipFunctionTable *zipFuncs = (*VMI)->GetZipFunctions(VMI);
 #endif /* HY_ZIP_API */
 
-  jclZipFile = (JCLZipFile *) (IDATA) (*env)->GetLongField (env, recv, descriptorFID);
   if (jclZipFile != (void *) -1)
     {
       retval =
@@ -245,13 +254,17 @@
 #else /* HY_ZIP_API */
         zipFuncs->zip_closeZipFile (VMI, &(jclZipFile->hyZipFile));
 #endif /* HY_ZIP_API */
+      descriptorFID = JCL_CACHE_GET (env, FID_java_util_zip_ZipFile_descriptor);
       (*env)->SetLongField (env, recv, descriptorFID, -1);
 
       /* Free the zip struct */
+	  zipfileHandles = JCL_CACHE_GET (env, zipfile_handles);
+      MUTEX_ENTER (zipfileHandles->mutex);
       if (jclZipFile->last != NULL)
         jclZipFile->last->next = jclZipFile->next;
       if (jclZipFile->next != NULL)
         jclZipFile->next->last = jclZipFile->last;
+      MUTEX_EXIT (zipfileHandles->mutex);
 
       jclmem_free_memory (env, jclZipFile);
       if (retval)
@@ -323,6 +336,7 @@
     return;
   zipfileHandles->last = NULL;
   zipfileHandles->next = NULL;
+  MUTEX_INIT (zipfileHandles->mutex);
   JCL_CACHE_SET (env, zipfile_handles, zipfileHandles);
 }
 
@@ -368,6 +382,7 @@
 #endif /* HY_ZIP_API */
 
   I_32 retval;
+  I_32 extraval;
   HyZipFile *zipFile;
   HyZipEntry zipEntry;
   jobject java_ZipEntry, extra;
@@ -419,12 +434,28 @@
   extra = NULL;
   if (zipEntry.extraFieldLength > 0)
     {
+      extraval =
 #ifndef HY_ZIP_API
-      zip_getZipEntryExtraField (PORTLIB, zipFile, &zipEntry, NULL,
+        zip_getZipEntryExtraField (PORTLIB, zipFile, &zipEntry, NULL,
 #else /* HY_ZIP_API */
-      zipFuncs->zip_getZipEntryExtraField (VMI, zipFile, &zipEntry, NULL,
+        zipFuncs->zip_getZipEntryExtraField (VMI, zipFile, &zipEntry, NULL,
 #endif /* HY_ZIP_API */
                                  zipEntry.extraFieldLength);
+      if (extraval || zipEntry.extraField == NULL)
+        {
+#ifndef HY_ZIP_API
+          zip_freeZipEntry (PORTLIB, &zipEntry);
+#else /* HY_ZIP_API */
+    	  zipFuncs->zip_freeZipEntry (VMI, &zipEntry);
+#endif /* HY_ZIP_API */
+          if (extraval)
+            {
+              char buf[50];
+              sprintf (buf, "Error %d getting extra field of zip entry", extraval);
+              throwNewInternalError (env, buf);
+            }
+          return (jobject) NULL;
+        }
       extra = ((*env)->NewByteArray (env, zipEntry.extraFieldLength));
       if (((*env)->ExceptionCheck (env)))
         {
@@ -432,7 +463,7 @@
 #ifndef HY_ZIP_API
           zip_freeZipEntry (PORTLIB, &zipEntry);
 #else /* HY_ZIP_API */
-          zipFuncs->zip_freeZipEntry (VMI, &zipEntry);
+          zipFuncs->zip_freeZipEntry (VMI, &zipEntry); //not valid zipEntry (-1)
 #endif /* HY_ZIP_API */
           return NULL;
         }

Modified: harmony/enhanced/classlib/trunk/modules/archive/src/main/native/archive/shared/zip.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/archive/src/main/native/archive/shared/zip.h?view=diff&rev=542962&r1=542961&r2=542962
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/archive/src/main/native/archive/shared/zip.h (original)
+++ harmony/enhanced/classlib/trunk/modules/archive/src/main/native/archive/shared/zip.h Wed
May 30 15:36:30 2007
@@ -24,6 +24,8 @@
 #include "hyzip.h"
 #endif /* HY_ZIP_API */
 
+#include "hymutex.h"
+
 typedef struct JCLZipFile
 {
   struct JCLZipFile *last;
@@ -36,6 +38,7 @@
 {
   JCLZipFile *last;
   JCLZipFile *next;
+  MUTEX mutex;
 } JCLZipFileLink;
 
 #endif /* zip_h */

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/native/include/unix/jclprots.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/include/unix/jclprots.h?view=diff&rev=542962&r1=542961&r2=542962
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/native/include/unix/jclprots.h (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/native/include/unix/jclprots.h Wed
May 30 15:36:30 2007
@@ -279,7 +279,7 @@
 /* NativesCommonZipFile*/
 void throwJavaZIOException PROTOTYPE((JNIEnv * env, const char *message));
 void throwNewInternalError PROTOTYPE((JNIEnv * env, const char * message));
-void JNICALL Java_java_util_zip_ZipFile_closeZipImpl PROTOTYPE((JNIEnv * env, jobject recv));
+void JNICALL Java_java_util_zip_ZipFile_closeZipImpl PROTOTYPE((JNIEnv * env, jobject recv,
jlong descriptor));
 jobject JNICALL Java_java_util_zip_ZipFile_00024ZFEnum_getNextEntry PROTOTYPE((JNIEnv * env,
jobject recv, jlong descriptor, jlong nextEntry));
 void JNICALL Java_java_util_zip_ZipFile_ntvinit PROTOTYPE((JNIEnv * env, jclass cls));
 void throwNewIllegalStateException PROTOTYPE((JNIEnv * env, const char * message));

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/native/include/windows/jclprots.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/include/windows/jclprots.h?view=diff&rev=542962&r1=542961&r2=542962
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/native/include/windows/jclprots.h
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/native/include/windows/jclprots.h
Wed May 30 15:36:30 2007
@@ -488,7 +488,7 @@
   void throwJavaZIOException PROTOTYPE ((JNIEnv * env, const char *message));
   void throwNewInternalError PROTOTYPE ((JNIEnv * env, const char *message));
   JNIEXPORT void JNICALL Java_java_util_zip_ZipFile_closeZipImpl
-    PROTOTYPE ((JNIEnv * env, jobject recv));
+    PROTOTYPE ((JNIEnv * env, jobject recv, jlong descriptor));
   JNIEXPORT jobject JNICALL Java_java_util_zip_ZipFile_00024ZFEnum_getNextEntry
     PROTOTYPE ((JNIEnv * env, jobject recv, jlong descriptor,
                 jlong nextEntry));



Mime
View raw message