Init commit of jobs output/error message peek project.

This commit is contained in:
Lei Chen 2026-05-09 16:57:54 +08:00
parent c772d7e601
commit d2b47e3985
38 changed files with 2267 additions and 21 deletions

View file

@ -1,8 +1,17 @@
#include <errno.h>
#include <time.h>
#include "mylock.h"
#include "utils.h"
#include "xceapi.h"
/* All synchronous API calls wait at most 10 seconds for a reply. */
static void cbuf_deadline_10s(struct timespec* ts)
{
clock_gettime(CLOCK_REALTIME, ts);
ts->tv_sec += 10;
}
int xce_hello(xce_ctx_t* ctx, char* msg)
{
int rc, status;
@ -19,7 +28,8 @@ int xce_hello(xce_ctx_t* ctx, char* msg)
if (rc < 0) {
return rc;
}
rc = cbuf_get(&(ctx->wbuf), &status);
struct timespec _dl; cbuf_deadline_10s(&_dl);
rc = cbuf_timedget(&(ctx->wbuf), &status, &_dl);
if (rc < 0) {
return rc;
}
@ -113,7 +123,8 @@ int xce_get_with_condition(xce_ctx_t* ctx, xce_get_t* get, void*** data)
return rc;
}
rc = cbuf_get(&(ctx->wbuf), &status);
struct timespec _dl; cbuf_deadline_10s(&_dl);
rc = cbuf_timedget(&(ctx->wbuf), &status, &_dl);
if (rc < 0) {
return rc;
}
@ -192,7 +203,8 @@ int xce_resval(xce_ctx_t* ctx, char* host, char* res, xce_resval_t*** vals)
return rc;
}
rc = cbuf_get(&(ctx->wbuf), &status);
struct timespec _dl; cbuf_deadline_10s(&_dl);
rc = cbuf_timedget(&(ctx->wbuf), &status, &_dl);
if (rc < 0) {
return rc;
}
@ -225,7 +237,8 @@ int xce_join(xce_ctx_t* ctx, int role, hostattrs_t* attrs)
if (rc < 0) {
return rc;
}
rc = cbuf_get(&(ctx->wbuf), &status);
struct timespec _dl; cbuf_deadline_10s(&_dl);
rc = cbuf_timedget(&(ctx->wbuf), &status, &_dl);
if (rc < 0) {
return rc;
}
@ -259,7 +272,8 @@ int xce_jobdispatch(xce_ctx_t* ctx, xce_job_dispatch_t* info)
return rc;
}
rc = cbuf_get(&(ctx->wbuf), &status);
struct timespec _dl; cbuf_deadline_10s(&_dl);
rc = cbuf_timedget(&(ctx->wbuf), &status, &_dl);
if (rc < 0) {
return rc;
}
@ -301,7 +315,8 @@ int xce_jobsubmit(xce_ctx_t* ctx, xce_job_submit_t* submit, uint64_t* jobid)
return rc;
}
rc = cbuf_get(&(ctx->wbuf), &status);
struct timespec _dl; cbuf_deadline_10s(&_dl);
rc = cbuf_timedget(&(ctx->wbuf), &status, &_dl);
if (rc < 0) {
return rc;
}
@ -414,7 +429,8 @@ int xce_clusterconf(xce_ctx_t* ctx, xce_clusterconf_t** conf)
return rc;
}
rc = cbuf_get(&(ctx->wbuf), &status);
struct timespec _dl; cbuf_deadline_10s(&_dl);
rc = cbuf_timedget(&(ctx->wbuf), &status, &_dl);
if (rc < 0) {
return rc;
}
@ -458,7 +474,8 @@ int xce_update_resvals(xce_ctx_t* ctx, int count, xce_resval_t** vals)
return rc;
}
rc = cbuf_get(&(ctx->wbuf), &status);
struct timespec _dl; cbuf_deadline_10s(&_dl);
rc = cbuf_timedget(&(ctx->wbuf), &status, &_dl);
if (rc < 0) {
return rc;
}
@ -501,7 +518,8 @@ int xce_update_jusage(xce_ctx_t* ctx, uint64_t jobid, int npids, int* pids,
return rc;
}
rc = cbuf_get(&(ctx->wbuf), &status);
struct timespec _dl; cbuf_deadline_10s(&_dl);
rc = cbuf_timedget(&(ctx->wbuf), &status, &_dl);
if (rc < 0) {
return rc;
}
@ -527,7 +545,8 @@ int xce_jobctrl(xce_ctx_t* ctx, xce_jobctrl_t* ctrl)
return rc;
}
rc = cbuf_get(&(ctx->wbuf), &status);
struct timespec _dl; cbuf_deadline_10s(&_dl);
rc = cbuf_timedget(&(ctx->wbuf), &status, &_dl);
if (rc < 0) {
return rc;
}
@ -553,7 +572,8 @@ int xce_queuectrl(xce_ctx_t* ctx, xce_queuectrl_t* ctrl)
return rc;
}
rc = cbuf_get(&(ctx->wbuf), &status);
struct timespec _dl; cbuf_deadline_10s(&_dl);
rc = cbuf_timedget(&(ctx->wbuf), &status, &_dl);
if (rc < 0) {
return rc;
}
@ -579,7 +599,8 @@ int xce_hostctrl(xce_ctx_t* ctx, xce_hostctrl_t* ctrl)
return rc;
}
rc = cbuf_get(&(ctx->wbuf), &status);
struct timespec _dl; cbuf_deadline_10s(&_dl);
rc = cbuf_timedget(&(ctx->wbuf), &status, &_dl);
if (rc < 0) {
return rc;
}
@ -605,7 +626,8 @@ int xce_runtask(xce_ctx_t* ctx, xce_taskrun_t* runinfo)
return rc;
}
rc = cbuf_get(&(ctx->wbuf), &status);
struct timespec _dl; cbuf_deadline_10s(&_dl);
rc = cbuf_timedget(&(ctx->wbuf), &status, &_dl);
if (rc < 0) {
return rc;
}
@ -631,7 +653,8 @@ int xce_set_pend_reason(xce_ctx_t* ctx, xce_preason_set_t* reasons)
return rc;
}
rc = cbuf_get(&(ctx->wbuf), &status);
struct timespec _dl; cbuf_deadline_10s(&_dl);
rc = cbuf_timedget(&(ctx->wbuf), &status, &_dl);
if (rc < 0) {
return rc;
}
@ -657,7 +680,8 @@ int xce_clear_reason(xce_ctx_t* ctx, xce_clear_reason_t* reasons)
return rc;
}
rc = cbuf_get(&(ctx->wbuf), &status);
struct timespec _dl; cbuf_deadline_10s(&_dl);
rc = cbuf_timedget(&(ctx->wbuf), &status, &_dl);
if (rc < 0) {
return rc;
}
@ -697,3 +721,37 @@ int xce_jobinfo(xce_ctx_t* ctx, uint64_t jobid, xce_job_t** job)
return 1;
}
int xce_fetchfile(xce_ctx_t* ctx, xce_fetchfile_t* msg, xce_fetchfile_reply_t** reply)
{
int rc;
int status;
if ((ctx == NULL) || (msg == NULL) || (reply == NULL)) {
return -EINVAL;
}
if (ctx->state != XCE_CTX_RUN) {
return -EINVAL;
}
ctx->reply.u.fetchfilereply = NULL;
rc = xce_fetchfile_req(ctx->ep, msg);
if (rc < 0) {
return rc;
}
struct timespec _dl; cbuf_deadline_10s(&_dl);
rc = cbuf_timedget(&(ctx->wbuf), &status, &_dl);
if (rc < 0) {
return rc;
}
if (status < 0) {
return status;
}
MOVE_PTR(*reply, ctx->reply.u.fetchfilereply);
return 0;
}