You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by cu...@apache.org on 2007/07/11 22:39:33 UTC
svn commit: r555390 - in /lucene/hadoop/trunk: CHANGES.txt
src/c++/libhdfs/hdfsJniHelper.c
Author: cutting
Date: Wed Jul 11 13:39:32 2007
New Revision: 555390
URL: http://svn.apache.org/viewvc?view=rev&rev=555390
Log:
HADOOP-911. Fix a multithreading bug in libhdfs. Contributed by Christian Kunz.
Modified:
lucene/hadoop/trunk/CHANGES.txt
lucene/hadoop/trunk/src/c++/libhdfs/hdfsJniHelper.c
Modified: lucene/hadoop/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/CHANGES.txt?view=diff&rev=555390&r1=555389&r2=555390
==============================================================================
--- lucene/hadoop/trunk/CHANGES.txt (original)
+++ lucene/hadoop/trunk/CHANGES.txt Wed Jul 11 13:39:32 2007
@@ -312,6 +312,9 @@
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
Modified: lucene/hadoop/trunk/src/c++/libhdfs/hdfsJniHelper.c
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/c%2B%2B/libhdfs/hdfsJniHelper.c?view=diff&rev=555390&r1=555389&r2=555390
==============================================================================
--- lucene/hadoop/trunk/src/c++/libhdfs/hdfsJniHelper.c (original)
+++ lucene/hadoop/trunk/src/c++/libhdfs/hdfsJniHelper.c Wed Jul 11 13:39:32 2007
@@ -39,14 +39,6 @@
/**
- * 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 @@
*/
JNIEnv* getJNIEnv(void)
{
- char threadID[threadID_SIZE];
const jsize vmBufLength = 1;
JavaVM* vmBuf[vmBufLength];
@@ -295,27 +286,6 @@
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);
@@ -370,17 +340,6 @@
exit(1);
}
}
-
- //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;
}