[Tarantool-patches] [PATCH v1] asan: leak unit/swim.test:swim_test_encryption

Vladislav Shpilevoy v.shpilevoy at tarantool.org
Thu Sep 10 00:06:43 MSK 2020


Hi! Thanks for the patch!

I force pushed my review fixes on top of the branch and paste
them below. If you agree, and if it works (I wasn't able to reproduce
the fail locally), then squash, please.

====================
diff --git a/src/lib/swim/swim.c b/src/lib/swim/swim.c
index 53f118609..396bd7c45 100644
--- a/src/lib/swim/swim.c
+++ b/src/lib/swim/swim.c
@@ -2114,12 +2114,6 @@ swim_set_codec(struct swim *swim, enum crypto_algo algo, enum crypto_mode mode,
 					key, key_size);
 }
 
-int
-swim_delete_codec(struct swim *swim)
-{
-	return swim_scheduler_delete_codec(&swim->scheduler);
-}
-
 bool
 swim_is_configured(const struct swim *swim)
 {
diff --git a/src/lib/swim/swim.h b/src/lib/swim/swim.h
index e684205c4..4565eb976 100644
--- a/src/lib/swim/swim.h
+++ b/src/lib/swim/swim.h
@@ -124,15 +124,6 @@ int
 swim_set_codec(struct swim *swim, enum crypto_algo algo, enum crypto_mode mode,
 	       const char *key, int key_size);
 
-
-/**
- * Delete SWIM codec used to encrypt/decrypt messages.
- * @param swim SWIM instance to set codec for.
- */
-int
-swim_delete_codec(struct swim *swim);
-
-
 /**
  * Stop listening and broadcasting messages, cleanup all internal
  * structures, free memory. The function yields. Actual deletion
diff --git a/src/lib/swim/swim_io.c b/src/lib/swim/swim_io.c
index f7107d39e..c8558c43e 100644
--- a/src/lib/swim/swim_io.c
+++ b/src/lib/swim/swim_io.c
@@ -402,6 +402,8 @@ swim_scheduler_destroy(struct swim_scheduler *scheduler)
 	swim_transport_destroy(&scheduler->transport);
 	swim_ev_io_stop(swim_loop(), &scheduler->output);
 	swim_scheduler_stop_input(scheduler);
+	if (scheduler->codec != NULL)
+		crypto_codec_delete(scheduler->codec);
 	assert(scheduler_count > 0);
 	if (--scheduler_count == 0)
 		swim_task_pool_destroy();
@@ -708,14 +710,6 @@ swim_scheduler_set_codec(struct swim_scheduler *scheduler,
 	return 0;
 }
 
-int
-swim_scheduler_delete_codec(struct swim_scheduler *scheduler)
-{
-	if (scheduler->codec != NULL)
-		crypto_codec_delete(scheduler->codec);
-	return 0;
-}
-
 const char *
 swim_inaddr_str(const struct sockaddr_in *addr)
 {
diff --git a/src/lib/swim/swim_io.h b/src/lib/swim/swim_io.h
index 72c6c030d..bf5a1389f 100644
--- a/src/lib/swim/swim_io.h
+++ b/src/lib/swim/swim_io.h
@@ -204,10 +204,6 @@ swim_scheduler_set_codec(struct swim_scheduler *scheduler,
 			 enum crypto_algo algo, enum crypto_mode mode,
 			 const char *key, int key_size);
 
-/** Delete the codec used to encrypt/decrypt messages. */
-int
-swim_scheduler_delete_codec(struct swim_scheduler *scheduler);
-
 /** Stop accepting new packets from the network. */
 void
 swim_scheduler_stop_input(struct swim_scheduler *scheduler);
diff --git a/test/unit/swim.c b/test/unit/swim.c
index bc19f8a10..bb12baf8d 100644
--- a/test/unit/swim.c
+++ b/test/unit/swim.c
@@ -770,7 +770,6 @@ swim_test_encryption(void)
 
 	is(swim_cluster_wait_fullmesh(cluster, 2), 0,
 	   "cluster works with encryption");
-	swim_cluster_delete_codec(cluster);
 	swim_cluster_delete(cluster);
 	/*
 	 * Test that the instances can not interact with different
@@ -1141,4 +1140,4 @@ main()
 {
 	swim_run_test("swim.txt", main_f);
 	return test_result;
-}
+}
\ No newline at end of file
diff --git a/test/unit/swim_test_utils.c b/test/unit/swim_test_utils.c
index c527af55c..9dbd28a9f 100644
--- a/test/unit/swim_test_utils.c
+++ b/test/unit/swim_test_utils.c
@@ -237,14 +237,6 @@ swim_cluster_new(int size)
 	}								\
 })
 
-#define swim_cluster_set_cfg_noargs(cluster, func) ({				\
-	for (int i = 0; i < cluster->size; ++i) {			\
-		int rc = func(cluster->node[i].swim);	\
-		assert(rc == 0);					\
-		(void) rc;						\
-	}								\
-})
-
 void
 swim_cluster_set_ack_timeout(struct swim_cluster *cluster, double ack_timeout)
 {
@@ -260,12 +252,6 @@ swim_cluster_set_codec(struct swim_cluster *cluster, enum crypto_algo algo,
 			     key, key_size);
 }
 
-void
-swim_cluster_delete_codec(struct swim_cluster *cluster)
-{
-	swim_cluster_set_cfg_noargs(cluster, swim_delete_codec);
-}
-
 void
 swim_cluster_set_gc(struct swim_cluster *cluster, enum swim_gc_mode gc_mode)
 {
diff --git a/test/unit/swim_test_utils.h b/test/unit/swim_test_utils.h
index b413bb8ce..ac86b6f72 100644
--- a/test/unit/swim_test_utils.h
+++ b/test/unit/swim_test_utils.h
@@ -64,13 +64,6 @@ void
 swim_cluster_set_codec(struct swim_cluster *cluster, enum crypto_algo algo,
 		       enum crypto_mode mode, const char *key, int key_size);
 
-/**
- * Delete codec for each instance in
- * @a cluster.
- */
-void
-swim_cluster_delete_codec(struct swim_cluster *cluster);
-
 /**
  * Change number of unacknowledged pings to delete a dead member
  * of all the instances in the cluster.


More information about the Tarantool-patches mailing list