From c7d526542632ec3406b4fb0a3d4a3733839d4e0f Mon Sep 17 00:00:00 2001 From: hvlad Date: Mon, 19 Dec 2011 16:01:11 +0000 Subject: [PATCH] Fixed bug CORE-3671 : JVM Access Violation when using Firebird Embedded --- src/common/classes/init.cpp | 2 +- src/jrd/gds.cpp | 5 ++++- src/jrd/jrd.cpp | 3 ++- src/jrd/why.cpp | 15 +++++++++++---- 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/common/classes/init.cpp b/src/common/classes/init.cpp index 3251a591b4a..fa0ed8a0b5a 100644 --- a/src/common/classes/init.cpp +++ b/src/common/classes/init.cpp @@ -223,7 +223,7 @@ namespace Firebird void InstanceControl::registerShutdown(FPTR_VOID shutdown) { - fb_assert(!gdsShutdown || !shutdown); + fb_assert(!gdsShutdown || !shutdown || gdsShutdown == shutdown); gdsShutdown = shutdown; } diff --git a/src/jrd/gds.cpp b/src/jrd/gds.cpp index 461a3fe1f02..f55b9cc3207 100644 --- a/src/jrd/gds.cpp +++ b/src/jrd/gds.cpp @@ -997,6 +997,9 @@ const int SECS_PER_DAY = SECS_PER_HOUR * 24; class CleanupTraceHandles { public: + CleanupTraceHandles(Firebird::MemoryPool&) + {}; + ~CleanupTraceHandles() { CloseHandle(trace_mutex_handle); @@ -1017,7 +1020,7 @@ class CleanupTraceHandles HANDLE CleanupTraceHandles::trace_mutex_handle = CreateMutex(NULL, FALSE, "firebird_trace_mutex"); HANDLE CleanupTraceHandles::trace_file_handle = INVALID_HANDLE_VALUE; -CleanupTraceHandles cleanupHandles; +Firebird::GlobalPtr cleanupHandles; #endif diff --git a/src/jrd/jrd.cpp b/src/jrd/jrd.cpp index e08a5240b34..86484eb647b 100644 --- a/src/jrd/jrd.cpp +++ b/src/jrd/jrd.cpp @@ -131,6 +131,7 @@ #include "../dsql/dsql.h" #include "../dsql/dsql_proto.h" +#include "../common/dllinst.h" using namespace Jrd; using namespace Firebird; @@ -3371,7 +3372,7 @@ int GDS_SHUTDOWN(unsigned int timeout) attach_count, database_count, svc_count); } - if (timeout) + if (timeout && !bEmbedded) { Semaphore shutdown_semaphore; diff --git a/src/jrd/why.cpp b/src/jrd/why.cpp index 2cb1049e4d3..14bfbb60417 100644 --- a/src/jrd/why.cpp +++ b/src/jrd/why.cpp @@ -911,10 +911,6 @@ namespace ISC_STATUS* local_vector; }; -#ifdef UNIX - int killed; - bool procInt, procTerm; - const int SHUTDOWN_TIMEOUT = 5000; // 5 sec void atExitShutdown() @@ -922,6 +918,10 @@ namespace fb_shutdown(SHUTDOWN_TIMEOUT, fb_shutrsn_exit_called); } +#ifdef UNIX + int killed; + bool procInt, procTerm; + GlobalPtr shutdownSemaphore; THREAD_ENTRY_DECLARE shutdownThread(THREAD_ENTRY_PARAM) @@ -1031,6 +1031,13 @@ namespace { #ifdef UNIX static GlobalPtr ctrlCHandler; +#elif defined WIN_NT + static volatile bool registered = false; + if (!registered) + { + registered = true; + InstanceControl::registerShutdown(atExitShutdown); + } #endif //UNIX if (att) {