laforge has submitted this change. ( https://gerrit.osmocom.org/c/osmo-cbc/+/28704 )
Change subject: Use cbc_{cbsp,sbcap}_link_close when possible ......................................................................
Use cbc_{cbsp,sbcap}_link_close when possible
This way we abstract whether the underlaying stream is a TCP/SCTP client or server.
Change-Id: Ie020b9b5ee93ae8d0c9e7266177728185e8635f2 --- M src/cbsp_link.c M src/cbsp_link_fsm.c M src/sbcap_link.c M src/sbcap_link_fsm.c 4 files changed, 14 insertions(+), 14 deletions(-)
Approvals: Jenkins Builder: Verified fixeria: Looks good to me, but someone else must approve osmith: Looks good to me, but someone else must approve laforge: Looks good to me, approved
diff --git a/src/cbsp_link.c b/src/cbsp_link.c index 1aa8159..bc421f2 100644 --- a/src/cbsp_link.c +++ b/src/cbsp_link.c @@ -75,7 +75,7 @@
} /* destroy connection */ - osmo_stream_srv_destroy(conn); + cbc_cbsp_link_close(link); return -EBADF; } OSMO_ASSERT(msg); @@ -134,7 +134,7 @@ link->fi = osmo_fsm_inst_alloc(&cbsp_link_fsm, link, link, LOGL_DEBUG, NULL); if (!link->fi) { LOGPCC(link, LOGL_ERROR, "Unable to allocate FSM\n"); - osmo_stream_srv_destroy(link->conn); + cbc_cbsp_link_close(link); talloc_free(link); return -1; } @@ -152,7 +152,7 @@ } else { LOGPCC(link, LOGL_NOTICE, "Rejecting unknown CBSP peer %s:%d (not permitted)\n", remote_ip, remote_port); - osmo_stream_srv_destroy(link->conn); + cbc_cbsp_link_close(link); return -1; } } else { @@ -194,7 +194,8 @@
void cbc_cbsp_link_close(struct cbc_cbsp_link *link) { - osmo_stream_srv_destroy(link->conn); + if (link->conn) + osmo_stream_srv_destroy(link->conn); }
/* initialize the CBC-side CBSP server */ diff --git a/src/cbsp_link_fsm.c b/src/cbsp_link_fsm.c index 3526901..d46a83e 100644 --- a/src/cbsp_link_fsm.c +++ b/src/cbsp_link_fsm.c @@ -196,8 +196,7 @@ { struct cbc_cbsp_link *link = (struct cbc_cbsp_link *) fi->priv;
- if (link->conn) - osmo_stream_srv_destroy(link->conn); + cbc_cbsp_link_close(link); llist_del(&link->list); link->fi = NULL;
diff --git a/src/sbcap_link.c b/src/sbcap_link.c index 19912f8..4656f6d 100644 --- a/src/sbcap_link.c +++ b/src/sbcap_link.c @@ -73,10 +73,10 @@ LOGPSBCAPC(link, LOGL_DEBUG, "%s(): sctp_recvmsg() returned %d (flags=0x%x)\n", __func__, rc, flags); if (rc < 0) { - osmo_stream_srv_destroy(conn); + cbc_sbcap_link_close(link); goto out; } else if (rc == 0) { - osmo_stream_srv_destroy(conn); + cbc_sbcap_link_close(link); } else { msgb_put(msg, rc); } @@ -87,7 +87,7 @@ osmo_sctp_sn_type_str(notif->sn_header.sn_type)); switch (notif->sn_header.sn_type) { case SCTP_SHUTDOWN_EVENT: - osmo_stream_srv_destroy(conn); + cbc_sbcap_link_close(link); break; case SCTP_ASSOC_CHANGE: LOGPSBCAPC(link, LOGL_DEBUG, "Rx sctp notif SCTP_ASSOC_CHANGE: %s\n", @@ -162,7 +162,7 @@ link->fi = osmo_fsm_inst_alloc(&sbcap_link_fsm, link, link, LOGL_DEBUG, NULL); if (!link->fi) { LOGPSBCAPC(link, LOGL_ERROR, "Unable to allocate FSM\n"); - osmo_stream_srv_destroy(link->conn); + cbc_sbcap_link_close(link); talloc_free(link); return -1; } @@ -180,7 +180,7 @@ } else { LOGPSBCAPC(link, LOGL_NOTICE, "Rejecting unknown SBc-AP peer %s:%d (not permitted)\n", remote_ip, remote_port); - osmo_stream_srv_destroy(link->conn); + cbc_sbcap_link_close(link); return -1; } } else { @@ -223,7 +223,8 @@
void cbc_sbcap_link_close(struct cbc_sbcap_link *link) { - osmo_stream_srv_destroy(link->conn); + if (link->conn) + osmo_stream_srv_destroy(link->conn); }
/* initialize the CBC-side SBc-AP server */ diff --git a/src/sbcap_link_fsm.c b/src/sbcap_link_fsm.c index f8d23cd..9447520 100644 --- a/src/sbcap_link_fsm.c +++ b/src/sbcap_link_fsm.c @@ -94,8 +94,7 @@ { struct cbc_sbcap_link *link = (struct cbc_sbcap_link *) fi->priv;
- if (link->conn) - osmo_stream_srv_destroy(link->conn); + cbc_sbcap_link_close(link); llist_del(&link->list); link->fi = NULL;