From 98c75ef27319690bd214c60457919806d7bf70f7 Mon Sep 17 00:00:00 2001 From: Pau Espin Pedrol Date: Tue, 13 Sep 2022 12:47:30 +0200 Subject: [PATCH] stream: Unset fd value after close() before calling closed_cb() The fd is not valid anymore after close() call, so let's set it to a clearly invalid value, to avoid confusion on closed_cb() users attempting to use the fd get info about the socket at that time. Change-Id: I82d9bdfb38cf5e9f689eca0d9a4c19ddd5541af7 --- src/stream.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/stream.c b/src/stream.c index f090c4f..bc209af 100644 --- a/src/stream.c +++ b/src/stream.c @@ -1439,8 +1439,9 @@ struct osmo_stream_srv_link *osmo_stream_srv_get_master(struct osmo_stream_srv * * \param[in] conn Stream Server to be destroyed */ void osmo_stream_srv_destroy(struct osmo_stream_srv *conn) { - close(conn->ofd.fd); osmo_fd_unregister(&conn->ofd); + close(conn->ofd.fd); + conn->ofd.fd = -1; if (conn->closed_cb) conn->closed_cb(conn); msgb_queue_free(&conn->tx_queue);