|
From: <ale...@us...> - 2010-06-08 11:41:09
|
Revision: 51228
http://firebird.svn.sourceforge.net/firebird/?rev=51228&view=rev
Author: alexpeshkoff
Date: 2010-06-08 11:40:58 +0000 (Tue, 08 Jun 2010)
Log Message:
-----------
repeat commit for CORE-3021 in SVN
Modified Paths:
--------------
firebird/branches/B2_5_Release/builds/make.new/config/install-sh
firebird/branches/B2_5_Release/src/jrd/DatabaseSnapshot.cpp
firebird/branches/B2_5_Release/src/jrd/DatabaseSnapshot.h
firebird/branches/B2_5_Release/src/jrd/event.cpp
firebird/branches/B2_5_Release/src/jrd/event_proto.h
firebird/branches/B2_5_Release/src/jrd/isc.h
firebird/branches/B2_5_Release/src/jrd/isc_s_proto.h
firebird/branches/B2_5_Release/src/jrd/isc_sync.cpp
firebird/branches/B2_5_Release/src/jrd/trace/TraceConfigStorage.cpp
firebird/branches/B2_5_Release/src/jrd/trace/TraceConfigStorage.h
firebird/branches/B2_5_Release/src/jrd/trace/TraceLog.cpp
firebird/branches/B2_5_Release/src/jrd/trace/TraceLog.h
firebird/branches/B2_5_Release/src/lock/lock.cpp
firebird/branches/B2_5_Release/src/lock/lock_proto.h
Modified: firebird/branches/B2_5_Release/builds/make.new/config/install-sh
===================================================================
--- firebird/branches/B2_5_Release/builds/make.new/config/install-sh 2010-06-06 22:24:10 UTC (rev 51227)
+++ firebird/branches/B2_5_Release/builds/make.new/config/install-sh 2010-06-08 11:40:58 UTC (rev 51228)
@@ -1,7 +1,7 @@
#!/bin/sh
# install - install a program, script, or datafile
-scriptversion=2006-12-25.00
+scriptversion=2009-04-28.21; # UTC
# This originates from X11R5 (mit/util/scripts/install.sh), which was
# later released in X11R6 (xc/config/util/install.sh) with the
@@ -515,5 +515,6 @@
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
-# time-stamp-end: "$"
+# time-stamp-time-zone: "UTC"
+# time-stamp-end: "; # UTC"
# End:
Modified: firebird/branches/B2_5_Release/src/jrd/DatabaseSnapshot.cpp
===================================================================
--- firebird/branches/B2_5_Release/src/jrd/DatabaseSnapshot.cpp 2010-06-06 22:24:10 UTC (rev 51227)
+++ firebird/branches/B2_5_Release/src/jrd/DatabaseSnapshot.cpp 2010-06-08 11:40:58 UTC (rev 51228)
@@ -106,12 +106,7 @@
ISC_remove_map_file(&handle);
}
-#ifdef WIN_NT
- ISC_mutex_fini(&mutex);
-#else
- ISC_mutex_fini(&base->mutex);
-#endif
-
+ ISC_mutex_fini(mutex);
ISC_STATUS_ARRAY statusVector;
ISC_unmap_file(statusVector, &handle);
}
@@ -119,11 +114,8 @@
void DatabaseSnapshot::SharedData::acquire()
{
-#ifdef WIN_NT
- checkMutex("lock", ISC_mutex_lock(&mutex));
-#else
- checkMutex("lock", ISC_mutex_lock(&base->mutex));
-#endif
+ checkMutex("lock", ISC_mutex_lock(mutex));
+
if (base->allocated > handle.sh_mem_length_mapped)
{
#if (defined HAVE_MMAP || defined WIN_NT)
@@ -142,11 +134,7 @@
void DatabaseSnapshot::SharedData::release()
{
-#ifdef WIN_NT
- checkMutex("unlock", ISC_mutex_unlock(&mutex));
-#else
- checkMutex("unlock", ISC_mutex_unlock(&base->mutex));
-#endif
+ checkMutex("unlock", ISC_mutex_unlock(mutex));
}
@@ -314,20 +302,27 @@
fb_assert(shmem);
#ifdef WIN_NT
- checkMutex("init", ISC_mutex_init(&shmem->mutex, shmemData->sh_mem_name));
+ checkMutex("init", ISC_mutex_init(&shmem->winMutex, shmemData->sh_mem_name));
+ shmem->mutex = &shmem->winMutex;
#endif
+ Header* const header = (Header*) shmemData->sh_mem_address;
+
if (!initialize)
+ {
+#ifndef WIN_NT
+ checkMutex("map", ISC_map_mutex(shmemData, &header->mutex, &shmem->mutex));
+#endif
return;
+ }
// Initialize the shared data header
- Header* const header = (Header*) shmemData->sh_mem_address;
header->version = MONITOR_VERSION;
header->used = alignOffset(sizeof(Header));
header->allocated = shmemData->sh_mem_length_mapped;
#ifndef WIN_NT
- checkMutex("init", ISC_mutex_init(&header->mutex));
+ checkMutex("init", ISC_mutex_init(shmemData, &header->mutex, &shmem->mutex));
#endif
}
Modified: firebird/branches/B2_5_Release/src/jrd/DatabaseSnapshot.h
===================================================================
--- firebird/branches/B2_5_Release/src/jrd/DatabaseSnapshot.h 2010-06-06 22:24:10 UTC (rev 51227)
+++ firebird/branches/B2_5_Release/src/jrd/DatabaseSnapshot.h 2010-06-08 11:40:58 UTC (rev 51228)
@@ -233,8 +233,9 @@
sh_mem handle;
#ifdef WIN_NT
- struct mtx mutex;
+ struct mtx winMutex;
#endif
+ struct mtx *mutex;
Header* base;
const SLONG process_id;
Modified: firebird/branches/B2_5_Release/src/jrd/event.cpp
===================================================================
--- firebird/branches/B2_5_Release/src/jrd/event.cpp 2010-06-06 22:24:10 UTC (rev 51227)
+++ firebird/branches/B2_5_Release/src/jrd/event.cpp 2010-06-08 11:40:58 UTC (rev 51228)
@@ -61,7 +61,7 @@
#include <windows.h>
#define MUTEX &m_mutex
#else
-#define MUTEX &m_header->evh_mutex
+#define MUTEX m_mutex
#endif
#define SRQ_BASE ((UCHAR*) m_header)
@@ -1114,11 +1114,17 @@
#endif
m_sharedFileCreated = initialize;
+ m_header = (evh*) shmem_data->sh_mem_address;
if (!initialize)
+ {
+#ifndef WIN_NT
+ if ( (mutex_state = ISC_map_mutex(shmem_data, &m_header->evh_mutex, &MUTEX)) )
+ mutex_bugcheck("mutex map", mutex_state);
+#endif
return;
+ }
- m_header = (evh*) shmem_data->sh_mem_address;
m_header->evh_length = m_shmemData.sh_mem_length_mapped;
m_header->evh_version = EVENT_VERSION;
m_header->evh_request_id = 0;
@@ -1127,7 +1133,7 @@
SRQ_INIT(m_header->evh_events);
#ifndef WIN_NT
- if ( (mutex_state = ISC_mutex_init(MUTEX)) )
+ if ( (mutex_state = ISC_mutex_init(shmem_data, &m_header->evh_mutex, &MUTEX)) )
mutex_bugcheck("mutex init", mutex_state);
#endif
Modified: firebird/branches/B2_5_Release/src/jrd/event_proto.h
===================================================================
--- firebird/branches/B2_5_Release/src/jrd/event_proto.h 2010-06-06 22:24:10 UTC (rev 51227)
+++ firebird/branches/B2_5_Release/src/jrd/event_proto.h 2010-06-08 11:40:58 UTC (rev 51228)
@@ -114,6 +114,8 @@
#ifdef WIN_NT
struct mtx m_mutex;
+#else
+ struct mtx* m_mutex;
#endif
bool m_sharedFileCreated;
Modified: firebird/branches/B2_5_Release/src/jrd/isc.h
===================================================================
--- firebird/branches/B2_5_Release/src/jrd/isc.h 2010-06-06 22:24:10 UTC (rev 51227)
+++ firebird/branches/B2_5_Release/src/jrd/isc.h 2010-06-08 11:40:58 UTC (rev 51228)
@@ -43,12 +43,6 @@
// Looks like a lot of linux kernels are buggy when working with PRIO_INHERIT mutexes.
#undef HAVE_PTHREAD_MUTEXATTR_SETPROTOCOL
-#if (SIZEOF_VOID_P < 8) && defined(DEV_BUILD)
-// This hack fixes CORE-3021 - segfault in DEV_BUILD.
-// Release build does not cause visible problems.
-#undef HAVE_PTHREAD_MUTEXATTR_SETROBUST_NP
-#endif
-
#endif //LINUX
#ifdef UNIX
Modified: firebird/branches/B2_5_Release/src/jrd/isc_s_proto.h
===================================================================
--- firebird/branches/B2_5_Release/src/jrd/isc_s_proto.h 2010-06-06 22:24:10 UTC (rev 51227)
+++ firebird/branches/B2_5_Release/src/jrd/isc_s_proto.h 2010-06-08 11:40:58 UTC (rev 51228)
@@ -45,7 +45,7 @@
#if defined(WIN_NT)
int ISC_mutex_init(struct mtx*, const TEXT*);
#else
-int ISC_mutex_init(struct mtx*);
+int ISC_mutex_init(sh_mem* shmem_data, struct mtx* mutex, struct mtx** mapped);
#endif
int ISC_mutex_lock(struct mtx*);
@@ -58,6 +58,9 @@
void ISC_unmap_object(ISC_STATUS*, /*sh_mem*,*/ UCHAR**, ULONG);
#endif
+int ISC_map_mutex(sh_mem* shmem_data, mtx* mutex, mtx** mapped);
+void ISC_unmap_mutex(mtx* mutex);
+
#ifdef UNIX
void ISC_exception_post(ULONG, const TEXT*);
void ISC_sync_signals_set(void*);
Modified: firebird/branches/B2_5_Release/src/jrd/isc_sync.cpp
===================================================================
--- firebird/branches/B2_5_Release/src/jrd/isc_sync.cpp 2010-06-06 22:24:10 UTC (rev 51227)
+++ firebird/branches/B2_5_Release/src/jrd/isc_sync.cpp 2010-06-08 11:40:58 UTC (rev 51228)
@@ -2219,6 +2219,9 @@
#ifdef HAVE_MMAP
+
+#define HAVE_MAP_OBJECT 1
+
UCHAR* ISC_map_object(ISC_STATUS* status_vector,
sh_mem* shmem_data,
ULONG object_offset,
@@ -2278,7 +2281,6 @@
void ISC_unmap_object(ISC_STATUS* status_vector,
- //sh_mem* shmem_data,
UCHAR** object_pointer,
ULONG object_length)
{
@@ -2333,6 +2335,9 @@
#ifdef WIN_NT
+
+#define HAVE_MAP_OBJECT 1
+
UCHAR* ISC_map_object(ISC_STATUS* status_vector,
sh_mem* shmem_data,
ULONG object_offset,
@@ -2376,7 +2381,6 @@
void ISC_unmap_object(ISC_STATUS* status_vector,
- //sh_mem* shmem_data,
UCHAR** object_pointer,
ULONG /*object_length*/)
{
@@ -2409,12 +2413,42 @@
}
#endif
+int ISC_map_mutex(sh_mem* shmem_data, mtx* mutex, mtx** mapped)
+{
+#ifdef HAVE_MAP_OBJECT
+ ISC_STATUS_ARRAY temp;
+ mutex = reinterpret_cast<mtx*>(ISC_map_object(temp, shmem_data,
+ reinterpret_cast<UCHAR*>(mutex) - shmem_data->sh_mem_address, sizeof(mtx)));
+ if (!mutex)
+ {
+ iscLogStatus("ISC_map_mutex()", temp);
+ return -1;
+ }
+#endif // HAVE_MAP_OBJECT
+ *mapped = mutex;
+ return 0;
+}
+
+void ISC_unmap_mutex(mtx* mutex)
+{
+#ifdef HAVE_MAP_OBJECT
+ ISC_STATUS_ARRAY temp;
+ ISC_unmap_object(temp, reinterpret_cast<UCHAR**>(&mutex), sizeof(mtx));
+ if (mutex)
+ {
+ iscLogStatus("ISC_unmap_mutex()", temp);
+ }
+#endif // HAVE_MAP_OBJECT
+
+}
+
+
#ifdef USE_POSIX_THREADS
#ifdef USE_SYS5SEMAPHORE
-int ISC_mutex_init(struct mtx* mutex)
+int ISC_mutex_init(sh_mem* shmem_data, struct mtx* mutex, struct mtx** mapped)
{
/**************************************
*
@@ -2426,6 +2460,13 @@
* Initialize a mutex.
*
**************************************/
+
+ if (ISC_map_mutex(shmem_data, mutex, mapped) != 0)
+ {
+ return -1; // no errno known here...
+ }
+ mutex = *mapped;
+
if (!getSem5(mutex))
{
return FB_FAILURE;
@@ -2456,7 +2497,7 @@
* Destroy a mutex.
*
**************************************/
- // no-op for SystemV semaphores
+ ISC_unmap_mutex(mutex);
}
@@ -2562,7 +2603,7 @@
static volatile bool staticBugFlag = false;
#endif
-int ISC_mutex_init(struct mtx* mutex)
+int ISC_mutex_init(sh_mem* shmem_data, struct mtx* mutex, struct mtx** mapped)
{
/**************************************
*
@@ -2574,6 +2615,13 @@
* Initialize a mutex.
*
**************************************/
+
+ if (ISC_map_mutex(shmem_data, mutex, mapped) != 0)
+ {
+ return -1; // no errno known here...
+ }
+ mutex = *mapped;
+
#ifdef BUGGY_LINUX_MUTEX
do
{
@@ -2662,7 +2710,7 @@
* Destroy a mutex.
*
**************************************/
- // no-op for posix threads
+ ISC_unmap_mutex(mutex);
}
Modified: firebird/branches/B2_5_Release/src/jrd/trace/TraceConfigStorage.cpp
===================================================================
--- firebird/branches/B2_5_Release/src/jrd/trace/TraceConfigStorage.cpp 2010-06-06 22:24:10 UTC (rev 51227)
+++ firebird/branches/B2_5_Release/src/jrd/trace/TraceConfigStorage.cpp 2010-06-08 11:40:58 UTC (rev 51228)
@@ -179,7 +179,8 @@
fb_assert(storage);
#ifdef WIN_NT
- checkMutex("init", ISC_mutex_init(&storage->m_mutex, shmemData->sh_mem_name));
+ checkMutex("init", ISC_mutex_init(&storage->m_winMutex, shmemData->sh_mem_name));
+ storage->m_mutex = &storage->m_winMutex;
#endif
ShMemHeader* const header = (ShMemHeader*) shmemData->sh_mem_address;
@@ -195,7 +196,11 @@
header->touch_time = 0;
memset(header->cfg_file_name, 0, sizeof(header->cfg_file_name));
#ifndef WIN_NT
- checkMutex("init", ISC_mutex_init(&header->mutex));
+ checkMutex("init", ISC_mutex_init(shmemData, &header->mutex, &storage->m_mutex));
+ }
+ else
+ {
+ checkMutex("map", ISC_map_mutex(shmemData, &header->mutex, &storage->m_mutex));
#endif
}
}
@@ -344,22 +349,13 @@
void ConfigStorage::acquire()
{
-#ifdef WIN_NT
- checkMutex("lock", ISC_mutex_lock(&m_mutex));
-#else
- checkMutex("lock", ISC_mutex_lock(&m_base->mutex));
-#endif
+ checkMutex("lock", ISC_mutex_lock(m_mutex));
}
void ConfigStorage::release()
{
checkDirty();
-
-#ifdef WIN_NT
- checkMutex("unlock", ISC_mutex_unlock(&m_mutex));
-#else
- checkMutex("unlock", ISC_mutex_unlock(&m_base->mutex));
-#endif
+ checkMutex("unlock", ISC_mutex_unlock(m_mutex));
}
void ConfigStorage::addSession(TraceSession& session)
Modified: firebird/branches/B2_5_Release/src/jrd/trace/TraceConfigStorage.h
===================================================================
--- firebird/branches/B2_5_Release/src/jrd/trace/TraceConfigStorage.h 2010-06-06 22:24:10 UTC (rev 51227)
+++ firebird/branches/B2_5_Release/src/jrd/trace/TraceConfigStorage.h 2010-06-08 11:40:58 UTC (rev 51228)
@@ -122,8 +122,9 @@
sh_mem m_handle;
ShMemHeader* m_base;
#ifdef WIN_NT
- struct mtx m_mutex;
+ struct mtx m_winMutex;
#endif
+ struct mtx* m_mutex;
int m_cfg_file;
bool m_dirty;
Firebird::Semaphore m_touchStartSem;
Modified: firebird/branches/B2_5_Release/src/jrd/trace/TraceLog.cpp
===================================================================
--- firebird/branches/B2_5_Release/src/jrd/trace/TraceLog.cpp 2010-06-06 22:24:10 UTC (rev 51227)
+++ firebird/branches/B2_5_Release/src/jrd/trace/TraceLog.cpp 2010-06-08 11:40:58 UTC (rev 51228)
@@ -245,7 +245,8 @@
TraceLog* log = (TraceLog*) arg;
#ifdef WIN_NT
- checkMutex("init", ISC_mutex_init(&log->m_mutex, shmemData->sh_mem_name));
+ checkMutex("init", ISC_mutex_init(&log->m_winMutex, shmemData->sh_mem_name));
+ log->m_mutex = &log->m_winMutex;
#endif
ShMemHeader* const header = (ShMemHeader*) shmemData->sh_mem_address;
@@ -256,27 +257,23 @@
header->readFileNum = 0;
header->writeFileNum = 0;
#ifndef WIN_NT
- checkMutex("init", ISC_mutex_init(&header->mutex));
+ checkMutex("init", ISC_mutex_init(shmemData, &header->mutex, &log->m_mutex));
+ }
+ else
+ {
+ checkMutex("map", ISC_map_mutex(shmemData, &header->mutex, &log->m_mutex));
#endif
}
}
void TraceLog::lock()
{
-#ifdef WIN_NT
- checkMutex("lock", ISC_mutex_lock(&m_mutex));
-#else
- checkMutex("lock", ISC_mutex_lock(&m_base->mutex));
-#endif
+ checkMutex("lock", ISC_mutex_lock(m_mutex));
}
void TraceLog::unlock()
{
-#ifdef WIN_NT
- checkMutex("unlock", ISC_mutex_unlock(&m_mutex));
-#else
- checkMutex("unlock", ISC_mutex_unlock(&m_base->mutex));
-#endif
+ checkMutex("unlock", ISC_mutex_unlock(m_mutex));
}
} // namespace Jrd
Modified: firebird/branches/B2_5_Release/src/jrd/trace/TraceLog.h
===================================================================
--- firebird/branches/B2_5_Release/src/jrd/trace/TraceLog.h 2010-06-06 22:24:10 UTC (rev 51227)
+++ firebird/branches/B2_5_Release/src/jrd/trace/TraceLog.h 2010-06-08 11:40:58 UTC (rev 51228)
@@ -67,8 +67,9 @@
sh_mem m_handle;
ShMemHeader* m_base;
#ifdef WIN_NT
- struct mtx m_mutex;
+ struct mtx m_winMutex;
#endif
+ struct mtx* m_mutex;
Firebird::PathName m_baseFileName;
unsigned int m_fileNum;
Modified: firebird/branches/B2_5_Release/src/lock/lock.cpp
===================================================================
--- firebird/branches/B2_5_Release/src/lock/lock.cpp 2010-06-06 22:24:10 UTC (rev 51227)
+++ firebird/branches/B2_5_Release/src/lock/lock.cpp 2010-06-08 11:40:58 UTC (rev 51228)
@@ -97,7 +97,7 @@
#include <process.h>
#define MUTEX &m_shmemMutex
#else
-#define MUTEX &m_header->lhb_mutex
+#define MUTEX m_lhb_mutex
#endif
#ifdef DEV_BUILD
@@ -2317,6 +2317,7 @@
* to have an exclusive lock on the lock file.
*
**************************************/
+
#ifdef WIN_NT
if (ISC_mutex_init(MUTEX, shmem_data->sh_mem_name)) {
bug(NULL, "mutex init failed");
@@ -2336,6 +2337,11 @@
#endif
if (!initializeMemory) {
+#ifndef WIN_NT
+ if (ISC_map_mutex(shmem_data, &m_header->lhb_mutex, &(MUTEX))) {
+ bug(NULL, "mutex map failed");
+ }
+#endif
return;
}
@@ -2354,7 +2360,7 @@
SRQ_INIT(m_header->lhb_free_requests);
#ifndef WIN_NT
- if (ISC_mutex_init(MUTEX)) {
+ if (ISC_mutex_init(shmem_data, &m_header->lhb_mutex, &(MUTEX))) {
bug(NULL, "mutex init failed");
}
#endif
Modified: firebird/branches/B2_5_Release/src/lock/lock_proto.h
===================================================================
--- firebird/branches/B2_5_Release/src/lock/lock_proto.h 2010-06-06 22:24:10 UTC (rev 51227)
+++ firebird/branches/B2_5_Release/src/lock/lock_proto.h 2010-06-08 11:40:58 UTC (rev 51228)
@@ -438,6 +438,8 @@
#ifdef WIN_NT
struct mtx m_shmemMutex;
+#else
+ struct mtx* m_lhb_mutex;
#endif
#ifdef USE_SHMEM_EXT
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|