Skip to content

Commit 2f703ab

Browse files
committed
Fixed bug #8509 : "Error creating private namespace" message in firebird.log
1 parent 1175a17 commit 2f703ab

File tree

1 file changed

+30
-16
lines changed

1 file changed

+30
-16
lines changed

src/common/utils.cpp

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
#include "../common/StatusArg.h"
6060
#include "../common/TimeZoneUtil.h"
6161
#include "../common/config/config.h"
62+
#include "../common/ThreadStart.h"
6263

6364
#ifdef WIN_NT
6465
#include <direct.h>
@@ -667,28 +668,41 @@ class PrivateNamespace
667668
if (!AddSIDToBoundaryDescriptor(&hBoundaryDesc, &sid))
668669
raiseError("AddSIDToBoundaryDescriptor");
669670

670-
m_hNamespace = CreatePrivateNamespace(&sa, hBoundaryDesc, sPrivateNameSpace);
671-
672-
if (m_hNamespace == NULL)
671+
int retry = 0;
672+
while (true)
673673
{
674-
DWORD err = GetLastError();
675-
if (err != ERROR_ALREADY_EXISTS)
676-
raiseError("CreatePrivateNamespace");
674+
m_hNamespace = CreatePrivateNamespace(&sa, hBoundaryDesc, sPrivateNameSpace);
677675

678-
m_hNamespace = OpenPrivateNamespace(hBoundaryDesc, sPrivateNameSpace);
679676
if (m_hNamespace == NULL)
680677
{
681-
err = GetLastError();
682-
if (err != ERROR_DUP_NAME)
683-
raiseError("OpenPrivateNamespace");
684-
685-
Firebird::string name(sPrivateNameSpace);
686-
name.append("\\test");
678+
DWORD err = GetLastError();
679+
if (err != ERROR_ALREADY_EXISTS)
680+
raiseError("CreatePrivateNamespace");
687681

688-
m_hTestEvent = CreateEvent(ISC_get_security_desc(), TRUE, TRUE, name.c_str());
689-
if (m_hTestEvent == NULL)
690-
raiseError("CreateEvent");
682+
m_hNamespace = OpenPrivateNamespace(hBoundaryDesc, sPrivateNameSpace);
683+
if (m_hNamespace == NULL)
684+
{
685+
err = GetLastError();
686+
if ((err == ERROR_PATH_NOT_FOUND) && (retry++ < 100))
687+
{
688+
// Namespace was closed by its last holder, wait a bit and try again
689+
Thread::sleep(10);
690+
continue;
691+
}
692+
693+
if (err != ERROR_DUP_NAME)
694+
raiseError("OpenPrivateNamespace");
695+
696+
Firebird::string name(sPrivateNameSpace);
697+
name.append("\\test");
698+
699+
m_hTestEvent = CreateEvent(ISC_get_security_desc(), TRUE, TRUE, name.c_str());
700+
if (m_hTestEvent == NULL)
701+
raiseError("CreateEvent");
702+
}
691703
}
704+
705+
break;
692706
}
693707
}
694708

0 commit comments

Comments
 (0)