Просмотр исходного кода

defect 1065
memory leak in checkpoint iteration when IterationNext has a failure condition
(like NO_MORE_SECTIONS)


git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@910 fd59a12c-fef9-0310-b244-a6a79926bd2f

Steven Dake 20 лет назад
Родитель
Сommit
e665c14f55
2 измененных файлов с 15 добавлено и 8 удалено
  1. 12 5
      lib/ckpt.c
  2. 3 3
      test/testckpt.c

+ 12 - 5
lib/ckpt.c

@@ -1365,13 +1365,13 @@ saCkptSectionIterationNext (
 		sizeof (struct req_lib_ckpt_sectioniteratornext), MSG_NOSIGNAL);
 
 	if (error != SA_AIS_OK) {
-		goto error_put;
+		goto error_put_unlock;
 	}
 
 	error = saRecvRetry (ckptSectionIterationInstance->response_fd, &res_lib_ckpt_sectioniteratornext,
 		sizeof (struct res_lib_ckpt_sectioniteratornext), MSG_WAITALL | MSG_NOSIGNAL);
 	if (error != SA_AIS_OK) {
-		goto error_put;
+		goto error_put_unlock;
 	}
 
 	memcpy (sectionDescriptor,
@@ -1388,20 +1388,27 @@ saCkptSectionIterationNext (
 			MSG_WAITALL | MSG_NOSIGNAL);
 	}
 
+	error = (error == SA_AIS_OK ? res_lib_ckpt_sectioniteratornext.header.error : error);
+	
 	/*
 	 * Add to persistent memory list for this sectioniterator
 	 */
-	if (error == SA_AIS_OK && res_lib_ckpt_sectioniteratornext.header.error == SA_AIS_OK) {
+	if (error == SA_AIS_OK) {
 		list_init (&iteratorSectionIdListEntry->list);
 		list_add (&iteratorSectionIdListEntry->list, &ckptSectionIterationInstance->sectionIdListHead);
 	}
 
-error_put:
+error_put_unlock:
 	pthread_mutex_unlock (&ckptSectionIterationInstance->response_mutex);
+
 error_put_nounlock:
 	saHandleInstancePut (&ckptSectionIterationHandleDatabase, sectionIterationHandle);
+
 error_exit:
-	return (error == SA_AIS_OK ? res_lib_ckpt_sectioniteratornext.header.error : error);
+	if (error != SA_AIS_OK) {
+		free (iteratorSectionIdListEntry);
+	}
+	return (error);
 }
 	
 SaAisErrorT

+ 3 - 3
test/testckpt.c

@@ -68,8 +68,8 @@ SaCkptCheckpointCreationAttributesT checkpointCreationAttributes = {
 	SA_CKPT_WR_ALL_REPLICAS,
 	100000,
 	5000000000LL,
-	5,
-	20000,
+	10,
+	200000,
 	10
 };
 
@@ -460,7 +460,7 @@ printf ("Please wait, testing expiry of checkpoint sections.\n");
 			(int)checkpointStatus.numberOfSections);
 	}
 	error = saCkptSectionIterationInitialize (checkpointHandle,
-		0,
+		SA_CKPT_SECTIONS_ANY,
 		0,
 		&sectionIterator);
 	printf ("%s: initialize section iterator\n",