Stefan Sperling has uploaded this change for review. ( 
https://gerrit.osmocom.org/11704


Change subject: return error code from xua_srv_conn_cb() if conn is freed
......................................................................

return error code from xua_srv_conn_cb() if conn is freed

Allow callers of xua_srv_conn_cb() to tell whether conn
was freed by returning an error code. I arbitrarily chose
ECONNABORTED as the error code to report in this case.

This is necessary because xua_srv_conn_cb(0 might be running
inside of a loop which checks for read and then write events
on the connection. If the connection is freed by xua_srv_conn_cb()
as part of processing a read event, callers should avoid further
processing of events. But if we don't return an error we are leaving
callers none the wiser and with a dangling conn pointer.

Change-Id: I7359667b2f25d6c45acc70049b2a4ee2f376a1df
Related: OS#3685
---
M src/osmo_ss7.c
1 file changed, 5 insertions(+), 1 deletion(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmo-sccp refs/changes/04/11704/1

diff --git a/src/osmo_ss7.c b/src/osmo_ss7.c
index 9805b3b..7c548bb 100644
--- a/src/osmo_ss7.c
+++ b/src/osmo_ss7.c
@@ -1424,9 +1424,11 @@
                __func__, rc, flags);
        if (rc < 0) {
                osmo_stream_srv_destroy(conn);
+               rc = -ECONNABORTED;
                goto out;
        } else if (rc == 0) {
                osmo_stream_srv_destroy(conn);
+               rc = -ECONNABORTED;
                goto out;
        } else {
                msgb_put(msg, rc);
@@ -1440,16 +1442,18 @@
                switch (notif->sn_header.sn_type) {
                case SCTP_SHUTDOWN_EVENT:
                        osmo_stream_srv_destroy(conn);
+                       rc = -ECONNABORTED;
                        break;
                case SCTP_ASSOC_CHANGE:
                        if (notif->sn_assoc_change.sac_state == SCTP_RESTART)
                                xua_asp_send_xlm_prim_simple(asp, 
OSMO_XLM_PRIM_M_SCTP_RESTART,
                                                             
PRIM_OP_INDICATION);
+                       rc = 0;
                        break;
                default:
+                       rc = 0;
                        break;
                }
-               rc = 0;
                goto out;
        }


--
To view, visit https://gerrit.osmocom.org/11704
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmo-sccp
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I7359667b2f25d6c45acc70049b2a4ee2f376a1df
Gerrit-Change-Number: 11704
Gerrit-PatchSet: 1
Gerrit-Owner: Stefan Sperling <[email protected]>

Reply via email to