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

Function cbm_http_server_free

src/ui/http_server.c:1990–2011  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1988}
1989
1990bool cbm_http_server_free(cbm_http_server_t *srv) {
1991 if (!srv)
1992 return true;
1993 int run_state = atomic_load_explicit(&srv->run_state, memory_order_acquire);
1994 if (run_state == HTTP_RUN_SCHEDULED || run_state == HTTP_RUN_RUNNING)
1995 return false;
1996 for (int i = 0; i < MAX_INDEX_JOBS; i++) {
1997 if (srv->index_jobs[i].thread_started) {
1998 if (!atomic_load_explicit(&srv->index_jobs[i].completed, memory_order_acquire))
1999 return false;
2000 if (cbm_thread_join(&srv->index_jobs[i].thread) != 0)
2001 return false;
2002 srv->index_jobs[i].thread_started = false;
2003 }
2004 }
2005 if (!cbm_httpd_close(srv->listener))
2006 return false;
2007 cbm_mcp_server_free(srv->mcp);
2008 cbm_secure_zero(srv->readiness_secret, sizeof(srv->readiness_secret));
2009 free(srv);
2010 return true;
2011}
2012
2013void cbm_http_server_stop(cbm_http_server_t *srv) {
2014 if (srv) {

Calls 4

cbm_thread_joinFunction · 0.85
cbm_httpd_closeFunction · 0.85
cbm_mcp_server_freeFunction · 0.85
cbm_secure_zeroFunction · 0.85

Tested by 4

th_server_startFunction · 0.68
th_server_stopFunction · 0.68