Change in osmo-e1d[master]: extend logging (log more noteworthy events)

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
Mon Jun 29 20:14:23 UTC 2020


laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-e1d/+/19058 )


Change subject: extend logging (log more noteworthy events)
......................................................................

extend logging (log more noteworthy events)

Let's log some more events that might happen.

Change-Id: I37fd290f0f0621fbf6e20e33fa709efc14df94c7
---
M src/ctl.c
M src/intf_line.c
2 files changed, 26 insertions(+), 2 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-e1d refs/changes/58/19058/1

diff --git a/src/ctl.c b/src/ctl.c
index 1fa5d84..b29e990 100644
--- a/src/ctl.c
+++ b/src/ctl.c
@@ -31,11 +31,13 @@
 
 #include <osmocom/core/isdnhdlc.h>
 #include <osmocom/core/msgb.h>
+#include <osmocom/core/logging.h>
 
 #include <osmocom/e1d/proto.h>
 #include <osmocom/e1d/proto_srv.h>
 
 #include "e1d.h"
+#include "log.h"
 
 
 struct e1_intf *
@@ -94,6 +96,8 @@
 void
 e1_ts_stop(struct e1_ts *ts)
 {
+	LOGPTS(ts, DE1D, LOGL_INFO, "Stopping\n");
+
 	ts->mode = E1_TS_MODE_OFF;
 
 	if (ts->fd >= 0) {
@@ -107,6 +111,8 @@
 {
 	int ret, sd[2];
 
+	LOGPTS(ts, DE1D, LOGL_INFO, "Starting in mode %u\n", mode);
+
 	ret = socketpair(AF_UNIX, SOCK_SEQPACKET, 0, sd);
 	if (ret < 0)
 		return ret;
diff --git a/src/intf_line.c b/src/intf_line.c
index 335fb83..7127617 100644
--- a/src/intf_line.c
+++ b/src/intf_line.c
@@ -64,6 +64,8 @@
 
 	llist_add_tail(&intf->list, &e1d->interfaces);
 
+	LOGPIF(intf, DE1D, LOGL_NOTICE, "Created\n");
+
 	return intf;
 }
 
@@ -72,6 +74,8 @@
 {
 	struct e1_line *line, *line2;
 
+	LOGPIF(intf, DE1D, LOGL_NOTICE, "Destroying\n");
+
 	/* destroy all lines */
 	llist_for_each_entry_safe(line, line2, &intf->lines, list)
 		e1_line_destroy(line);
@@ -107,12 +111,16 @@
 
 	llist_add_tail(&line->list, &intf->lines);
 
+	LOGPLI(line, DE1D, LOGL_NOTICE, "Created\n");
+
 	return line;
 }
 
 void
 e1_line_destroy(struct e1_line *line)
 {
+	LOGPLI(line, DE1D, LOGL_NOTICE, "Destroying\n");
+
 	/* close all [peer] file descriptors */
 	for (int i=0; i<32; i++)
 		e1_ts_stop(&line->ts[i]);
@@ -147,6 +155,8 @@
 				rv, osmo_hexdump(ts->rx_buf, rv));
 			rv = write(ts->fd, ts->rx_buf, bytes_to_write);
 			if (rv < 0 && errno != EAGAIN) {
+				LOGPTS(ts, DE1D, LOGL_ERROR, "dead socket during write: %s\n",
+					strerror(errno));
 				e1_ts_stop(ts);
 				return -1;
 			}
@@ -178,6 +188,8 @@
 				ts->tx_len = rv; 
 				ts->tx_ofs = 0;
 			} else if (rv < 0 && errno != EAGAIN) {
+				LOGPTS(ts, DE1D, LOGL_ERROR, "dead socket during read: %s\n",
+					strerror(errno));
 				e1_ts_stop(ts);
 				return -1;
 			}
@@ -237,8 +249,11 @@
 		switch (ts->mode) {
 		case E1_TS_MODE_RAW:
 			l = read(ts->fd, buf_ts, fts);
-			if (l < 0 && errno != EAGAIN)
+			if (l < 0 && errno != EAGAIN) {
+				LOGPTS(ts, DE1D, LOGL_ERROR, "dead socket during read: %s\n",
+					strerror(errno));
 				e1_ts_stop(ts);
+			}
 			break;
 		case E1_TS_MODE_HDLCFCS:
 			l = _e1_tx_hdlcfs(ts, buf_ts, fts);
@@ -290,8 +305,11 @@
 		switch (ts->mode) {
 		case E1_TS_MODE_RAW:
 			rv = write(ts->fd, buf_ts, ftr);
-			if (rv < 0 && errno != EAGAIN)
+			if (rv < 0 && errno != EAGAIN) {
+				LOGPTS(ts, DE1D, LOGL_ERROR, "dead socket during write: %s\n",
+					strerror(errno));
 				e1_ts_stop(ts);
+			}
 			break;
 		case E1_TS_MODE_HDLCFCS:
 			_e1_rx_hdlcfs(ts, buf_ts, ftr);

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-e1d/+/19058
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-e1d
Gerrit-Branch: master
Gerrit-Change-Id: I37fd290f0f0621fbf6e20e33fa709efc14df94c7
Gerrit-Change-Number: 19058
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge at osmocom.org>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200629/d0278162/attachment.htm>


More information about the gerrit-log mailing list