[MERGED] libosmocore[master]: Handle replies in ctrl_cmd_handle()

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/.

Max gerrit-no-reply at lists.osmocom.org
Wed Mar 1 16:38:00 UTC 2017


Max has submitted this change and it was merged.

Change subject: Handle replies in ctrl_cmd_handle()
......................................................................


Handle replies in ctrl_cmd_handle()

Previously *_REPLY and ERROR messages were not explicitly handled which
would lead to sending error in response to them which in turn would
prompt other party to send error as well which would result in infinite
cycle.

Handle it explicitly by logging message id and other relevant data.

Change-Id: Id96f3a2fc81fa4549f49556d83f062c6b2f59e28
Related: OS#1615
---
M src/ctrl/control_if.c
1 file changed, 17 insertions(+), 0 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/ctrl/control_if.c b/src/ctrl/control_if.c
index de49d16..f49d639 100644
--- a/src/ctrl/control_if.c
+++ b/src/ctrl/control_if.c
@@ -186,6 +186,23 @@
 
 	vector vline, cmdvec, cmds_vec;
 
+	if (cmd->type == CTRL_TYPE_SET_REPLY ||
+	    cmd->type == CTRL_TYPE_GET_REPLY) {
+		if (strncmp(cmd->reply, "OK", 2) == 0) {
+			LOGP(DLCTRL, LOGL_DEBUG, "%s <%s> for %s is OK\n",
+			     get_value_string(ctrl_type_vals, cmd->type),
+			     cmd->id, cmd->variable);
+			return CTRL_CMD_HANDLED;
+		}
+	}
+
+	if (cmd->type == CTRL_TYPE_ERROR) {
+			LOGP(DLCTRL, LOGL_ERROR, "%s <%s> for %s is %s\n",
+			     get_value_string(ctrl_type_vals, cmd->type),
+			     cmd->id, cmd->variable, cmd->reply);
+			return CTRL_CMD_HANDLED;
+	}
+
 	ret = CTRL_CMD_ERROR;
 	cmd->reply = NULL;
 	node = CTRL_NODE_ROOT;

-- 
To view, visit https://gerrit.osmocom.org/1896
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Id96f3a2fc81fa4549f49556d83f062c6b2f59e28
Gerrit-PatchSet: 4
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Max <msuraev at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max <msuraev at sysmocom.de>



More information about the gerrit-log mailing list