security communication with openssl and simplify netio

This commit is contained in:
Rongsong Shen 2025-11-18 11:21:24 +08:00
parent 2a7b7c39bb
commit 8f796b3109
20 changed files with 1176 additions and 922 deletions

View file

@ -5,8 +5,7 @@
int xce_hello(xce_ctx_t* ctx, char* msg)
{
ioctx_t* ioctx;
int rc, status;
int rc, status;
if (ctx == NULL) {
return -EINVAL;
@ -16,12 +15,7 @@ int xce_hello(xce_ctx_t* ctx, char* msg)
return -EINVAL;
}
ioctx = ioctx_alloc(ctx->ep, &(ctx->myinfo));
if (ioctx == NULL) {
return -ENOMEM;
}
rc = xce_hello_req(ioctx, msg);
rc = xce_hello_req(ctx->ep, msg);
if (rc < 0) {
return rc;
}
@ -35,9 +29,7 @@ int xce_hello(xce_ctx_t* ctx, char* msg)
int xce_shutdown(xce_ctx_t* ctx)
{
ioctx_t* ioctx;
int rc;
int status;
int rc;
if (ctx == NULL) {
return -EINVAL;
@ -47,27 +39,14 @@ int xce_shutdown(xce_ctx_t* ctx)
return -EINVAL;
}
ioctx = ioctx_alloc(ctx->ep, &(ctx->myinfo));
if (ioctx == NULL) {
return -ENOMEM;
}
rc = xce_shutdown_req(ctx->ep);
rc = xce_shutdown_req(ioctx);
if (rc < 0) {
return rc;
}
rc = cbuf_get(&(ctx->wbuf), &status);
if (rc < 0) {
return rc;
}
return status;
/* do not need wait controller back as it will be shutdown */
return rc;
}
int xce_get(xce_ctx_t* ctx, int table, void*** data)
{
ioctx_t* ioctx;
int rc;
int status;
xce_match_t condition = { .type = MatchCondition_condition_matchall };
@ -82,13 +61,8 @@ int xce_get(xce_ctx_t* ctx, int table, void*** data)
return -EINVAL;
}
ioctx = ioctx_alloc(ctx->ep, &(ctx->myinfo));
if (ioctx == NULL) {
return -ENOMEM;
}
ctx->reply.u.get = &getreply;
rc = xce_get_req(ioctx, &get);
rc = xce_get_req(ctx->ep, &get);
if (rc < 0) {
return rc;
}
@ -119,28 +93,27 @@ int xce_reslist(xce_ctx_t* ctx, xce_resource_t*** res)
int xce_resval(xce_ctx_t* ctx, char* host, char* res, xce_resval_t*** vals)
{
ioctx_t* ioctx;
int rc;
int status;
int rc;
int status;
/* clang-format off */
xce_reskey_t reskey = {
.resname = res,
.hostname = host
.resname = res,
.hostname = host
};
xce_match_t condition = {
.type = MatchCondition_condition_matchreskey,
.condition = {
.reskey = &reskey
}
.type = MatchCondition_condition_matchreskey,
.condition = {
.reskey = &reskey
}
};
xce_get_t get = {
.table = Data_data_resvals,
.condition = &condition
.table = Data_data_resvals,
.condition = &condition
};
dataset_t getreply = {
.table = Data_data_resvals,
.nrows = 0,
.rows = NULL
.table = Data_data_resvals,
.nrows = 0,
.rows = NULL
};
/* clang-format on */
@ -152,13 +125,8 @@ int xce_resval(xce_ctx_t* ctx, char* host, char* res, xce_resval_t*** vals)
return -EINVAL;
}
ioctx = ioctx_alloc(ctx->ep, &(ctx->myinfo));
if (ioctx == NULL) {
return -ENOMEM;
}
ctx->reply.u.get = &getreply;
rc = xce_get_req(ioctx, &get);
rc = xce_get_req(ctx->ep, &get);
if (rc < 0) {
return rc;
}
@ -182,8 +150,7 @@ int xce_resval(xce_ctx_t* ctx, char* host, char* res, xce_resval_t*** vals)
int xce_join(xce_ctx_t* ctx, int role, hostattrs_t* attrs)
{
ioctx_t* ioctx;
int rc, status;
int rc, status;
if (ctx == NULL) {
return -EINVAL;
@ -193,12 +160,7 @@ int xce_join(xce_ctx_t* ctx, int role, hostattrs_t* attrs)
return -EINVAL;
}
ioctx = ioctx_alloc(ctx->ep, &(ctx->myinfo));
if (ioctx == NULL) {
return -ENOMEM;
}
rc = xce_join_req(ioctx, role, attrs);
rc = xce_join_req(ctx->ep, role, attrs);
if (rc < 0) {
return rc;
}
@ -221,8 +183,7 @@ int xce_free_workers(int nworkers, xce_worker_t* workers) { return 0; }
int xce_jobdispatch(xce_ctx_t* ctx, xce_job_dispatch_t* info)
{
ioctx_t* ioctx;
int rc, status;
int rc, status;
if (ctx == NULL) {
return -EINVAL;
@ -232,12 +193,7 @@ int xce_jobdispatch(xce_ctx_t* ctx, xce_job_dispatch_t* info)
return -EINVAL;
}
ioctx = ioctx_alloc(ctx->ep, &(ctx->myinfo));
if (ioctx == NULL) {
return -ENOMEM;
}
rc = xce_jobdispatch_req(ioctx, info);
rc = xce_jobdispatch_req(ctx->ep, info);
if (rc < 0) {
return rc;
}
@ -252,8 +208,7 @@ int xce_jobdispatch(xce_ctx_t* ctx, xce_job_dispatch_t* info)
int xce_notify(xce_ctx_t* ctx, xce_notify_data_t* data)
{
ioctx_t* ioctx;
int rc;
int rc;
if (ctx == NULL) {
return -EINVAL;
@ -263,20 +218,14 @@ int xce_notify(xce_ctx_t* ctx, xce_notify_data_t* data)
return -EINVAL;
}
ioctx = ioctx_alloc(ctx->ep, &(ctx->myinfo));
if (ioctx == NULL) {
return -ENOMEM;
}
rc = xce_notify_req(ioctx, data);
rc = xce_notify_req(ctx->ep, data);
return rc;
}
int xce_jobsubmit(xce_ctx_t* ctx, xce_job_submit_t* submit, uint64_t* jobid)
{
ioctx_t* ioctx;
int rc, status;
int rc, status;
if (ctx == NULL) {
return -EINVAL;
@ -286,12 +235,7 @@ int xce_jobsubmit(xce_ctx_t* ctx, xce_job_submit_t* submit, uint64_t* jobid)
return -EINVAL;
}
ioctx = ioctx_alloc(ctx->ep, &(ctx->myinfo));
if (ioctx == NULL) {
return -ENOMEM;
}
rc = xce_jobsubmit_req(ioctx, submit);
rc = xce_jobsubmit_req(ctx->ep, submit);
if (rc < 0) {
return rc;
}
@ -393,8 +337,7 @@ int xce_free_groups(int ngroups, xce_group_t* groups)
int xce_clusterconf(xce_ctx_t* ctx, xce_clusterconf_t** conf)
{
ioctx_t* ioctx;
int rc, status;
int rc, status;
if ((ctx == NULL) || (conf == NULL)) {
return -EINVAL;
@ -404,12 +347,7 @@ int xce_clusterconf(xce_ctx_t* ctx, xce_clusterconf_t** conf)
return -EINVAL;
}
ioctx = ioctx_alloc(ctx->ep, &(ctx->myinfo));
if (ioctx == NULL) {
return -ENOMEM;
}
rc = xce_clusterconf_req(ioctx);
rc = xce_clusterconf_req(ctx->ep);
if (rc < 0) {
return rc;
}
@ -429,9 +367,8 @@ int xce_clusterconf(xce_ctx_t* ctx, xce_clusterconf_t** conf)
int xce_update_resvals(xce_ctx_t* ctx, int count, xce_resval_t** vals)
{
ioctx_t* ioctx;
int rc;
int status;
int rc;
int status;
/* clang-format off */
xce_resval_list_t valist = {
@ -454,12 +391,7 @@ int xce_update_resvals(xce_ctx_t* ctx, int count, xce_resval_t** vals)
return -EINVAL;
}
ioctx = ioctx_alloc(ctx->ep, &(ctx->myinfo));
if (ioctx == NULL) {
return -ENOMEM;
}
rc = xce_update_req(ioctx, &data);
rc = xce_update_req(ctx->ep, &data);
if (rc < 0) {
return rc;
}
@ -475,9 +407,8 @@ int xce_update_resvals(xce_ctx_t* ctx, int count, xce_resval_t** vals)
int xce_update_jusage(xce_ctx_t* ctx, uint64_t jobid, int npids, int* pids,
int ngids, int* pgids, int nusage, xce_rusage_t** usages)
{
ioctx_t* ioctx;
int rc;
int status;
int rc;
int status;
/* clang-format off */
xce_job_rusages_t rusages = {
@ -503,12 +434,7 @@ int xce_update_jusage(xce_ctx_t* ctx, uint64_t jobid, int npids, int* pids,
return -EINVAL;
}
ioctx = ioctx_alloc(ctx->ep, &(ctx->myinfo));
if (ioctx == NULL) {
return -ENOMEM;
}
rc = xce_update_req(ioctx, &data);
rc = xce_update_req(ctx->ep, &data);
if (rc < 0) {
return rc;
}
@ -523,9 +449,8 @@ int xce_update_jusage(xce_ctx_t* ctx, uint64_t jobid, int npids, int* pids,
int xce_jobctrl(xce_ctx_t* ctx, xce_jobctrl_t* ctrl)
{
ioctx_t* ioctx;
int rc;
int status;
int rc;
int status;
if (ctx == NULL) {
return -EINVAL;
@ -535,12 +460,7 @@ int xce_jobctrl(xce_ctx_t* ctx, xce_jobctrl_t* ctrl)
return -EINVAL;
}
ioctx = ioctx_alloc(ctx->ep, &(ctx->myinfo));
if (ioctx == NULL) {
return -ENOMEM;
}
rc = xce_jobctrl_req(ioctx, ctrl);
rc = xce_jobctrl_req(ctx->ep, ctrl);
if (rc < 0) {
return rc;
}
@ -555,9 +475,8 @@ int xce_jobctrl(xce_ctx_t* ctx, xce_jobctrl_t* ctrl)
int xce_queuectrl(xce_ctx_t* ctx, xce_queuectrl_t* ctrl)
{
ioctx_t* ioctx;
int rc;
int status;
int rc;
int status;
if (ctx == NULL) {
return -EINVAL;
@ -567,12 +486,7 @@ int xce_queuectrl(xce_ctx_t* ctx, xce_queuectrl_t* ctrl)
return -EINVAL;
}
ioctx = ioctx_alloc(ctx->ep, &(ctx->myinfo));
if (ioctx == NULL) {
return -ENOMEM;
}
rc = xce_queuectrl_req(ioctx, ctrl);
rc = xce_queuectrl_req(ctx->ep, ctrl);
if (rc < 0) {
return rc;
}
@ -587,9 +501,8 @@ int xce_queuectrl(xce_ctx_t* ctx, xce_queuectrl_t* ctrl)
int xce_runtask(xce_ctx_t* ctx, xce_taskrun_t* runinfo)
{
ioctx_t* ioctx;
int rc;
int status;
int rc;
int status;
if (ctx == NULL) {
return -EINVAL;
@ -599,12 +512,7 @@ int xce_runtask(xce_ctx_t* ctx, xce_taskrun_t* runinfo)
return -EINVAL;
}
ioctx = ioctx_alloc(ctx->ep, &(ctx->myinfo));
if (ioctx == NULL) {
return -ENOMEM;
}
rc = xce_runtask_req(ioctx, runinfo);
rc = xce_runtask_req(ctx->ep, runinfo);
if (rc < 0) {
return rc;
}