Change in osmo-mgw[master]: drop/replace very weird logging in mgcp_client.c

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

Neels Hofmeyr gerrit-no-reply at lists.osmocom.org
Wed Dec 12 03:49:12 UTC 2018


Neels Hofmeyr has uploaded this change for review. ( https://gerrit.osmocom.org/12269


Change subject: drop/replace very weird logging in mgcp_client.c
......................................................................

drop/replace very weird logging in mgcp_client.c

mgcp_do_write() is the final stage of writing data towards the MGCP server
(MGW). In that function, drop an unconditional iteration and copy of the MGCP
message to a static string buffer for no apparent reason besides debug logging.

Instead, use osmo_escape_str() with a limited length, which can just be an
inline format argument in the LOGP() statement. This way, the string mangling
is simpler and only gets run when DMGCP is actually on debug log level.

Change-Id: Id6877ed7fd7dbe009b2ece8792d5160d040c1aaa
---
M src/libosmo-mgcp-client/mgcp_client.c
1 file changed, 5 insertions(+), 16 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-mgw refs/changes/69/12269/1

diff --git a/src/libosmo-mgcp-client/mgcp_client.c b/src/libosmo-mgcp-client/mgcp_client.c
index 2a8cc15..fc9c5d3 100644
--- a/src/libosmo-mgcp-client/mgcp_client.c
+++ b/src/libosmo-mgcp-client/mgcp_client.c
@@ -735,26 +735,15 @@
 static int mgcp_do_write(struct osmo_fd *fd, struct msgb *msg)
 {
 	int ret;
-	static char strbuf[4096];
-	unsigned int l = msg->len < sizeof(strbuf) ? msg->len : sizeof(strbuf);
-	unsigned int i;
 
-	osmo_strlcpy(strbuf, (const char*)msg->data, l);
-	for (i = 0; i < sizeof(strbuf); i++) {
-		if (strbuf[i] == '\n' || strbuf[i] == '\r') {
-			strbuf[i] = '\0';
-			break;
-		}
-	}
-	DEBUGP(DLMGCP, "Tx MGCP msg to MGCP GW: '%s'\n", strbuf);
-
-	LOGP(DLMGCP, LOGL_DEBUG, "Sending msg to MGCP GW size: %u\n", msg->len);
+	LOGP(DLMGCP, LOGL_DEBUG, "Sending msg to MGCP GW size: len=%u '%s'...\n",
+	     msg->len, osmo_escape_str((const char*)msg->data, OSMO_MIN(42, msg->len)));
 
 	ret = write(fd->fd, msg->data, msg->len);
 	if (ret != msg->len)
-		LOGP(DLMGCP, LOGL_ERROR, "Failed to forward message to MGCP"
-		     " GW: %s\n", strerror(errno));
-
+		LOGP(DLMGCP, LOGL_ERROR, "Failed to Tx MGCP: %d='%s'; msg: len=%u '%s'...\n",
+		     errno, strerror(errno),
+		     msg->len, osmo_escape_str((const char*)msg->data, OSMO_MIN(42, msg->len)));
 	return ret;
 }
 

-- 
To view, visit https://gerrit.osmocom.org/12269
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Id6877ed7fd7dbe009b2ece8792d5160d040c1aaa
Gerrit-Change-Number: 12269
Gerrit-PatchSet: 1
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20181212/6e4da89a/attachment.htm>


More information about the gerrit-log mailing list