From 57e46303c0177c3f7917694d064da2e1499ff6ec Mon Sep 17 00:00:00 2001
From: mechanik20051988 <mechanik20051988@tarantool.org>
Date: Wed, 15 Sep 2021 20:35:20 +0300
Subject: [PATCH] Add comments and make minor changes.

---
 src/box/iproto.cc  |  7 ++-----
 src/box/iproto.h   |  2 +-
 src/box/lua/stat.c | 20 ++++++++++++++------
 3 files changed, 17 insertions(+), 12 deletions(-)

diff --git a/src/box/iproto.cc b/src/box/iproto.cc
index f5bd810b08..858518386f 100644
--- a/src/box/iproto.cc
+++ b/src/box/iproto.cc
@@ -2726,10 +2726,10 @@ iproto_thread_init(struct iproto_thread *iproto_thread)
 	if (iproto_thread->rmean == NULL) {
 		slab_cache_destroy(&iproto_thread->net_slabc);
 		diag_set(OutOfMemory, sizeof(struct rmean),
-			  "rmean_new", "struct rmean");
+			 "rmean_new", "struct rmean");
 		return -1;
 	}
-
+	rlist_create(&iproto_thread->stopped_connections);
 	return 0;
 }
 
@@ -2772,9 +2772,6 @@ iproto_init(int threads_count)
 			goto fail;
 		}
 		/* Create a pipe to "net" thread. */
-		iproto_thread->stopped_connections =
-			RLIST_HEAD_INITIALIZER(iproto_thread->
-					       stopped_connections);
 		char endpoint_name[ENDPOINT_NAME_MAX];
 		snprintf(endpoint_name, ENDPOINT_NAME_MAX, "net%u",
 			 iproto_thread->id);
diff --git a/src/box/iproto.h b/src/box/iproto.h
index a35a552b1a..51dfd58b48 100644
--- a/src/box/iproto.h
+++ b/src/box/iproto.h
@@ -52,7 +52,7 @@ enum {
 	 * processing stops until some new fibers are freed up.
 	 */
 	IPROTO_FIBER_POOL_SIZE_FACTOR = 5,
-	/** Maximum count of iproto threads */
+	/** Maximum count of iproto threads. */
 	IPROTO_THREADS_MAX = 1000,
 };
 
diff --git a/src/box/lua/stat.c b/src/box/lua/stat.c
index 946d067acf..1ee2fb54f3 100644
--- a/src/box/lua/stat.c
+++ b/src/box/lua/stat.c
@@ -71,8 +71,8 @@ static void
 inject_iproto_stats(struct lua_State *L, struct iproto_stats *stats)
 {
 	inject_current_stat(L, "CONNECTIONS", stats->connections);
-	inject_current_stat(L, "REQUESTS", stats->requests);
 	inject_current_stat(L, "STREAMS", stats->streams);
+	inject_current_stat(L, "REQUESTS", stats->requests);
 }
 
 static void
@@ -179,14 +179,14 @@ lbox_stat_net_index(struct lua_State *L)
 		lua_pushstring(L, "current");
 		lua_pushnumber(L, stats.connections);
 		lua_rawset(L, -3);
-	} else if (strcmp(key, "REQUESTS") == 0) {
-		lua_pushstring(L, "current");
-		lua_pushnumber(L, stats.requests);
-		lua_rawset(L, -3);
 	} else if (strcmp(key, "STREAMS") == 0) {
 		lua_pushstring(L, "current");
 		lua_pushnumber(L, stats.streams);
 		lua_rawset(L, -3);
+	} else if (strcmp(key, "REQUESTS") == 0) {
+		lua_pushstring(L, "current");
+		lua_pushnumber(L, stats.requests);
+		lua_rawset(L, -3);
 	}
 	return 1;
 }
@@ -198,7 +198,9 @@ lbox_stat_net_index(struct lua_State *L)
  *
  * - SENT (packets): total, rps;
  * - RECEIVED (packets): total, rps;
- * - CONNECTIONS: current.
+ * - CONNECTIONS: total, rps, current;
+ * - STREAMS: total, rps, current;
+ * - REQUESTS: total, rps, current.
  *
  * These fields have the following meaning:
  *
@@ -218,6 +220,9 @@ lbox_stat_net_call(struct lua_State *L)
 	return 1;
 }
 
+/**
+ * Same as `lbox_stat_net_index` but for thread with given id.
+ */
 static int
 lbox_stat_net_thread_index(struct lua_State *L)
 {
@@ -233,6 +238,9 @@ lbox_stat_net_thread_index(struct lua_State *L)
 	return 1;
 }
 
+/**
+ * Same as `lbox_stat_net_call` but for thread with given id.
+ */
 static int
 lbox_stat_net_thread_call(struct lua_State *L)
 {
-- 
GitLab