hadoop-hdfs-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e..@apache.org
Subject svn commit: r1126312 - in /hadoop/hdfs/trunk: CHANGES.txt src/c++/libhdfs/hdfsJniHelper.c
Date Mon, 23 May 2011 04:58:11 GMT
Author: eli
Date: Mon May 23 04:58:10 2011
New Revision: 1126312

URL: http://svn.apache.org/viewvc?rev=1126312&view=rev
Log:
HDFS-1978. All but first option in LIBHDFS_OPTS is ignored. Contributed by Eli Collins

Modified:
    hadoop/hdfs/trunk/CHANGES.txt
    hadoop/hdfs/trunk/src/c++/libhdfs/hdfsJniHelper.c

Modified: hadoop/hdfs/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/hdfs/trunk/CHANGES.txt?rev=1126312&r1=1126311&r2=1126312&view=diff
==============================================================================
--- hadoop/hdfs/trunk/CHANGES.txt (original)
+++ hadoop/hdfs/trunk/CHANGES.txt Mon May 23 04:58:10 2011
@@ -1053,6 +1053,8 @@ Release 0.22.0 - Unreleased
     HDFS-1965. IPCs done using block token-based tickets can't reuse
     connections (todd)
 
+    HDFS-1978. All but first option in LIBHDFS_OPTS is ignored. (eli)
+
 Release 0.21.1 - Unreleased
     HDFS-1466. TestFcHdfsSymlink relies on /tmp/test not existing. (eli)
 

Modified: hadoop/hdfs/trunk/src/c++/libhdfs/hdfsJniHelper.c
URL: http://svn.apache.org/viewvc/hadoop/hdfs/trunk/src/c%2B%2B/libhdfs/hdfsJniHelper.c?rev=1126312&r1=1126311&r2=1126312&view=diff
==============================================================================
--- hadoop/hdfs/trunk/src/c++/libhdfs/hdfsJniHelper.c (original)
+++ hadoop/hdfs/trunk/src/c++/libhdfs/hdfsJniHelper.c Mon May 23 04:58:10 2011
@@ -421,28 +421,35 @@ JNIEnv* getJNIEnv(void)
         snprintf(optHadoopClassPath, optHadoopClassPathLen,
                 "%s%s", hadoopClassPathVMArg, hadoopClassPath);
 
+        // Determine the # of LIBHDFS_OPTS args
         int noArgs = 1;
-        //determine how many arguments were passed as LIBHDFS_OPTS env var
         char *hadoopJvmArgs = getenv("LIBHDFS_OPTS");
         char jvmArgDelims[] = " ";
+        char *str, *token, *savePtr;
         if (hadoopJvmArgs != NULL)  {
-                char *result = NULL;
-                result = strtok( hadoopJvmArgs, jvmArgDelims );
-                while ( result != NULL ) {
-                        noArgs++;
-        		result = strtok( NULL, jvmArgDelims);
-           	}
+          hadoopJvmArgs = strdup(hadoopJvmArgs);
+          for (noArgs = 1, str = hadoopJvmArgs; ; noArgs++, str = NULL) {
+            token = strtok_r(str, jvmArgDelims, &savePtr);
+            if (NULL == token) {
+              break;
+            }
+          }
+          free(hadoopJvmArgs);
         }
+
+        // Now that we know the # args, populate the options array
         JavaVMOption options[noArgs];
         options[0].optionString = optHadoopClassPath;
-		//fill in any specified arguments
+        hadoopJvmArgs = getenv("LIBHDFS_OPTS");
 	if (hadoopJvmArgs != NULL)  {
-            char *result = NULL;
-            result = strtok( hadoopJvmArgs, jvmArgDelims );	
-            int argNum = 1;
-            for (;argNum < noArgs ; argNum++) {
-                options[argNum].optionString = result; //optHadoopArg;
+          hadoopJvmArgs = strdup(hadoopJvmArgs);
+          for (noArgs = 1, str = hadoopJvmArgs; ; noArgs++, str = NULL) {
+            token = strtok_r(str, jvmArgDelims, &savePtr);
+            if (NULL == token) {
+              break;
             }
+            options[noArgs].optionString = token;
+          }
         }
 
         //Create the VM
@@ -454,14 +461,18 @@ JNIEnv* getJNIEnv(void)
         vm_args.ignoreUnrecognized = 1;
 
         rv = JNI_CreateJavaVM(&vm, (void*)&env, &vm_args);
+
+        if (hadoopJvmArgs != NULL)  {
+          free(hadoopJvmArgs);
+        }
+        free(optHadoopClassPath);
+
         if (rv != 0) {
             fprintf(stderr, "Call to JNI_CreateJavaVM failed "
                     "with error: %d\n", rv);
             UNLOCK_JVM_MUTEX();
             return NULL;
         }
-
-        free(optHadoopClassPath);
     }
     else {
         //Attach this thread to the VM



Mime
View raw message