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
This commit is contained in:
Pau Espin 2022-09-13 12:47:30 +02:00
parent 2087d61c21
commit 98c75ef273
1 changed files with 2 additions and 1 deletions

View File

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