daniel submitted this change.
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(-)
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 change 33344. To unsubscribe, or for help writing mail filters, visit settings.