From 5cc9a764e72fa14dca2ec2097217b26d9832b77f Mon Sep 17 00:00:00 2001 From: onefang Date: Fri, 30 Jul 2021 04:58:57 +1000 Subject: Add backup_IARsim config variable. Only using it for newbie IAR loading for now, coz I haven't actually written the IAR backup code yet. Also clean out the excess table from ourSims, since it is no longer needed to find the sim we used to use for IARs. --- src/.sledjChisl.conf.lua | 1 + src/sledjchisl/sledjchisl.c | 80 +++++++++++---------------------------------- 2 files changed, 20 insertions(+), 61 deletions(-) diff --git a/src/.sledjChisl.conf.lua b/src/.sledjChisl.conf.lua index d6fad37..f24e6ed 100644 --- a/src/.sledjChisl.conf.lua +++ b/src/.sledjChisl.conf.lua @@ -19,6 +19,7 @@ config = ["loadAverageInc"] = 0.7; ["simTimeOut"] = 45; -- seconds ["bulkSims"] = 0; -- 0 means figure it out from number of CPUs. + ["backupIARsim"] = "Sandbox"; ["webRoot"] = "/var/www/html"; ["webHost"] = "localhost"; ["URL"] = "sledjchisl.fcgi"; diff --git a/src/sledjchisl/sledjchisl.c b/src/sledjchisl/sledjchisl.c index 8aad370..767a894 100644 --- a/src/sledjchisl/sledjchisl.c +++ b/src/sledjchisl/sledjchisl.c @@ -484,6 +484,7 @@ char *Tconsole = "SledjChisl"; char *Tsocket = "opensim-tmux.socket"; char *Ttab = "SC"; char *Tcmd = "tmux -S"; +char *backupIARsim = "Sandbox"; char *webRoot = "/var/www/html"; char *URL = "fcgi-bin/sledjchisl.fcgi"; char *ToS = "Be good."; @@ -731,7 +732,7 @@ struct _simList { int len, num; char **sims; - qtreetbl_t *tbl, *byTab; + qtreetbl_t *byTab; }; simList *ourSims = NULL; @@ -810,7 +811,6 @@ simList *getSims() ourSims = xmalloc(sizeof(simList)); memset(ourSims, 0, sizeof(simList)); - ourSims->tbl = qtreetbl(0); ourSims->byTab = qtreetbl(0); new->extra = (long) ourSims; dirtree_handle_callback(new, filterSims); @@ -875,7 +875,6 @@ ini->putstr(ini, "INI FILE", name); simd->sizeZ = getIntFromIni(ini, "Region.SizeZ"); simd->tab = name; ini->put(ini, "SIM DATA", simd, sizeof(simData)); -ourSims->tbl->put(ourSims->tbl, sim, ini, sizeof(qlisttbl_t)); ourSims->byTab->put(ourSims->byTab, name, ini, sizeof(qlisttbl_t)); if ((!qfile_exist(newPath))) @@ -955,8 +954,8 @@ void freeSimList(simList *sims) qtreetbl_obj_t obj; memset((void*) &obj, 0, sizeof(obj)); // start from the minimum. - sims->tbl->lock(sims->tbl); - while (sims->tbl->getnext(sims->tbl, &obj, false) == true) + sims->byTab->lock(sims->byTab); + while (sims->byTab->getnext(sims->byTab, &obj, false) == true) { char *name = qmemdup(obj.name, obj.namesize); // keep the name size_t namesize = obj.namesize; // for removal argument @@ -983,30 +982,6 @@ void freeSimList(simList *sims) ; } - sims->tbl->remove_by_obj(sims->tbl, obj.name, obj.namesize); // remove - obj = sims->tbl->find_nearest(sims->tbl, name, namesize, false); // rewind one step back - free(name); // clean up - } - sims->tbl->unlock(sims->tbl); - sims->tbl->free(sims->tbl); - - memset((void*) &obj, 0, sizeof(obj)); // start from the minimum. - sims->byTab->lock(sims->byTab); - while (sims->byTab->getnext(sims->byTab, &obj, false) == true) - { - char *name = qmemdup(obj.name, obj.namesize); // keep the name - size_t namesize = obj.namesize; // for removal argument - qlisttbl_t *ini = (qlisttbl_t *) obj.data; - if (NULL != ini) - { -// TODO - this leaks memory, but it's a bug in qLibc. Send the bug fix upstream. -// It either leaks, or frees twice. Pffft -// ini->clear(ini); -// ini->free(ini); -// free(ini); - ; - } - sims->byTab->remove_by_obj(sims->byTab, obj.name, obj.namesize); // remove obj = sims->byTab->find_nearest(sims->byTab, name, namesize, false); // rewind one step back free(name); // clean up @@ -4467,42 +4442,24 @@ notWritten: sysinfo(&info); la = info.loads[0]/65536.0; - for (i = 0; i < ourSims->num; i++) - { - char *sim = ourSims->sims[i], *name;// = getSimName(ourSims->sims[i], &nm, &num); - - qlisttbl_t *ini = ourSims->tbl->get(ourSims->tbl, sim, NULL, false); - if (NULL == ini) - { - E("Sim %s not found in ini list!", sim); -// name = getSimName(ourSims->sims[i], &nm, &num); - } - else - name = qstrunchar(ini->getstr(ini, "Region.RegionName", false), '"', '"'); + char *name; + simData *simd = ourSims->byTab->get(ourSims->byTab, backupIARsim, NULL, false); + if (NULL == simd) + E("Sim %s not found in ini list! Can't create inventory for %s %s", backupIARsim, first, last); + else + name = simd->name; + if (checkSimIsRunning(backupIARsim)) + { + char *cmd = xmprintf("%d.%d", simd->window, simd->pane); + char *c = xmprintf("load iar -m %s %s / password /opt/opensim_SC/backups/DefaultMember.IAR", first, last); - if (checkSimIsRunning(sim)) - { - I("Loading default member IAR for %s %s in sim %s, this might take a couple of minutes.", first, last, name); - char *c = xmprintf("%s %s/%s send-keys -t '%s:%d' 'load iar -m %s %s / password /opt/opensim_SC/backups/DefaultMember.IAR' Enter", - Tcmd, scRun, Tsocket, Tconsole, i + 1, first, last); + I("Loading default member IAR for %s %s in sim %s, this might take a couple of minutes.", first, last, name); T(c); - int r = system(c); - if (!WIFEXITED(r)) - E("tmux load iar command failed!"); - else - { -// snprintf(toybuf, sizeof(toybuf), "INITIALIZATION COMPLETE FOR %s", name); -// waitTmuxText(name, toybuf); -// I("%s is done starting up.", name); -// la = waitLoadAverage(la, loadAverageInc, simTimeOut); - } - free(c); - free(name); - break; - } - free(name); + sendTmuxCmd(cmd, c); + free(cmd); + free(c); } } free(first); @@ -6987,6 +6944,7 @@ jit library is loaded or the JIT compiler will not be activated. if ((tmp = configs->getstr(configs, "Tconsole", false)) != NULL) {Tconsole = tmp; D("Setting Tconsole = %s", Tconsole);} if ((tmp = configs->getstr(configs, "Tsocket", false)) != NULL) {Tsocket = tmp; D("Setting Tsocket = %s", Tsocket);} if ((tmp = configs->getstr(configs, "Ttab", false)) != NULL) {Ttab = tmp; D("Setting Ttab = %s", Ttab);} + if ((tmp = configs->getstr(configs, "backupIARsim", false)) != NULL) {backupIARsim = tmp; D("Setting backupIARsim = %s", backupIARsim);} if ((tmp = configs->getstr(configs, "webRoot", false)) != NULL) {webRoot = tmp; D("Setting webRoot = %s", webRoot);} if ((tmp = configs->getstr(configs, "URL", false)) != NULL) {URL = tmp; D("Setting URL = %s", URL);} if ((vd = configs->get (configs, "seshRenew", NULL, false)) != NULL) {seshRenew = (int) *((float *) vd); D("Setting seshRenew = %d", seshRenew);} -- cgit v1.1