Skip to content

Commit

Permalink
Fixed bug CORE-3671 : JVM Access Violation when using Firebird Embedded
Browse files Browse the repository at this point in the history
  • Loading branch information
hvlad committed Dec 19, 2011
1 parent fb4e19e commit c7d5265
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/common/classes/init.cpp
Expand Up @@ -223,7 +223,7 @@ namespace Firebird

void InstanceControl::registerShutdown(FPTR_VOID shutdown)
{
fb_assert(!gdsShutdown || !shutdown);
fb_assert(!gdsShutdown || !shutdown || gdsShutdown == shutdown);
gdsShutdown = shutdown;
}

Expand Down
5 changes: 4 additions & 1 deletion src/jrd/gds.cpp
Expand Up @@ -997,6 +997,9 @@ const int SECS_PER_DAY = SECS_PER_HOUR * 24;
class CleanupTraceHandles
{
public:
CleanupTraceHandles(Firebird::MemoryPool&)
{};

~CleanupTraceHandles()
{
CloseHandle(trace_mutex_handle);
Expand All @@ -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<CleanupTraceHandles> cleanupHandles;

#endif

Expand Down
3 changes: 2 additions & 1 deletion src/jrd/jrd.cpp
Expand Up @@ -131,6 +131,7 @@

#include "../dsql/dsql.h"
#include "../dsql/dsql_proto.h"
#include "../common/dllinst.h"

using namespace Jrd;
using namespace Firebird;
Expand Down Expand Up @@ -3371,7 +3372,7 @@ int GDS_SHUTDOWN(unsigned int timeout)
attach_count, database_count, svc_count);
}

if (timeout)
if (timeout && !bEmbedded)
{
Semaphore shutdown_semaphore;

Expand Down
15 changes: 11 additions & 4 deletions src/jrd/why.cpp
Expand Up @@ -911,17 +911,17 @@ namespace
ISC_STATUS* local_vector;
};

#ifdef UNIX
int killed;
bool procInt, procTerm;

const int SHUTDOWN_TIMEOUT = 5000; // 5 sec

void atExitShutdown()
{
fb_shutdown(SHUTDOWN_TIMEOUT, fb_shutrsn_exit_called);
}

#ifdef UNIX
int killed;
bool procInt, procTerm;

GlobalPtr<SignalSafeSemaphore> shutdownSemaphore;

THREAD_ENTRY_DECLARE shutdownThread(THREAD_ENTRY_PARAM)
Expand Down Expand Up @@ -1031,6 +1031,13 @@ namespace
{
#ifdef UNIX
static GlobalPtr<CtrlCHandler> ctrlCHandler;
#elif defined WIN_NT
static volatile bool registered = false;
if (!registered)
{
registered = true;
InstanceControl::registerShutdown(atExitShutdown);
}
#endif //UNIX
if (att)
{
Expand Down

0 comments on commit c7d5265

Please sign in to comment.