| 1438 | } |
| 1439 | |
| 1440 | static char *application_job_failure_response(const cbm_index_worker_result_t *result, |
| 1441 | const char *log_path) { |
| 1442 | char message[1024]; |
| 1443 | if (result && result->cancellation_requested) { |
| 1444 | (void)snprintf(message, sizeof(message), |
| 1445 | "index operation cancelled before completion (its last waiting " |
| 1446 | "client disconnected or the daemon stopped). %s", |
| 1447 | CBM_MCP_INDEX_ASYNC_HINT); |
| 1448 | } else if (result && (result->supervision_failed || !result->tree_quiesced)) { |
| 1449 | (void)snprintf(message, sizeof(message), |
| 1450 | "index worker containment failed (%s); inspect log: %s", |
| 1451 | cbm_proc_outcome_str(result->outcome), log_path ? log_path : "unavailable"); |
| 1452 | } else if (result && result->response_missing) { |
| 1453 | /* #1300: name the silent clean exit, where it stopped, and the log. */ |
| 1454 | const char *log = log_path ? log_path |
| 1455 | : result->worker_log[0] ? result->worker_log |
| 1456 | : "unavailable"; |
| 1457 | (void)snprintf(message, sizeof(message), |
| 1458 | "index worker exited cleanly (exit 0) without writing a response; the " |
| 1459 | "index was not published; last phase reached: %s; inspect log: %s", |
| 1460 | result->last_phase[0] ? result->last_phase : "unknown", log); |
| 1461 | } else if (result) { |
| 1462 | (void)snprintf(message, sizeof(message), |
| 1463 | "index worker ended with %s (exit=%d, signal=%d); inspect log: %s", |
| 1464 | cbm_proc_outcome_str(result->outcome), result->exit_code, |
| 1465 | result->term_signal, log_path ? log_path : "unavailable"); |
| 1466 | } else { |
| 1467 | (void)snprintf(message, sizeof(message), "index worker could not be started"); |
| 1468 | } |
| 1469 | return cbm_mcp_text_result(message, true); |
| 1470 | } |
| 1471 | |
| 1472 | static cbm_mcp_supervised_result_disposition_t application_attempt_disposition( |
| 1473 | cbm_daemon_application_job_t *job, application_attempt_t *attempt) { |
no test coverage detected