浏览代码

commit 4c0f6f027bd12c94e9fb7615a299a7f6d27faa3c
Author: Yahoo\! <ltucker@yahoo-inc.com>
Date: Thu Sep 10 19:55:32 2009 -0700

HADOOP:5420 additional patch to correct a problem when mapred.local.dir
is split across multiple directories


git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-0.20-security-patches@1076997 13f79535-47bb-0310-9956-ffa450edef68

Owen O'Malley 14 年之前
父节点
当前提交
c2dc153ab3
共有 2 个文件被更改,包括 13 次插入20 次删除
  1. 12 20
      src/c++/task-controller/configuration.c
  2. 1 0
      src/c++/task-controller/task-controller.c

+ 12 - 20
src/c++/task-controller/configuration.c

@@ -203,35 +203,27 @@ const char * get_value(char* key) {
 }
 }
 
 
 const char ** get_values(char * key) {
 const char ** get_values(char * key) {
-  const char ** toPass = NULL;
-  const char * value = get_value(key);
   char *tempTok = NULL;
   char *tempTok = NULL;
   char *tempstr = NULL;
   char *tempstr = NULL;
   int size = 0;
   int size = 0;
-  int len;
+  int toPassSize = MAX_SIZE;
+  const char** toPass = (const char **) malloc(sizeof(char *) * toPassSize);
+
   //first allocate any array of 10
   //first allocate any array of 10
+  const char * value = get_value(key);
   if(value != NULL) {
   if(value != NULL) {
-    toPass = (const char **) malloc(sizeof(char *) * MAX_SIZE);
     tempTok = strtok_r((char *)value, ",", &tempstr);
     tempTok = strtok_r((char *)value, ",", &tempstr);
-    if (tempTok != NULL) {
-      while (1) {
-        toPass[size++] = tempTok;
-        tempTok = strtok_r(NULL, ",", &tempstr);
-        if(tempTok == NULL){
-          break;
-        }
-        if((size % MAX_SIZE) == 0) {
-          toPass = (const char **) realloc(toPass,(sizeof(char *) *
-              (MAX_SIZE * ((size/MAX_SIZE) +1))));
-        }
+    while (tempTok != NULL) {
+      toPass[size++] = tempTok;
+      if(size == toPassSize) {
+        toPassSize += MAX_SIZE;
+        toPass = (const char **) realloc(toPass,(sizeof(char *) *
+                                         (MAX_SIZE * toPassSize)));
       }
       }
-    } else {
-      toPass[size] = (char *)value;
+      tempTok = strtok_r(NULL, ",", &tempstr);
     }
     }
   }
   }
-  if(size > 0) {
-    toPass[size] = NULL;
-  }
+  toPass[size] = NULL;
   return toPass;
   return toPass;
 }
 }
 
 

+ 1 - 0
src/c++/task-controller/task-controller.c

@@ -91,6 +91,7 @@ int check_tt_root(const char *tt_root) {
       found = 0;
       found = 0;
       break;
       break;
     }
     }
+    ++mapred_local_dir; 
   }
   }
   free(mapred_local_dir);
   free(mapred_local_dir);
   return found;
   return found;