Commit e870016d authored by John P. Willis's avatar John P. Willis
Browse files

Add support for global mappings across namespaces

parent 0f9f0236
Pipeline #751 passed with stage
in 1 minute and 32 seconds
......@@ -128,6 +128,12 @@ void global (short action, char *key, char *data)
int ierr_sav = OK;
char *ptr = key;
char name[256];
char old_gloplib[PATHLEN];
register int i = 0;
register char ch;
char *old_ns = (char *) malloc (STRLEN * sizeof (char));
NULLPTRCHK(old_ns,"global");
......@@ -139,12 +145,19 @@ void global (short action, char *key, char *data)
char *tk_buf = (char *) malloc (STRLEN * sizeof (char));
NULLPTRCHK(tk_buf,"global");
char *mapk_buf = (char *) malloc (STRLEN * sizeof (char));
NULLPTRCHK(mapk_buf,"global");
char *mapd_buf = (char *) malloc (STRLEN * sizeof (char));
NULLPTRCHK(mapd_buf,"global");
freem_ref_t *r = (freem_ref_t *) malloc (sizeof (freem_ref_t));
NULLPTRCHK(r,"global");
short extref_flg = FALSE;
short mapped_flg = FALSE;
if (key[1] != '$') {
while ((shm_config->hdr->tp_owner != pid) && (shm_config->hdr->tp_owner != 0)) {
sleep (1);
......@@ -155,6 +168,30 @@ void global (short action, char *key, char *data)
if (key[1] != '$') frm_process_alias (key);
if (key[1] != '$') {
/* process mappings */
ierr_sav = OK;
while ((ch = *(ptr++)) != DELIM && ch != EOL && i < 256) {
name[i++] = ch;
}
name[i] = '\0';
snprintf (mapk_buf, STRLEN - 1, "^$SYSTEM\202MAPPINGS\202GLOBAL\202%s\201", name);
global (get_sym, mapk_buf, mapd_buf);
stcnv_m2c (mapd_buf);
if (ierr == OK) {
mapped_flg = TRUE;
strncpy (old_ns, nsname, STRLEN - 1);
set_namespace (mapd_buf, 0);
strncpy (old_gloplib, gloplib, PATHLEN - 1);
strncpy (gloplib, glopath, PATHLEN - 1);
}
}
if (dbg_enable_watch && (action == set_sym)) dbg_fire_watch (key);
/* variables for transaction-in-flight symbol table */
......@@ -277,8 +314,14 @@ void global (short action, char *key, char *data)
}
if (extref_flg == TRUE) {
if ((extref_flg == TRUE) || (mapped_flg == TRUE)) {
if (mapped_flg == TRUE) {
strncpy (gloplib, old_gloplib, PATHLEN - 1);
}
set_namespace (old_ns, 0);
}
if (evt_async_enabled && r->reftype == MREF_RT_GLOBAL) {
......@@ -356,6 +399,8 @@ void global (short action, char *key, char *data)
free (r);
free (tk_buf);
free (old_ns);
free (mapk_buf);
free (mapd_buf);
ierr = ierr_sav;
......
......@@ -352,14 +352,44 @@ short frm_global_exists(char *gbl_namespace, char *gbl_path, char *global_name)
char glofile[STRLEN];
char goobuf[STRLEN];
char mapk_buf[255];
char mapd_buf[255];
char old_ns[255];
if (global_name[0] == '%') {
gpth = gloplib;
sprintf (gbl_namespace, "SYSTEM");
int ierr_sav = OK;
snprintf (mapk_buf, 254, "^$SYSTEM\202MAPPINGS\202GLOBAL\202^%s\201", global_name);
global (get_sym, mapk_buf, mapd_buf);
stcnv_m2c (mapd_buf);
if (ierr == OK) {
strncpy (old_ns, nsname, STRLEN - 1);
set_namespace (mapd_buf, 0);
gpth = (char *) malloc (PATHLEN * sizeof (char));
NULLPTRCHK(gpth,"frm_global_exists");
strncpy (gpth, glopath, PATHLEN - 1);
strncpy (gbl_namespace, mapd_buf, 254);
set_namespace (old_ns, 0);
}
else {
gpth = glopath;
sprintf (gbl_namespace, "%s\201", nsname);
ierr = ierr_sav;
if (global_name[0] == '%') {
gpth = gloplib;
sprintf (gbl_namespace, "SYSTEM");
}
else {
gpth = glopath;
sprintf (gbl_namespace, "%s\201", nsname);
}
}
stcpy (goobuf, gpth);
......
......@@ -94,7 +94,7 @@ void ssvn_system(short action, char *key, char *data)
mref_init (r, MREF_RT_SSV, "^$SYSTEM");
internal_to_mref (r, key);
if ((r->subscript_count > 2) && (strcmp (r->subscripts[0], "EVENT") != 0)) {
if ((r->subscript_count > 2) && (strcmp (r->subscripts[0], "EVENT") != 0) && (strcmp (r->subscripts[0], "MAPPINGS") != 0)) {
ierr = INVREF;
goto done;
}
......@@ -109,6 +109,24 @@ void ssvn_system(short action, char *key, char *data)
ierr = OK;
break;
}
else if (strcmp (r->subscripts[0], "MAPPINGS") == 0) {
if ((strcmp (r->subscripts[1], "GLOBAL") == 0) || (strcmp (r->subscripts[1], "ROUTINE") == 0)) {
ierr = OK;
symtab (action, key, data);
break;
}
else {
ierr = M38;
break;
}
}
else if (strcmp (r->subscripts[0], "MAINTENANCE_MODE") == 0) {
......@@ -307,10 +325,15 @@ void ssvn_system(short action, char *key, char *data)
goto done;
}
if (strcmp (r->subscripts[0], "EVENT") != 0) {
if ((strcmp (r->subscripts[0], "EVENT") != 0) && (strcmp (r->subscripts[0], "MAPPINGS") != 0)) {
ierr = M29;
goto done;
}
if ((strcmp (r->subscripts[0], "MAPPINGS") == 0) && ((strcmp (r->subscripts[1], "GLOBAL") != 0) && (strcmp (r->subscripts[1], "ROUTINE") != 0))) {
ierr = M38;
goto done;
}
global (action, key, data);
ierr = OK;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment