Skip to content
Snippets Groups Projects
Commit 029f82f3 authored by Konstantin Osipov's avatar Konstantin Osipov
Browse files

Fix snapshot corruption in presence of concurrent updates introduced in 1.5.1-68

The final version of odnoklassniki patch did not include the
most important part - delayed free of salloc memory.

Make a quick & dirty fix to the point.
parent 76e33839
No related branches found
No related tags found
No related merge requests found
...@@ -45,6 +45,8 @@ ...@@ -45,6 +45,8 @@
#define SLAB_ALIGN_PTR(ptr) (void *)((uintptr_t)(ptr) & ~(SLAB_SIZE - 1)) #define SLAB_ALIGN_PTR(ptr) (void *)((uintptr_t)(ptr) & ~(SLAB_SIZE - 1))
extern int snapshot_pid;
#ifdef SLAB_DEBUG #ifdef SLAB_DEBUG
#undef NDEBUG #undef NDEBUG
uint8_t red_zone[4] = { 0xfa, 0xfa, 0xfa, 0xfa }; uint8_t red_zone[4] = { 0xfa, 0xfa, 0xfa, 0xfa };
...@@ -322,6 +324,9 @@ sfree(void *ptr) ...@@ -322,6 +324,9 @@ sfree(void *ptr)
static void static void
sfree_batch(void) sfree_batch(void)
{ {
if (snapshot_pid)
return;
ssize_t batch = arena.delayed_free_batch; ssize_t batch = arena.delayed_free_batch;
while (--batch >= 0 && !SLIST_EMPTY(&free_delayed)) { while (--batch >= 0 && !SLIST_EMPTY(&free_delayed)) {
......
...@@ -324,8 +324,6 @@ snapshot(void) ...@@ -324,8 +324,6 @@ snapshot(void)
if (snapshot_pid) if (snapshot_pid)
return EINPROGRESS; return EINPROGRESS;
/* increment snapshot version */
snapshot_version++;
pid_t p = fork(); pid_t p = fork();
if (p < 0) { if (p < 0) {
...@@ -334,6 +332,8 @@ snapshot(void) ...@@ -334,6 +332,8 @@ snapshot(void)
} }
if (p > 0) { if (p > 0) {
snapshot_pid = p; snapshot_pid = p;
/* increment snapshot version */
snapshot_version++;
int status = wait_for_child(p); int status = wait_for_child(p);
snapshot_pid = 0; snapshot_pid = 0;
return (WIFSIGNALED(status) ? EINTR : WEXITSTATUS(status)); return (WIFSIGNALED(status) ? EINTR : WEXITSTATUS(status));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment