| 2791 | } |
| 2792 | |
| 2793 | static void application_session_close(void *context, |
| 2794 | cbm_daemon_runtime_application_session_t *opaque_session) { |
| 2795 | cbm_daemon_application_t *application = context; |
| 2796 | cbm_daemon_application_session_t *session = (cbm_daemon_application_session_t *)opaque_session; |
| 2797 | if (!application || !session || session->application != application) { |
| 2798 | return; |
| 2799 | } |
| 2800 | bool reap_update = false; |
| 2801 | cbm_daemon_application_job_t *join_auto_index = NULL; |
| 2802 | cbm_mutex_lock(&application->mutex); |
| 2803 | cbm_daemon_application_session_t **cursor = &application->sessions; |
| 2804 | while (*cursor && *cursor != session) { |
| 2805 | cursor = &(*cursor)->next; |
| 2806 | } |
| 2807 | if (*cursor == session) { |
| 2808 | *cursor = session->next; |
| 2809 | } |
| 2810 | if (session->active_job && session->active_job_subscribed) { |
| 2811 | application_job_unsubscribe_locked(session->active_job); |
| 2812 | session->active_job = NULL; |
| 2813 | session->active_job_subscribed = false; |
| 2814 | } |
| 2815 | join_auto_index = application_auto_index_release_locked(session); |
| 2816 | reap_update = application_update_owner_release_locked(session); |
| 2817 | reap_update = |
| 2818 | reap_update || (session->background_eligible && application->update_thread_started && |
| 2819 | application->update_owners == 0); |
| 2820 | application_release_session_watch_locked(session); |
| 2821 | cbm_mutex_unlock(&application->mutex); |
| 2822 | application_auto_index_cancel_join(application, join_auto_index); |
| 2823 | application_jobs_reap_completed(application); |
| 2824 | if (reap_update) { |
| 2825 | if (!application_update_reap(application, true, APPLICATION_BACKGROUND_REAP_MS)) { |
| 2826 | application_cleanup_force_terminate("update_cleanup"); |
| 2827 | } |
| 2828 | } |
| 2829 | cbm_mcp_server_free(session->mcp); |
| 2830 | free(session->hook_event); |
| 2831 | free(session->hook_dialect); |
| 2832 | free(session); |
| 2833 | } |
| 2834 | |
| 2835 | void cbm_daemon_application_set_permanent(cbm_daemon_application_t *application, bool permanent) { |
| 2836 | if (!application) { |
nothing calls this directly
no test coverage detected