Tarantool development patches archive
 help / color / mirror / Atom feed
From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
To: "Alexander V. Tikhonov" <avtikhon@tarantool.org>,
	Kirill Yukhin <kyukhin@tarantool.org>
Cc: tarantool-patches@dev.tarantool.org
Subject: Re: [Tarantool-patches] [PATCH v1] asan: leak unit/swim.test:swim_test_encryption
Date: Wed, 9 Sep 2020 23:06:43 +0200	[thread overview]
Message-ID: <ffc1a037-e8f3-3b55-9c66-88711ed75c6a@tarantool.org> (raw)
In-Reply-To: <75cc0d4428b08ee24ffeab4acd718ee5709fc2f4.1599674855.git.avtikhon@tarantool.org>

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.

  reply	other threads:[~2020-09-09 21:06 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-09 18:08 Alexander V. Tikhonov
2020-09-09 21:06 ` Vladislav Shpilevoy [this message]
2020-09-10  5:27   ` Alexander V. Tikhonov
2020-09-11 10:38 ` Kirill Yukhin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ffc1a037-e8f3-3b55-9c66-88711ed75c6a@tarantool.org \
    --to=v.shpilevoy@tarantool.org \
    --cc=avtikhon@tarantool.org \
    --cc=kyukhin@tarantool.org \
    --cc=tarantool-patches@dev.tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH v1] asan: leak unit/swim.test:swim_test_encryption' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox