pespin has submitted this change. (
https://gerrit.osmocom.org/c/osmo-bsc/+/36576?usp=email )
Change subject: cbsp_link.c: Update somo_stream read_cb2 functions to accommodate for new
API param
......................................................................
cbsp_link.c: Update somo_stream read_cb2 functions to accommodate for new API param
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
---
M src/osmo-bsc/cbsp_link.c
1 file changed, 54 insertions(+), 2 deletions(-)
Approvals:
Jenkins Builder: Verified
pespin: Looks good to me, approved
diff --git a/src/osmo-bsc/cbsp_link.c b/src/osmo-bsc/cbsp_link.c
index 98f25d3..9e17ef3 100644
--- a/src/osmo-bsc/cbsp_link.c
+++ b/src/osmo-bsc/cbsp_link.c
@@ -62,11 +62,28 @@
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 @@
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) {
--
To view, visit
https://gerrit.osmocom.org/c/osmo-bsc/+/36576?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Change-Id: I4cce5cb6ca98bc28a67dd6e927e9cdfd2312851a
Gerrit-Change-Number: 36576
Gerrit-PatchSet: 2
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: osmith <osmith(a)sysmocom.de>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
Gerrit-MessageType: merged