Skip to content

Commit afabfbc

Browse files
authored
Merge pull request #6158 from nickanderson/ENT-3868/master
ENT-3933: Improved persistent class logging and plugged memory leak
2 parents d0bab1c + 51650ed commit afabfbc

1 file changed

Lines changed: 22 additions & 2 deletions

File tree

libpromises/eval_context.c

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -748,24 +748,44 @@ void EvalContextHeapPersistentSave(EvalContext *ctx, const char *name, unsigned
748748
Log(LOG_LEVEL_VERBOSE, "Persistent class '%s' is already in a preserved state -- %jd minutes to go",
749749
key, (intmax_t)((existing_info->expires - now) / 60));
750750
CloseDB(dbp);
751+
free(existing_info);
751752
free(key);
752753
free(new_info);
753754
return;
754755
}
756+
else if (policy == CONTEXT_STATE_POLICY_RESET)
757+
{
758+
Log(LOG_LEVEL_VERBOSE,
759+
"Resetting persistent class '%s' timer to %u minutes (was %jd minutes remaining)",
760+
key, ttl_minutes, (intmax_t)((existing_info->expires - now) / 60));
761+
}
762+
else
763+
{
764+
Log(LOG_LEVEL_VERBOSE,
765+
"Updating persistent class '%s' (%u minutes, policy preserve)",
766+
key, ttl_minutes);
767+
}
755768
}
756769
else
757770
{
758771
Log(LOG_LEVEL_ERR, "While persisting class '%s', error reading existing value", key);
759772
CloseDB(dbp);
773+
free(existing_info);
760774
free(key);
761775
free(new_info);
762776
return;
763777
}
778+
free(existing_info);
779+
}
780+
else
781+
{
782+
Log(LOG_LEVEL_VERBOSE,
783+
"Creating persistent class '%s' (%u minutes, policy %s)",
784+
key, ttl_minutes,
785+
policy == CONTEXT_STATE_POLICY_PRESERVE ? "preserve" : "reset");
764786
}
765787
}
766788

767-
Log(LOG_LEVEL_VERBOSE, "Updating persistent class '%s'", key);
768-
769789
WriteDB(dbp, key, new_info, new_info_size);
770790

771791
CloseDB(dbp);

0 commit comments

Comments
 (0)