Failure in startup with -m startup or running left running_db cleared.

This commit is contained in:
Olof hagsand 2019-04-18 12:20:31 +02:00
parent 6c2e880ab9
commit b714eff077
4 changed files with 119 additions and 21 deletions

View file

@ -638,16 +638,33 @@ main(int argc,
status = STARTUP_OK;
break;
case SM_RUNNING: /* Use running as startup */
/* Copy original running to startup and treat as startup */
/* Copy original running to tmp as backup (restore if error) */
if (xmldb_copy(h, "running", "tmp") < 0)
goto done;
/* [Delete and] create running db */
if (startup_db_reset(h, "running") < 0)
goto done;
ret = startup_mode_startup(h, "tmp", cbret);
/* If ret fails, copy tmp back to running */
if (ret != 1)
if (xmldb_copy(h, "tmp", "running") < 0)
goto done;
if (ret2status(ret, &status) < 0)
goto done;
break;
case SM_STARTUP:
/* Copy original running to tmp as backup (restore if error) */
if (xmldb_copy(h, "running", "tmp") < 0)
goto done;
/* [Delete and] create running db */
if (startup_db_reset(h, "running") < 0)
goto done;
/* Load and commit from startup */
ret = startup_mode_startup(h, "startup", cbret);
/* If ret fails, copy tmp back to running */
if (ret != 1)
if (xmldb_copy(h, "tmp", "running") < 0)
goto done;
if (ret2status(ret, &status) < 0)
goto done;
/* if status = STARTUP_INVALID, cbret contains info */