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

Function index_thread_fn

src/ui/http_server.c:1643–1664  ·  view source on GitHub ↗

Execute through the daemon's shared job registry. The thread is retained in * its slot and joined before reuse/free; no detached operation can outlive the * daemon application that owns its callback context. */

Source from the content-addressed store, hash-verified

1641 * its slot and joined before reuse/free; no detached operation can outlive the
1642 * daemon application that owns its callback context. */
1643static void *index_thread_fn(void *arg) {
1644 index_job_t *job = arg;
1645 char *project =
1646 cbm_project_name_from_path(job->project_name[0] ? job->project_name : job->root_path);
1647 cbm_log_info("ui.index.start", "project", project ? project : "", "path", job->root_path);
1648 cbm_http_server_t *server = job->server;
1649 int result = server && server->index_executor
1650 ? server->index_executor(server->index_executor_context, job->root_path,
1651 job->project_name)
1652 : -1;
1653 if (result != 0) {
1654 snprintf(job->error_msg, sizeof(job->error_msg), "daemon index operation failed");
1655 atomic_store(&job->status, 3);
1656 } else {
1657 atomic_store(&job->status, 2);
1658 }
1659 cbm_log(result == 0 ? CBM_LOG_INFO : CBM_LOG_ERROR, "ui.index.done", "project",
1660 project ? project : "", "path", job->root_path, "rc", result == 0 ? "ok" : "err", NULL);
1661 free(project);
1662 atomic_store_explicit(&job->completed, 1, memory_order_release);
1663 return NULL;
1664}
1665
1666/* POST /api/index — body: {"root_path": "/abs/path", "project_name": "..."} */
1667static void handle_index_start(cbm_http_server_t *server, cbm_http_conn_t *c,

Callers

nothing calls this directly

Calls 2

cbm_logFunction · 0.85

Tested by

no test coverage detected