Session has to be open in order to have a valid session_id
---
src/sim.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/sim.c b/src/sim.c
index 793ff64a..3319ecee 100644
--- a/src/sim.c
+++ b/src/sim.c
@@ -3805,7 +3805,8 @@ void __ofono_sim_remove_session_watch(struct ofono_sim_aid_session
*session,
{
__ofono_watchlist_remove_item(session->watches, id);
- if (g_slist_length(session->watches->items) == 0) {
+ if (g_slist_length(session->watches->items) == 0 &&
+ session->state == SESSION_STATE_OPEN) {
/* last watcher, close session */
session->state = SESSION_STATE_CLOSING;
session->sim->driver->close_channel(session->sim,
--
2.25.1