mirror of
https://gitea.osmocom.org/cellular-infrastructure/osmo-mgw.git
synced 2025-11-02 13:03:33 +00:00
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
This commit is contained in:
committed by
Neels Hofmeyr
parent
1fd50e5306
commit
32d15cc8ba
@@ -735,26 +735,15 @@ static int mgcp_do_read(struct osmo_fd *fd)
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user