aboutsummaryrefslogtreecommitdiffstats
path: root/src/osmo-bsc
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2024-04-16 19:37:27 +0200
committerPau Espin Pedrol <pespin@sysmocom.de>2024-04-17 16:13:39 +0200
commit9fb31c13df0d2bffc602b6cc7f67b76033471874 (patch)
tree1e0af2bd36b9fcbf0bce170c1ba7290745aec218 /src/osmo-bsc
parentd7afb4341e3c1b1caa85918badb8d54b5de8706f (diff)
cbsp_link.c: Update somo_stream read_cb2 functions to accommodate for new API paramHEADpespin/streammaster
libosmo-netif (not yet released) stream_{cli,srv} osmo_io read_cb API was updated to provide read result status. Hence, now API users can account for lower layer errors and act properly, like it used to do with the previous ofd backend. This commit partially reverts some error code paths removed in 85687bf176e4b9663f2396a27c28b49221c72fa3 when converting code to use osmo_io osmo_stream backend. Change-Id: I4cce5cb6ca98bc28a67dd6e927e9cdfd2312851a Depends: libosmo-netif.git Change-Id I395c75ff1e9904757ce1d767a9ac2f779593c4c8
Diffstat (limited to 'src/osmo-bsc')
-rw-r--r--src/osmo-bsc/cbsp_link.c37
1 files changed, 35 insertions, 2 deletions
diff --git a/src/osmo-bsc/cbsp_link.c b/src/osmo-bsc/cbsp_link.c
index 98f25d358..9e17ef373 100644
--- a/src/osmo-bsc/cbsp_link.c
+++ b/src/osmo-bsc/cbsp_link.c
@@ -62,11 +62,28 @@ static int cbsp_srv_closed_cb(struct osmo_stream_srv *conn)
return 0;
}
-static int cbsp_srv_read_cb(struct osmo_stream_srv *conn, struct msgb *msg)
+static int cbsp_srv_read_cb(struct osmo_stream_srv *conn, int res, struct msgb *msg)
{
struct bsc_cbc_link *cbc = osmo_stream_srv_get_data(conn);
struct osmo_cbsp_decoded *decoded;
+ if (res <= 0) {
+ if (res == -EAGAIN || res == -EINTR) {
+ msgb_free(msg);
+ return 0;
+ }
+ /*
+ if (rc == -EPIPE || rc == -ECONNRESET) {
+ // lost connection
+ } else if (rc == 0) {
+ // connection closed
+ } */
+ msgb_free(msg);
+ osmo_stream_srv_destroy(conn);
+ cbc->server.srv = NULL;
+ return -EBADF;
+ }
+
OSMO_ASSERT(msg);
decoded = osmo_cbsp_decode(conn, msg);
if (decoded) {
@@ -148,11 +165,27 @@ static int cbsp_client_disconnect_cb(struct osmo_stream_cli *cli)
return 0;
}
-static int cbsp_client_read_cb(struct osmo_stream_cli *cli, struct msgb *msg)
+static int cbsp_client_read_cb(struct osmo_stream_cli *cli, int res, struct msgb *msg)
{
struct bsc_cbc_link *cbc = osmo_stream_cli_get_data(cli);
struct osmo_cbsp_decoded *decoded;
+ if (res <= 0) {
+ if (res == -EAGAIN || res == -EINTR) {
+ msgb_free(msg);
+ return 0;
+ }
+ /*
+ if (rc == -EPIPE || rc == -ECONNRESET) {
+ // lost connection
+ } else if (rc == 0) {
+ // connection closed
+ } */
+ msgb_free(msg);
+ osmo_stream_cli_reconnect(cli);
+ return -EBADF;
+ }
+
OSMO_ASSERT(msg);
decoded = osmo_cbsp_decode(cli, msg);
if (decoded) {