Change in osmo-e1d[master]: close timeslot socket if read or write returns negative

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:22 UTC 2020


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


Change subject: close timeslot socket if read or write returns negative
......................................................................

close timeslot socket if read or write returns negative

If the user application has closed the timeslot socket, we will
get error returns from read/write calls, which we must use to clean
up the daemon-side state for this timeslot.

Change-Id: I2e3e5010f36e916b4c8908af91447b3d3661123f
---
M src/intf_line.c
1 file changed, 15 insertions(+), 2 deletions(-)



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

diff --git a/src/intf_line.c b/src/intf_line.c
index 9118232..fdfaa82 100644
--- a/src/intf_line.c
+++ b/src/intf_line.c
@@ -142,9 +142,14 @@
 		);
 
 		if (rv > 0) {
+			int bytes_to_write = rv;
 			LOGP(DXFR, LOGL_DEBUG, "RX Message: %d %d [ %s]\n",
 				ts->id, rv, osmo_hexdump(ts->rx_buf, rv));
-			write(ts->fd, ts->rx_buf, rv);
+			rv = write(ts->fd, ts->rx_buf, bytes_to_write);
+			if (rv < 0 && errno != EAGAIN) {
+				e1_ts_stop(ts);
+				return -1;
+			}
 		} else  if (rv < 0 && ts->id == 4) {
 			LOGP(DXFR, LOGL_ERROR, "ERR RX: %d %d %d [ %s]\n",
 				rv,oi,cl, osmo_hexdump(buf, len));
@@ -172,6 +177,9 @@
 					ts->id, rv, osmo_hexdump(ts->tx_buf, rv));
 				ts->tx_len = rv; 
 				ts->tx_ofs = 0;
+			} else if (rv < 0 && errno != EAGAIN) {
+				e1_ts_stop(ts);
+				return -1;
 			}
 		}
 
@@ -229,6 +237,8 @@
 		switch (ts->mode) {
 		case E1_TS_MODE_RAW:
 			l = read(ts->fd, buf_ts, fts);
+			if (l < 0 && errno != EAGAIN)
+				e1_ts_stop(ts);
 			break;
 		case E1_TS_MODE_HDLCFCS:
 			l = _e1_tx_hdlcfs(ts, buf_ts, fts);
@@ -269,6 +279,7 @@
 	{
 		struct e1_ts *ts = &line->ts[tsn];
 		uint8_t buf_ts[ftr];
+		int rv;
 
 		if (ts->mode == E1_TS_MODE_OFF)
 			continue;
@@ -278,7 +289,9 @@
 
 		switch (ts->mode) {
 		case E1_TS_MODE_RAW:
-			write(ts->fd, buf_ts, ftr);
+			rv = write(ts->fd, buf_ts, ftr);
+			if (rv < 0 && errno != EAGAIN)
+				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/+/19056
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-e1d
Gerrit-Branch: master
Gerrit-Change-Id: I2e3e5010f36e916b4c8908af91447b3d3661123f
Gerrit-Change-Number: 19056
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/a3176166/attachment.htm>


More information about the gerrit-log mailing list