stream: Set state to closed before calling disconnect_cb()

Fixes recent crashes in ttcn-cbc-test

Change-Id: I40ceb17c32d1f58f8d0eeda8d1d794cf3f478e83
Related: OS#6063
This commit is contained in:
Daniel Willmann 2023-06-16 22:43:46 +02:00 committed by daniel
parent 39f99fa3ce
commit 14c1df9881
1 changed files with 5 additions and 3 deletions

View File

@ -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)