aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Willmann <dwillmann@sysmocom.de>2023-06-16 22:43:46 +0200
committerdaniel <dwillmann@sysmocom.de>2023-06-17 06:18:03 +0000
commit14c1df98811165d3085de6be1244569137d59844 (patch)
tree810b3a39cf7418d1e9c949a951f3dd882af82466
parent39f99fa3cea8e8c8772d07f037804d3fdc2f2df5 (diff)
stream: Set state to closed before calling disconnect_cb()
Fixes recent crashes in ttcn-cbc-test Change-Id: I40ceb17c32d1f58f8d0eeda8d1d794cf3f478e83 Related: OS#6063
-rw-r--r--src/stream.c8
1 files changed, 5 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 @@ static void osmo_stream_cli_close_ofd(struct osmo_stream_cli *cli)
* 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 @@ void osmo_stream_cli_close(struct osmo_stream_cli *cli)
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)