From 4d8d2a04230525b106c9825a25c79c5191e88541 Mon Sep 17 00:00:00 2001
From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
Date: Thu, 6 Dec 2018 16:38:25 +0300
Subject: [PATCH] iproto: rename disconnect cmsg to destroy

Disconnect cmsg is a message that is used by iproto
thread to notify tx thread that a connection is dead
and has no outstanding requests. That is its
tx-related resourses are freed and the connection is
deleted.

But the text above is clear definition of destroy. The
patch harmonizes cmsg name and its puprose.

Secondly, the patch is motivated by #3859 which
requires separate disconnect and destroy phases.

Needed for #3859
---
 src/box/iproto.cc | 36 ++++++++++++++++++------------------
 1 file changed, 18 insertions(+), 18 deletions(-)

diff --git a/src/box/iproto.cc b/src/box/iproto.cc
index ff188cbf9e..29ff59725c 100644
--- a/src/box/iproto.cc
+++ b/src/box/iproto.cc
@@ -273,14 +273,14 @@ enum rmean_net_name {
 const char *rmean_net_strings[IPROTO_LAST] = { "SENT", "RECEIVED" };
 
 static void
-tx_process_disconnect(struct cmsg *m);
+tx_process_destroy(struct cmsg *m);
 
 static void
-net_finish_disconnect(struct cmsg *m);
+net_finish_destroy(struct cmsg *m);
 
-static const struct cmsg_hop disconnect_route[] = {
-	{ tx_process_disconnect, &net_pipe },
-	{ net_finish_disconnect, NULL },
+static const struct cmsg_hop destroy_route[] = {
+	{ tx_process_destroy, &net_pipe },
+	{ net_finish_destroy, NULL },
 };
 
 /**
@@ -399,10 +399,10 @@ struct iproto_connection
 	/** Logical session. */
 	struct session *session;
 	ev_loop *loop;
-	/* Pre-allocated disconnect msg. */
-	struct cmsg disconnect;
-	/** True if disconnect message is sent. Debug-only. */
-	bool is_disconnected;
+	/** Pre-allocated destroy msg. */
+	struct cmsg destroy_msg;
+	/** True if destroy message is sent. Debug-only. */
+	bool is_destroy_sent;
 	struct rlist in_stop_list;
 	/**
 	 * Kharon is used to implement box.session.push().
@@ -578,9 +578,9 @@ iproto_connection_close(struct iproto_connection *con)
 	 * twice.
 	 */
 	if (iproto_connection_is_idle(con)) {
-		assert(con->is_disconnected == false);
-		con->is_disconnected = true;
-		cpipe_push(&tx_pipe, &con->disconnect);
+		assert(! con->is_destroy_sent);
+		con->is_destroy_sent = true;
+		cpipe_push(&tx_pipe, &con->destroy_msg);
 	}
 	rlist_del(&con->in_stop_list);
 }
@@ -998,8 +998,8 @@ iproto_connection_new(int fd)
 	con->session = NULL;
 	rlist_create(&con->in_stop_list);
 	/* It may be very awkward to allocate at close. */
-	cmsg_init(&con->disconnect, disconnect_route);
-	con->is_disconnected = false;
+	cmsg_init(&con->destroy_msg, destroy_route);
+	con->is_destroy_sent = false;
 	con->tx.is_push_pending = false;
 	con->tx.is_push_sent = false;
 	return con;
@@ -1223,10 +1223,10 @@ tx_fiber_init(struct session *session, uint64_t sync)
  * as well as output buffers of the connection.
  */
 static void
-tx_process_disconnect(struct cmsg *m)
+tx_process_destroy(struct cmsg *m)
 {
 	struct iproto_connection *con =
-		container_of(m, struct iproto_connection, disconnect);
+		container_of(m, struct iproto_connection, destroy_msg);
 	if (con->session) {
 		tx_fiber_init(con->session, 0);
 		if (! rlist_empty(&session_on_disconnect))
@@ -1247,10 +1247,10 @@ tx_process_disconnect(struct cmsg *m)
  * and close the connection.
  */
 static void
-net_finish_disconnect(struct cmsg *m)
+net_finish_destroy(struct cmsg *m)
 {
 	struct iproto_connection *con =
-		container_of(m, struct iproto_connection, disconnect);
+		container_of(m, struct iproto_connection, destroy_msg);
 	/* Runs the trigger, which may yield. */
 	iproto_connection_delete(con);
 }
-- 
GitLab