Bladeren bron

HADOOP-911. Fix a multithreading bug in libhdfs. Contributed by Christian Kunz.

git-svn-id: https://svn.apache.org/repos/asf/lucene/hadoop/trunk@555390 13f79535-47bb-0310-9956-ffa450edef68
Doug Cutting 18 jaren geleden
bovenliggende
commit
9fb632c57d
2 gewijzigde bestanden met toevoegingen van 3 en 41 verwijderingen
  1. 3 0
      CHANGES.txt
  2. 0 41
      src/c++/libhdfs/hdfsJniHelper.c

+ 3 - 0
CHANGES.txt

@@ -312,6 +312,9 @@ Trunk (unreleased changes)
  96. HADOOP-1582.  Fix hdfslib to return 0 instead of -1 at
      end-of-file, per C conventions.  (Christian Kunz via cutting)
 
+ 97. HADOOP-911.  Fix a multithreading bug in libhdfs.
+     (Christian Kunz)
+
 
 Release 0.13.0 - 2007-06-08
 

+ 0 - 41
src/c++/libhdfs/hdfsJniHelper.c

@@ -38,14 +38,6 @@ static volatile int hashTableInited = 0;
 #define JDOUBLE       'D'
 
 
-/**
- * Helpful macro to convert a pthread_t to a string
- */
-#define GET_threadID(threadID, key, keySize) \
-    snprintf(key, keySize, "__hdfs_threadID__%u", (unsigned)(threadID)); 
-#define threadID_SIZE 32
-
-
 /**
  * MAX_HASH_TABLE_ELEM: The maximum no. of entries in the hashtable.
  * It's set to 4096 to account for (classNames + No. of threads)
@@ -287,7 +279,6 @@ jclass globalClassReference(const char *className, JNIEnv *env)
  */
 JNIEnv* getJNIEnv(void)
 {
-    char threadID[threadID_SIZE];
 
     const jsize vmBufLength = 1;
     JavaVM* vmBuf[vmBufLength]; 
@@ -295,27 +286,6 @@ JNIEnv* getJNIEnv(void)
     jint rv = 0; 
     jint noVMs = 0;
 
-    //Get the threadID and stringize it 
-    GET_threadID(pthread_self(), threadID, sizeof(threadID));
-
-    //See if you already have the JNIEnv* cached...
-    env = (JNIEnv*)searchEntryFromTable(threadID);
-    if (env != NULL) {
-        return env; 
-    }
-
-    //All right... some serious work required here!
-    //1. Initialize the HashTable
-    //2. LOCK!
-    //3. Check if any JVMs have been created here
-    //      Yes: Use it (we should only have 1 VM)
-    //      No: Create the JVM
-    //4. UNLOCK
-
-    hashTableInit();
-
-    LOCK_HASH_TABLE();
-
     rv = JNI_GetCreatedJavaVMs(&(vmBuf[0]), vmBufLength, &noVMs);
     if (rv != 0) {
         fprintf(stderr, "JNI_GetCreatedJavaVMs failed with error: %d\n", rv);
@@ -371,16 +341,5 @@ JNIEnv* getJNIEnv(void)
         }
     }
 
-    //Save the threadID -> env mapping
-    ENTRY e, *ep;
-    e.key = threadID;
-    e.data = (void*)(env);
-    if ((ep = hsearch(e, ENTER)) == NULL) {
-        fprintf(stderr, "Call to hsearch(ENTER) failed\n");
-        exit(1);
-    }
-
-    UNLOCK_HASH_TABLE();
-
     return env;
 }