[PATCH 1/4] iproto: rename disconnect cmsg to destroy

Vladislav Shpilevoy v.shpilevoy at tarantool.org
Fri Dec 7 18:46:32 MSK 2018


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 3d13bad2f..40d456374 100644
--- a/src/box/iproto.cc
+++ b/src/box/iproto.cc
@@ -271,14 +271,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 },
 };
 
 /**
@@ -397,10 +397,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().
@@ -576,9 +576,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);
 }
@@ -992,8 +992,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;
@@ -1204,10 +1204,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))
@@ -1228,10 +1228,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);
 }
-- 
2.17.2 (Apple Git-113)




More information about the Tarantool-patches mailing list