return r;
}
-
-/*
- This is called when a job has crashed.
-*/
-int pakfire_client_job_crashed(struct pakfire_client* self,
- const char* job_id, int signo, struct pakfire_buffer* log) {
- struct json_object* request = NULL;
- struct pakfire_xfer* xfer = NULL;
- int r;
-
- // Create a new request object
- r = pakfire_json_new_object(&request);
- if (r < 0)
- goto ERROR;
-
- // Add signal number
- r = pakfire_json_add_int64(request, "signo", signo);
- if (r < 0)
- goto ERROR;
-
- // Optionally append the log
- if (!pakfire_buffer_is_empty(log)) {
- r = pakfire_json_add_bytes(request, "log", log->data, log->length);
- if (r < 0)
- goto ERROR;
- }
-
- // Create a new transfer
- r = pakfire_client_xfer_create(&xfer, self, "/api/v1/jobs/%s/crashed", job_id);
- if (r < 0)
- goto ERROR;
-
- // Enable authentication
- r = pakfire_client_xfer_auth(self, xfer);
- if (r < 0)
- goto ERROR;
-
- // Set the request body
- r = pakfire_xfer_set_json_payload(xfer, request);
- if (r < 0)
- goto ERROR;
-
- // Enqueue the transfer
- r = pakfire_httpclient_enqueue(self->httpclient, xfer);
-
-ERROR:
- if (xfer)
- pakfire_xfer_unref(xfer);
-
- return r;
-}
int pakfire_client_delete_repo(struct pakfire_client* client,
const char* distro, const char* name);
-// Jobs
-
-int pakfire_client_job_crashed(struct pakfire_client* self,
- const char* job_id, int signo, struct pakfire_buffer* log);
-
#endif /* PAKFIRE_CLIENT_H */
return r;
}
-static int pakfire_job_crashed(struct pakfire_job* self, const siginfo_t* si) {
- struct pakfire_buffer log = {};
- int r;
-
- DEBUG(self->ctx, "Sending crash report...\n");
-
- // Dump the log
- r = pakfire_log_buffer_dump(self->log.buffer, &log.data, &log.length);
- if (r < 0)
- goto ERROR;
-
- // Send the report
- r = pakfire_client_job_crashed(self->client, self->id, si->si_status, &log);
-
-ERROR:
- pakfire_buffer_free(&log);
-
- return r;
-}
-
static int pakfire_job_result(struct pakfire_ctx* ctx, struct pakfire* pakfire,
struct pakfire_build* build, struct pakfire_archive* archive, void* data) {
struct pakfire_job* job = data;
*/
static int pakfire_job_exited(sd_event_source* s, const siginfo_t* si, void* data) {
struct pakfire_job* job = data;
- int r;
switch (si->si_code) {
case CLD_EXITED:
// Update state
job->state = PAKFIRE_JOB_STATE_KILLED;
-
- // Send some information about this
- r = pakfire_job_crashed(job, si);
- if (r < 0)
- ERROR(job->ctx, "Could not send crash report: %s\n", strerror(-r));
-
break;
}