Skip to content

Commit

Permalink
Key registration requests to module name, rather than file name.
Browse files Browse the repository at this point in the history
  • Loading branch information
philip-davis committed Aug 22, 2024
1 parent 7600d32 commit 41a1070
Showing 1 changed file with 29 additions and 17 deletions.
46 changes: 29 additions & 17 deletions src/dspaces-server.c
Original file line number Diff line number Diff line change
Expand Up @@ -3311,30 +3311,42 @@ static int dspaces_init_registry(dspaces_provider_t server)

static int route_registration(dspaces_provider_t server, reg_in_t *reg)
{
struct dspaces_module *mod;
struct dspaces_module *mod, *reg_mod;
int nargs;
struct dspaces_module_ret *res = NULL;
struct dspaces_module_args *args;
int err;

DEBUG_OUT("routing registration request.\n");

mod = dspaces_mod_by_name(&server->mods, "ds_reg");
if(mod) {
nargs = build_module_args_from_reg(reg, &args);
res = dspaces_module_exec(mod, "register", args, nargs,
DSPACES_MOD_RET_INT);
if(res && res->type == DSPACES_MOD_RET_ERR) {
err = res->err;
free(res);
return (err);
}
if(res) {
if(res->ival != reg->id) {
DEBUG_OUT("updating registration id to %li.\n", res->ival);
reg->id = res->ival;
}
}
mod = dspaces_mod_by_name(&server->mods, reg->type);
if(!mod) {
return (DS_MOD_ENOMOD);
}

// ds_reg module doesn't have access to the map between dspaces module name
// and Python module name, so translate for it.
free(reg->type);
reg->type = strdup(mod->file);

reg_mod = dspaces_mod_by_name(&server->mods, "ds_reg");
if(!reg_mod) {
return (DS_MOD_EFAULT);
}
nargs = build_module_args_from_reg(reg, &args);
res = dspaces_module_exec(reg_mod, "register", args, nargs,
DSPACES_MOD_RET_INT);
if(!res) {
return (DS_MOD_EFAULT);
}
if(res->type == DSPACES_MOD_RET_ERR) {
err = res->err;
free(res);
return (err);
}
if(res->ival != reg->id) {
DEBUG_OUT("updating registration id to %li.\n", res->ival);
reg->id = res->ival;
}

return (0);
Expand Down

0 comments on commit 41a1070

Please sign in to comment.