hawq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lil...@apache.org
Subject incubator-hawq git commit: HAWQ-574. Fix memory leak in dispatcher
Date Wed, 23 Mar 2016 01:53:39 GMT
Repository: incubator-hawq
Updated Branches:
  refs/heads/master 31fdef71c -> 26a5b2029


HAWQ-574. Fix memory leak in dispatcher


Project: http://git-wip-us.apache.org/repos/asf/incubator-hawq/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-hawq/commit/26a5b202
Tree: http://git-wip-us.apache.org/repos/asf/incubator-hawq/tree/26a5b202
Diff: http://git-wip-us.apache.org/repos/asf/incubator-hawq/diff/26a5b202

Branch: refs/heads/master
Commit: 26a5b202906bb62016bba0b1c865d9478bb6f53e
Parents: 31fdef7
Author: Lili Ma <ictmalili@gmail.com>
Authored: Wed Mar 23 09:48:59 2016 +0800
Committer: Lili Ma <ictmalili@gmail.com>
Committed: Wed Mar 23 09:48:59 2016 +0800

----------------------------------------------------------------------
 src/backend/cdb/dispatcher.c      | 10 ++++++++++
 src/backend/gp_libpq_fe/fe-exec.c | 13 ++++++++-----
 2 files changed, 18 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/26a5b202/src/backend/cdb/dispatcher.c
----------------------------------------------------------------------
diff --git a/src/backend/cdb/dispatcher.c b/src/backend/cdb/dispatcher.c
index d9d0771..e3c5e94 100644
--- a/src/backend/cdb/dispatcher.c
+++ b/src/backend/cdb/dispatcher.c
@@ -1569,6 +1569,16 @@ dispatch_free_result(DispatchDataResult *result)
 		pfree(result->errbuf.data);
 		result->errbuf.data = NULL;
 	}
+
+	if (!result->result)
+	{
+	  for (int i = 0; i <= result->numresults; i++){
+	    PQclear(result->result[i]);
+	    result->result[i] = NULL;
+	  }
+	  free(result->result);
+	}
+
 	dispmgt_free_takeoved_segment_conns(result->segment_conns);
 }
 

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/26a5b202/src/backend/gp_libpq_fe/fe-exec.c
----------------------------------------------------------------------
diff --git a/src/backend/gp_libpq_fe/fe-exec.c b/src/backend/gp_libpq_fe/fe-exec.c
index 0285430..8382683 100644
--- a/src/backend/gp_libpq_fe/fe-exec.c
+++ b/src/backend/gp_libpq_fe/fe-exec.c
@@ -681,11 +681,14 @@ PQclear(PGresult *res)
 
 	if (res->sendback)
 	{
-		if (res->sendback->eof)
-			free(res->sendback->eof);
-		if (res->sendback->uncompressed_eof)
-			free(res->sendback->uncompressed_eof);
-		free(res->sendback);
+	  for (int i = 0; i < res->numSendback; i++)
+	  {
+	    if (res->sendback[i].eof)
+	      free(res->sendback[i].eof);
+	    if (res->sendback[i].uncompressed_eof)
+	      free(res->sendback[i].uncompressed_eof);
+	  }
+	  free(res->sendback);
 	}
 
 	/* Free the PGresult structure itself */


Mime
View raw message