Some improvements and fixes to previously submitted pull request for cleaning temporary objects

This commit is contained in:
kotsachin
2015-05-25 18:14:47 +09:00
parent ad109edb5b
commit 8a0466e4c2
2 changed files with 19 additions and 7 deletions

View File

@ -64,7 +64,7 @@ static void on_before_exec(pgutConn *conn);
static void on_after_exec(pgutConn *conn);
static void on_interrupt(void);
static void on_cleanup(void);
static void exit_or_abort(int exitcode);
static void exit_or_abort(int exitcode, int elevel);
void
pgut_init(int argc, char **argv)
@ -872,7 +872,10 @@ pgut_errfinish(int dummy, ...)
edata->detail.data);
if (pgut_abort_level <= edata->elevel && edata->elevel <= PANIC)
exit_or_abort(edata->code);
{
in_cleanup = true; /* need to be set for cleaning temporary objects on error */
exit_or_abort(edata->code, edata->elevel);
}
}
#ifndef PGUT_OVERRIDE_ELOG
@ -1195,13 +1198,19 @@ on_cleanup(void)
}
static void
exit_or_abort(int exitcode)
exit_or_abort(int exitcode, int elevel)
{
call_atexit_callbacks(true);
if (in_cleanup)
if (in_cleanup && FATAL > elevel)
{
/* oops, error in cleanup*/
in_cleanup = false;
call_atexit_callbacks(true);
exit(exitcode);
}
else if (FATAL <= elevel <= PANIC)
{
/* on FATAL or PANIC */
call_atexit_callbacks(true);
abort();
}
else