MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / host_state_free

Function host_state_free

src/daemon/host.c:540–566  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

538}
539
540static void host_state_free(host_state_t *host) {
541 if (!host_http_stop_join_free(host)) {
542 /* The retained server or one of its callbacks can still borrow every
543 * dependency below. Process containment is the only safe teardown. */
544 host_force_terminate("http_cleanup");
545 }
546 if (host->application) {
547 if (!cbm_daemon_application_free(host->application)) {
548 /* The application still owns work or a borrowed callback context.
549 * Freeing any dependency below would turn the retained application
550 * into UAF. The daemon is the ultimate containment boundary. */
551 host_cleanup_force_terminate("application_cleanup");
552 }
553 host->application = NULL;
554 }
555 cbm_watcher_free(host->watcher);
556 host->watcher = NULL;
557 cbm_store_close(host->watch_store);
558 host->watch_store = NULL;
559 cbm_config_close(host->runtime_config);
560 host->runtime_config = NULL;
561 if (host->project_locks) {
562 host_cleanup_release_until_complete(host_project_lock_manager_free_once,
563 &host->project_locks, "project_lock_manager_cleanup");
564 }
565 cbm_secure_zero(host->ui_readiness_secret, sizeof(host->ui_readiness_secret));
566}
567
568static bool host_state_prepare(host_state_t *host, const cbm_daemon_ipc_endpoint_t *endpoint) {
569 host->http_ops = &g_host_http_default_ops;

Callers 2

cbm_daemon_host_runFunction · 0.85

Calls 9

host_http_stop_join_freeFunction · 0.85
host_force_terminateFunction · 0.85
cbm_watcher_freeFunction · 0.85
cbm_store_closeFunction · 0.85
cbm_config_closeFunction · 0.85
cbm_secure_zeroFunction · 0.85

Tested by

no test coverage detected