Change in libosmo-netif[master]: stream: Add new WAIT_RECONNECT cli state

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

laforge gerrit-no-reply at lists.osmocom.org
Tue Jan 28 21:41:55 UTC 2020


laforge has submitted this change. ( https://gerrit.osmocom.org/c/libosmo-netif/+/17031 )

Change subject: stream: Add new WAIT_RECONNECT cli state
......................................................................

stream: Add new WAIT_RECONNECT cli state

It's not really needed right now from logic point of view, since we
reused NONE for that. But it makes logging and logic clearer, and will
make it easier if we decide to move it to FSMs at a later point in time.

Other state value_string names are also modified with its whitespace
removed since anyway we'd need to change them to match WAIT_RECONNECT
length. Let's drop the space because imho it's not that useful and
anyway if we move to FSMs at some point then we won't have them anyway.

Change-Id: I7b9a6da87081c418b0d14bab5f34369c5eca6fe8
---
M src/stream.c
M tests/stream/stream_test.err
2 files changed, 14 insertions(+), 10 deletions(-)

Approvals:
  Jenkins Builder: Verified
  fixeria: Looks good to me, but someone else must approve
  laforge: Looks good to me, approved



diff --git a/src/stream.c b/src/stream.c
index c47ae3e..8a063f2 100644
--- a/src/stream.c
+++ b/src/stream.c
@@ -129,16 +129,18 @@
  */
 
 enum osmo_stream_cli_state {
-        STREAM_CLI_STATE_NONE         = 0, /* No fd associated, may have timer active to try to connect again */
-        STREAM_CLI_STATE_CONNECTING   = 1, /* Fd associated, but connection not yet confirmed by peer or lower layers */
-        STREAM_CLI_STATE_CONNECTED    = 2, /* Fd associated and connection is established */
+        STREAM_CLI_STATE_NONE, 		 /* No fd associated, no timer active */
+        STREAM_CLI_STATE_WAIT_RECONNECT, /* No fd associated, has timer active to try to connect again */
+        STREAM_CLI_STATE_CONNECTING,	 /* Fd associated, but connection not yet confirmed by peer or lower layers */
+        STREAM_CLI_STATE_CONNECTED,	 /* Fd associated and connection is established */
         STREAM_CLI_STATE_MAX
 };
 
 static const struct value_string stream_cli_state_names[] = {
-	{ STREAM_CLI_STATE_NONE,       "      NONE" },
-	{ STREAM_CLI_STATE_CONNECTING, "CONNECTING" },
-	{ STREAM_CLI_STATE_CONNECTED,  " CONNECTED" },
+	{ STREAM_CLI_STATE_NONE,           "NONE" },
+	{ STREAM_CLI_STATE_WAIT_RECONNECT, "WAIT_RECONNECT" },
+	{ STREAM_CLI_STATE_CONNECTING,     "CONNECTING" },
+	{ STREAM_CLI_STATE_CONNECTED,      "CONNECTED" },
 	{ 0, NULL }
 };
 
@@ -187,6 +189,7 @@
 		return;
 	}
 
+	cli->state = STREAM_CLI_STATE_WAIT_RECONNECT;
 	LOGSCLI(cli, LOGL_INFO, "retrying in %d seconds...\n",
 		cli->reconnect_timeout);
 	osmo_timer_schedule(&cli->timer, cli->reconnect_timeout, 0);
@@ -669,6 +672,7 @@
 	return 0;
 
 error_close_socket:
+	cli->state = STREAM_CLI_STATE_NONE;
 	close(cli->ofd.fd);
 	cli->ofd.fd = -1;
 	return -EIO;
diff --git a/tests/stream/stream_test.err b/tests/stream/stream_test.err
index 04bfcfe..69a0b85 100644
--- a/tests/stream/stream_test.err
+++ b/tests/stream/stream_test.err
@@ -12,8 +12,8 @@
 {2.000006} autoreconnecting test step 6 [client OK, server OK], FD reg 1
 
 {2.000007} autoreconnecting test step 5 [client OK, server OK], FD reg 1
-[ CONNECTED] osmo_stream_cli_recv(): connection closed with srv
-[      NONE] osmo_stream_cli_reconnect(): retrying in 9 seconds...
+[CONNECTED] osmo_stream_cli_recv(): connection closed with srv
+[WAIT_RECONNECT] osmo_stream_cli_reconnect(): retrying in 9 seconds...
 
 {11.000008} autoreconnecting test step 4 [client OK, server OK], FD reg 0
 
@@ -37,7 +37,7 @@
 {11.000017} non-reconnecting test step 2 [client OK, server OK], FD reg 1
 
 {11.000018} non-reconnecting test step 1 [client OK, server OK], FD reg 1
-[ CONNECTED] osmo_stream_cli_recv(): connection closed with srv
-[      NONE] osmo_stream_cli_reconnect(): not reconnecting, disabled.
+[CONNECTED] osmo_stream_cli_recv(): connection closed with srv
+[NONE] osmo_stream_cli_reconnect(): not reconnecting, disabled.
 
 {20.000019} non-reconnecting test step 0 [client OK, server OK], FD reg 0

-- 
To view, visit https://gerrit.osmocom.org/c/libosmo-netif/+/17031
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: libosmo-netif
Gerrit-Branch: master
Gerrit-Change-Id: I7b9a6da87081c418b0d14bab5f34369c5eca6fe8
Gerrit-Change-Number: 17031
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <axilirator at gmail.com>
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200128/ef81787f/attachment.htm>


More information about the gerrit-log mailing list