trxcon: improve L1CTL connection related logging

* l1ctl_client_conn_close(): log "Closing L1CTL connection";
* l1ctl_client_read_cb(): more precise logging, use strerror().

Change-Id: Ie932513f93fd7f1a5f5e70f4d78235551f7599c8
Related: OS#5599
This commit is contained in:
Vadim Yanitskiy 2022-07-30 05:33:36 +07:00
parent 12d1b9788e
commit b3aece3239
1 changed files with 11 additions and 5 deletions

View File

@ -50,12 +50,16 @@ static int l1ctl_client_read_cb(struct osmo_fd *ofd)
/* Attempt to read from socket */
rc = read(ofd->fd, &len, L1CTL_MSG_LEN_FIELD);
if (rc < L1CTL_MSG_LEN_FIELD) {
LOGP_CLI(client, DL1D, LOGL_NOTICE,
"L1CTL server has lost connection (id=%u)\n",
client->id);
if (rc >= 0)
if (rc != L1CTL_MSG_LEN_FIELD) {
if (rc <= 0) {
LOGP_CLI(client, DL1D, LOGL_NOTICE,
"L1CTL connection error: read() failed (rc=%d): %s\n",
rc, strerror(errno));
} else {
LOGP_CLI(client, DL1D, LOGL_NOTICE,
"L1CTL connection error: short read\n");
rc = -EIO;
}
l1ctl_client_conn_close(client);
return rc;
}
@ -199,6 +203,8 @@ void l1ctl_client_conn_close(struct l1ctl_client *client)
{
struct l1ctl_server *server = client->server;
LOGP_CLI(client, DL1C, LOGL_NOTICE, "Closing L1CTL connection\n");
if (server->cfg->conn_close_cb != NULL)
server->cfg->conn_close_cb(client);