daniel has submitted this change. ( 
https://gerrit.osmocom.org/c/libosmo-netif/+/33344 )

Change subject: stream: Set state to closed before calling disconnect_cb()
......................................................................

stream: Set state to closed before calling disconnect_cb()

Fixes recent crashes in ttcn-cbc-test

Change-Id: I40ceb17c32d1f58f8d0eeda8d1d794cf3f478e83
Related: OS#6063
---
M src/stream.c
1 file changed, 17 insertions(+), 3 deletions(-)

Approvals:
  Jenkins Builder: Verified
  laforge: Looks good to me, but someone else must approve
  fixeria: Looks good to me, approved; Verified




diff --git a/src/stream.c b/src/stream.c
index 31aa058..c710e1b 100644
--- a/src/stream.c
+++ b/src/stream.c
@@ -337,6 +337,8 @@
  *  abstraction and close the socket */
 void osmo_stream_cli_close(struct osmo_stream_cli *cli)
 {
+       int old_state = cli->state;
+
        if (cli->state == STREAM_CLI_STATE_CLOSED)
                return;
        if (cli->state == STREAM_CLI_STATE_WAIT_RECONNECT) {
@@ -357,13 +359,13 @@
                OSMO_ASSERT(false);
        }

-       if (cli->state == STREAM_CLI_STATE_CONNECTED) {
+       cli->state = STREAM_CLI_STATE_CLOSED;
+
+       if (old_state == STREAM_CLI_STATE_CONNECTED) {
                LOGSCLI(cli, LOGL_DEBUG, "connection closed\n");
                if (cli->disconnect_cb)
                        cli->disconnect_cb(cli);
        }
-
-       cli->state = STREAM_CLI_STATE_CLOSED;
 }

 static inline int osmo_stream_cli_fd(const struct osmo_stream_cli *cli)

--
To view, visit https://gerrit.osmocom.org/c/libosmo-netif/+/33344
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmo-netif
Gerrit-Branch: master
Gerrit-Change-Id: I40ceb17c32d1f58f8d0eeda8d1d794cf3f478e83
Gerrit-Change-Number: 33344
Gerrit-PatchSet: 2
Gerrit-Owner: daniel <[email protected]>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: daniel <[email protected]>
Gerrit-Reviewer: fixeria <[email protected]>
Gerrit-Reviewer: laforge <[email protected]>
Gerrit-MessageType: merged

Reply via email to