hadoop-hdfs-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sur...@apache.org
Subject svn commit: r901316 - in /hadoop/hdfs/trunk: CHANGES.txt src/c++/libhdfs/hdfs.c src/c++/libhdfs/hdfsJniHelper.c
Date Wed, 20 Jan 2010 18:28:36 GMT
Author: suresh
Date: Wed Jan 20 18:28:36 2010
New Revision: 901316

URL: http://svn.apache.org/viewvc?rev=901316&view=rev
Log:
HDFS-464. Fix memory leaks in libhdfs. Contributed by Christian Kunz.

Modified:
    hadoop/hdfs/trunk/CHANGES.txt
    hadoop/hdfs/trunk/src/c++/libhdfs/hdfs.c
    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=901316&r1=901315&r2=901316&view=diff
==============================================================================
--- hadoop/hdfs/trunk/CHANGES.txt (original)
+++ hadoop/hdfs/trunk/CHANGES.txt Wed Jan 20 18:28:36 2010
@@ -667,6 +667,8 @@
     HDFS-187. Initialize secondary namenode http address in TestStartup.
     (Todd Lipcon via szetszwo)
 
+    HDFS-464. Fix memory leaks in libhdfs. (Christian Kunz via suresh)
+
 Release 0.20.1 - 2009-09-01
 
   IMPROVEMENTS

Modified: hadoop/hdfs/trunk/src/c++/libhdfs/hdfs.c
URL: http://svn.apache.org/viewvc/hadoop/hdfs/trunk/src/c%2B%2B/libhdfs/hdfs.c?rev=901316&r1=901315&r2=901316&view=diff
==============================================================================
--- hadoop/hdfs/trunk/src/c++/libhdfs/hdfs.c (original)
+++ hadoop/hdfs/trunk/src/c++/libhdfs/hdfs.c Wed Jan 20 18:28:36 2010
@@ -219,6 +219,7 @@
       if (groups == NULL || groups_size <= 0) {
         fprintf(stderr, "ERROR: groups must not be empty/null\n");
         errno = EINVAL;
+        destroyLocalReference(env, jConfiguration);
         return NULL;
       }
 
@@ -227,6 +228,8 @@
       if (jGroups == NULL) {
         errno = EINTERNAL;
         fprintf(stderr, "ERROR: could not construct groups array\n");
+        destroyLocalReference(env, jConfiguration);
+        destroyLocalReference(env, jUserString);
         return NULL;
       }
 
@@ -259,12 +262,14 @@
           destroyLocalReference(env, jGroups);
         }          
         destroyLocalReference(env, jUgi);
+        destroyLocalReference(env, jAttrString);
         return NULL;
       }
 
       destroyLocalReference(env, jUserString);
       destroyLocalReference(env, jGroups);
       destroyLocalReference(env, jUgi);
+      destroyLocalReference(env, jAttrString);
     }
 #else
     
@@ -402,6 +407,7 @@
       if (groups == NULL || groups_size <= 0) {
         fprintf(stderr, "ERROR: groups must not be empty/null\n");
         errno = EINVAL;
+        destroyLocalReference(env, jConfiguration);
         return NULL;
       }
 
@@ -410,6 +416,8 @@
       if (jGroups == NULL) {
         errno = EINTERNAL;
         fprintf(stderr, "ERROR: could not construct groups array\n");
+        destroyLocalReference(env, jConfiguration);
+        destroyLocalReference(env, jUserString);
         return NULL;
       }
 
@@ -442,12 +450,14 @@
           destroyLocalReference(env, jGroups);
         }          
         destroyLocalReference(env, jUgi);
+        destroyLocalReference(env, jAttrString);
         return NULL;
       }
 
       destroyLocalReference(env, jUserString);
       destroyLocalReference(env, jGroups);
       destroyLocalReference(env, jUgi);
+      destroyLocalReference(env, jAttrString);
     }
 #else
     
@@ -726,12 +736,12 @@
     file = malloc(sizeof(struct hdfsFile_internal));
     if (!file) {
         errno = ENOMEM;
-        return NULL;
-    }
-    file->file = (*env)->NewGlobalRef(env, jVal.l);
-    file->type = (((flags & O_WRONLY) == 0) ? INPUT : OUTPUT);
+    } else {
+        file->file = (*env)->NewGlobalRef(env, jVal.l);
+        file->type = (((flags & O_WRONLY) == 0) ? INPUT : OUTPUT);
 
-    destroyLocalReference(env, jVal.l);
+        destroyLocalReference(env, jVal.l);
+    }
 
     done:
 
@@ -813,9 +823,11 @@
                      jPath) != 0) {
         errno = errnoFromException(jExc, env, "org.apache.hadoop.fs."
                                    "FileSystem::exists");
+        destroyLocalReference(env, jPath);
         return -1;
     }
 
+    destroyLocalReference(env, jPath);
     return jVal.z ? 0 : -1;
 }
 
@@ -1332,6 +1344,7 @@
                      jPath, jRecursive) != 0) {
         errno = errnoFromException(jExc, env, "org.apache.hadoop.fs."
                                    "FileSystem::delete");
+        destroyLocalReference(env, jPath);
         return -1;
     }
 
@@ -1382,6 +1395,8 @@
                      jOldPath, jNewPath) != 0) {
         errno = errnoFromException(jExc, env, "org.apache.hadoop.fs."
                                    "FileSystem::rename");
+        destroyLocalReference(env, jOldPath);
+        destroyLocalReference(env, jNewPath);
         return -1;
     }
 
@@ -1645,6 +1660,7 @@
     //Create an object of org.apache.hadoop.fs.Path
     jobject jPath = constructNewObjectOfPath(env, path);
     if (jPath == NULL) {
+      destroyLocalReference(env, jPermObj);
       return -3;
     }
 
@@ -1916,8 +1932,10 @@
                      "getCapacity", "()J") != 0) {
         errno = errnoFromException(jExc, env, "org.apache.hadoop.fs."
                                    "FsStatus::getCapacity");
+        destroyLocalReference(env, fss);
         return -1;
     }
+    destroyLocalReference(env, fss);
     return jVal.j;
 }
 
@@ -1952,8 +1970,10 @@
                      "getUsed", "()J") != 0) {
         errno = errnoFromException(jExc, env, "org.apache.hadoop.fs."
                                    "FsStatus::getUsed");
+        destroyLocalReference(env, fss);
         return -1;
     }
+    destroyLocalReference(env, fss);
     return jVal.j;
 
 }

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=901316&r1=901315&r2=901316&view=diff
==============================================================================
--- hadoop/hdfs/trunk/src/c++/libhdfs/hdfsJniHelper.c (original)
+++ hadoop/hdfs/trunk/src/c++/libhdfs/hdfsJniHelper.c Wed Jan 20 18:28:36 2010
@@ -243,6 +243,7 @@
       fprintf(stderr, "ERROR: jelem == NULL\n");
     }
     (*env)->SetObjectArrayElement(env, result, i, jelem);
+    (*env)->DeleteLocalRef(env, jelem);
   }
   return result;
 }



Mime
View raw message