diff options
-rw-r--r-- | src/osmo-bsc/cbsp_link.c | 37 |
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) { |