| 1762 | } |
| 1763 | |
| 1764 | static void application_job_publish(cbm_daemon_application_job_t *job, |
| 1765 | application_job_execution_t *execution) { |
| 1766 | if (!execution->response) { |
| 1767 | execution->response = application_job_failure_response( |
| 1768 | execution->have_last_result ? &execution->last_result : NULL, |
| 1769 | execution->last_log[0] ? execution->last_log : NULL); |
| 1770 | } |
| 1771 | bool cancelled = execution->have_last_result && execution->last_result.cancellation_requested; |
| 1772 | cbm_log(execution->successful ? CBM_LOG_INFO |
| 1773 | : cancelled ? CBM_LOG_WARN |
| 1774 | : CBM_LOG_ERROR, |
| 1775 | "daemon.index.result", "project", job->project_key, "path", job->root_path, "status", |
| 1776 | execution->successful ? "indexed" |
| 1777 | : cancelled ? "cancelled" |
| 1778 | : "failed", |
| 1779 | NULL); |
| 1780 | cbm_daemon_application_t *application = job->application; |
| 1781 | cbm_mutex_lock(&application->mutex); |
| 1782 | job->response = execution->response; |
| 1783 | job->successful = execution->successful; |
| 1784 | job->cancelled = execution->have_last_result && execution->last_result.cancellation_requested; |
| 1785 | job->supervision_failed = execution->supervision_failed || |
| 1786 | (execution->unsafe_terminal && execution->have_last_result && |
| 1787 | !execution->last_result.cancellation_requested); |
| 1788 | job->terminal = true; |
| 1789 | job->thread_done = true; |
| 1790 | application_index_record_finish_locked(job); |
| 1791 | if (job->async_owned) { |
| 1792 | /* The async reference ends with the job; terminal, so no cancel. */ |
| 1793 | job->async_owned = false; |
| 1794 | application_job_unsubscribe_locked(job); |
| 1795 | } |
| 1796 | for (cbm_daemon_application_session_t *session = application->sessions; session; |
| 1797 | session = session->next) { |
| 1798 | if (session->auto_index_job != job || !session->auto_index_subscribed) { |
| 1799 | continue; |
| 1800 | } |
| 1801 | session->auto_index_job = NULL; |
| 1802 | session->auto_index_subscribed = false; |
| 1803 | application_job_unsubscribe_locked(job); |
| 1804 | if (job->successful) { |
| 1805 | application_refresh_watch_locked(session); |
| 1806 | } |
| 1807 | } |
| 1808 | application_auto_index_retry_pending_locked(application); |
| 1809 | cbm_mem_class_flush_thread(); |
| 1810 | cbm_mutex_unlock(&application->mutex); |
| 1811 | } |
| 1812 | |
| 1813 | static void *application_job_thread(void *opaque) { |
| 1814 | cbm_daemon_application_job_t *job = opaque; |
no test coverage detected