From 961bf6108bfdbef9010d0a269747cfd3629e5294 Mon Sep 17 00:00:00 2001 From: Erik Zandvliet Date: Wed, 30 Apr 2014 15:29:59 +0200 Subject: [PATCH] Fixes autobackoff on windows --- lib/shared_memory.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/shared_memory.cpp b/lib/shared_memory.cpp index 534c8076..99225dd5 100644 --- a/lib/shared_memory.cpp +++ b/lib/shared_memory.cpp @@ -253,7 +253,14 @@ namespace IPC { if (master){ handle = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, len, name.c_str()); }else{ - handle = OpenFileMapping(FILE_MAP_ALL_ACCESS, FALSE, name.c_str()); + int i = 0; + do { + if (i != 0){ + Util::sleep(1000); + } + handle = OpenFileMapping(FILE_MAP_ALL_ACCESS, FALSE, name.c_str()); + i++; + } while(i < 10 && !handle && autoBackoff); } if (!handle) { DEBUG_MSG(DLVL_FAIL, "%s for page %s failed: %s", (master ? "CreateFileMapping" : "OpenFileMapping"), name.c_str(), strerror(errno));