|
From: <asf...@us...> - 2010-06-05 02:41:21
|
Revision: 51209
http://firebird.svn.sourceforge.net/firebird/?rev=51209&view=rev
Author: asfernandes
Date: 2010-06-05 02:41:14 +0000 (Sat, 05 Jun 2010)
Log Message:
-----------
Port CVS changes (includes CORE-2993, CORE-3010, CORE-3011, CORE-3015, CORE-3016, CORE-3017 and CORE-3021)
Modified Paths:
--------------
firebird/branches/B2_5_Release/builds/install/arch-specific/linux/misc/firebird.init.d.gentoo.in
firebird/branches/B2_5_Release/doc/WhatsNew
firebird/branches/B2_5_Release/src/common/classes/alloc.cpp
firebird/branches/B2_5_Release/src/jrd/Database.h
firebird/branches/B2_5_Release/src/jrd/DatabaseSnapshot.cpp
firebird/branches/B2_5_Release/src/jrd/build_no.h
firebird/branches/B2_5_Release/src/jrd/cch.cpp
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/isc_version.h
firebird/branches/B2_5_Release/src/jrd/jrd.cpp
firebird/branches/B2_5_Release/src/jrd/trace/TraceConfigStorage.cpp
firebird/branches/B2_5_Release/src/misc/writeBuildNum.sh
Modified: firebird/branches/B2_5_Release/builds/install/arch-specific/linux/misc/firebird.init.d.gentoo.in
===================================================================
--- firebird/branches/B2_5_Release/builds/install/arch-specific/linux/misc/firebird.init.d.gentoo.in 2010-06-05 01:54:52 UTC (rev 51208)
+++ firebird/branches/B2_5_Release/builds/install/arch-specific/linux/misc/firebird.init.d.gentoo.in 2010-06-05 02:41:14 UTC (rev 51209)
@@ -6,9 +6,6 @@
# on system startup and shutdown to start the background
# Firebird database server daemon
-# Source function library.
-. /etc/init.d/functions.sh
-
# To run more instances of firebird:
# Copy @prefix@ somewhere
# Copy this script under a new name
@@ -49,19 +46,19 @@
GUARDIAN=@FB_SBINDIR@/fbguard
fi
-start(){
+start() {
ebegin "Starting $FULLNAME"
start-stop-daemon --oknodo --start --pidfile $pidfile --chuid $FBRunUser --startas $GUARDIAN -- $FB_OPTS
eend $?
}
-stop(){
+stop() {
ebegin "Stopping $FULLNAME"
start-stop-daemon --stop --pidfile $pidfile --oknodo
eend $?
}
-restart(){
+restart() {
svc_stop
sleep 1
svc_start
Modified: firebird/branches/B2_5_Release/doc/WhatsNew
===================================================================
--- firebird/branches/B2_5_Release/doc/WhatsNew 2010-06-05 01:54:52 UTC (rev 51208)
+++ firebird/branches/B2_5_Release/doc/WhatsNew 2010-06-05 02:41:14 UTC (rev 51209)
@@ -2,6 +2,39 @@
* v2.5 Release Candidate 3
**************************
+ * Bugfix CORE-3021
+ Segfault in DEV_BUILD
+ Contributor(s):
+ Alex Peshkov <peshkoff at mail.ru>
+
+ * Bugfix CORE-3017
+ Files left at Firebird's lock directory
+ Contributor(s):
+ Vlad Khorsun <hvlad at users.sourceforge.net>
+ Alex Peshkov <peshkoff at mail.ru>
+
+ * Bugfix CORE-3016
+ On disconnect it is possible to see "Fatal lock manager error: invalid lock id (0), errno: 0"
+ in firebird.log
+ Contributor(s):
+ Vlad Khorsun <hvlad at users.sourceforge.net>
+
+ * Bugfix CORE-3015
+ Various "Cannot initialize the shared memory region" errors
+ Contributor(s):
+ Vlad Khorsun <hvlad at users.sourceforge.net>
+
+ * Bugfix CORE-3011
+ Server hangs or crashes while monitoring connections repeatedly attaching and detaching
+ Contributor(s):
+ Dmitry Yemanov <dimitr at firebirdsql.org>
+
+ * Bugfix CORE-3010
+ First connect to any database shows MON$MEMORY_USED = 4Gb
+ Contributor(s):
+ Dmitry Yemanov <dimitr at firebirdsql.org>
+ Vlad Khorsun <hvlad at users.sourceforge.net>
+
* Bugfix CORE-3006
/tmp/firebird and files in it may get 'root' (i.e. GID == 0) group
Contributor(s):
Modified: firebird/branches/B2_5_Release/src/common/classes/alloc.cpp
===================================================================
--- firebird/branches/B2_5_Release/src/common/classes/alloc.cpp 2010-06-05 01:54:52 UTC (rev 51208)
+++ firebird/branches/B2_5_Release/src/common/classes/alloc.cpp 2010-06-05 02:41:14 UTC (rev 51209)
@@ -1371,6 +1371,9 @@
MemoryExtent* extent = pool->extents_parent;
while (extent) {
MemoryExtent* next = extent->mxt_next;
+
+ MemoryBlock* blk = ptrToBlock(extent);
+ parent->increment_usage(blk->mbk_small.mbk_length);
parent->deallocate(extent);
extent = next;
}
@@ -1731,6 +1734,7 @@
}
else
{
+ parent->increment_usage(ext_size);
parent->deallocate(extent);
}
}
Modified: firebird/branches/B2_5_Release/src/jrd/Database.h
===================================================================
--- firebird/branches/B2_5_Release/src/jrd/Database.h 2010-06-05 01:54:52 UTC (rev 51208)
+++ firebird/branches/B2_5_Release/src/jrd/Database.h 2010-06-05 02:41:14 UTC (rev 51209)
@@ -107,6 +107,7 @@
const ULONG DBB_gc_background = 0x40000L; // background garbage collection by gc_thread
const ULONG DBB_no_fs_cache = 0x80000L; // Not using file system cache
const ULONG DBB_destroying = 0x100000L; // database destructor is called
+const ULONG DBB_monitor_locking = 0x200000L; // monitoring lock is being acquired
//
// dbb_ast_flags
Modified: firebird/branches/B2_5_Release/src/jrd/DatabaseSnapshot.cpp
===================================================================
--- firebird/branches/B2_5_Release/src/jrd/DatabaseSnapshot.cpp 2010-06-05 01:54:52 UTC (rev 51208)
+++ firebird/branches/B2_5_Release/src/jrd/DatabaseSnapshot.cpp 2010-06-05 02:41:14 UTC (rev 51209)
@@ -101,6 +101,9 @@
{ // scope
DumpGuard guard(this);
cleanup();
+
+ if (base->used == sizeof(Header))
+ ISC_remove_map_file(&handle);
}
#ifdef WIN_NT
@@ -387,8 +390,13 @@
}
}
- // Release the lock and mark dbb as requesting a new one
- LCK_release(tdbb, lock);
+ // Release the lock, if feasible
+ if (!(dbb->dbb_flags & DBB_monitor_locking))
+ {
+ LCK_release(tdbb, lock);
+ }
+
+ // Mark dbb as requesting a new lock
dbb->dbb_ast_flags |= DBB_monitor_off;
}
}
Modified: firebird/branches/B2_5_Release/src/jrd/build_no.h
===================================================================
--- firebird/branches/B2_5_Release/src/jrd/build_no.h 2010-06-05 01:54:52 UTC (rev 51208)
+++ firebird/branches/B2_5_Release/src/jrd/build_no.h 2010-06-05 02:41:14 UTC (rev 51209)
@@ -3,16 +3,16 @@
*** DO NOT EDIT ***
TO CHANGE ANY INFORMATION IN HERE PLEASE
EDIT src/misc/writeBuildNum.sh
- FORMAL BUILD NUMBER:26024
+ FORMAL BUILD NUMBER:26038
*/
-#define PRODUCT_VER_STRING "2.5.0.26024"
-#define FILE_VER_STRING "WI-V2.5.0.26024"
-#define LICENSE_VER_STRING "WI-V2.5.0.26024"
-#define FILE_VER_NUMBER 2, 5, 0, 26024
+#define PRODUCT_VER_STRING "2.5.0.26038"
+#define FILE_VER_STRING "WI-V2.5.0.26038"
+#define LICENSE_VER_STRING "WI-V2.5.0.26038"
+#define FILE_VER_NUMBER 2, 5, 0, 26038
#define FB_MAJOR_VER "2"
#define FB_MINOR_VER "5"
#define FB_REV_NO "0"
-#define FB_BUILD_NO "26024"
+#define FB_BUILD_NO "26038"
#define FB_BUILD_TYPE "V"
#define FB_BUILD_SUFFIX "Firebird 2.5 Release Candidate 3"
Modified: firebird/branches/B2_5_Release/src/jrd/cch.cpp
===================================================================
--- firebird/branches/B2_5_Release/src/jrd/cch.cpp 2010-06-05 01:54:52 UTC (rev 51208)
+++ firebird/branches/B2_5_Release/src/jrd/cch.cpp 2010-06-05 02:41:14 UTC (rev 51209)
@@ -374,6 +374,9 @@
{
Database::SyncGuard dsGuard(dbb, true);
+ if (dbb->dbb_flags & DBB_not_in_use)
+ return 0;
+
Lock* const lock = dbb->dbb_lock;
// Since this routine will be called asynchronously,
Modified: firebird/branches/B2_5_Release/src/jrd/isc.h
===================================================================
--- firebird/branches/B2_5_Release/src/jrd/isc.h 2010-06-05 01:54:52 UTC (rev 51208)
+++ firebird/branches/B2_5_Release/src/jrd/isc.h 2010-06-05 02:41:14 UTC (rev 51209)
@@ -38,11 +38,19 @@
#endif
#ifdef LINUX
+
// This hack fixes CORE-2896 - embedded connections fail on linux.
// 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
#if defined(USE_POSIX_THREADS)
@@ -105,6 +113,7 @@
UCHAR *sh_mem_address;
ULONG sh_mem_length_mapped;
SLONG sh_mem_handle;
+ TEXT sh_mem_name[MAXPATHLEN];
};
#endif // 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-05 01:54:52 UTC (rev 51208)
+++ firebird/branches/B2_5_Release/src/jrd/isc_s_proto.h 2010-06-05 02:41:14 UTC (rev 51209)
@@ -72,5 +72,6 @@
void ISC_unmap_file(ISC_STATUS*, struct sh_mem*);
void ISC_remove_map_file(const TEXT* filename);
+void ISC_remove_map_file(const struct sh_mem*);
#endif // JRD_ISC_S_PROTO_H
Modified: firebird/branches/B2_5_Release/src/jrd/isc_sync.cpp
===================================================================
--- firebird/branches/B2_5_Release/src/jrd/isc_sync.cpp 2010-06-05 01:54:52 UTC (rev 51208)
+++ firebird/branches/B2_5_Release/src/jrd/isc_sync.cpp 2010-06-05 02:41:14 UTC (rev 51209)
@@ -1679,14 +1679,21 @@
void ISC_remove_map_file(const TEXT* filename)
{
+#ifndef WIN_NT
TEXT expanded_filename[MAXPATHLEN];
gds__prefix_lock(expanded_filename, filename);
// We can't do much (specially in dtors) when it fails
// therefore do not check for errors - at least it's just /tmp.
unlink(expanded_filename);
+#endif // WIN_NT
}
+void ISC_remove_map_file(const struct sh_mem* shmem_data)
+{
+ ISC_remove_map_file(shmem_data->sh_mem_name);
+}
+
#ifdef UNIX
UCHAR* ISC_map_file(ISC_STATUS* status_vector,
@@ -1822,6 +1829,7 @@
shmem_data->sh_mem_address = address;
shmem_data->sh_mem_length_mapped = length;
shmem_data->sh_mem_handle = fd;
+ strcpy(shmem_data->sh_mem_name, filename);
#ifdef USE_SYS5SEMAPHORE
// register mapped file
@@ -1924,20 +1932,23 @@
* routine (if given) or punt (leaving the file unmapped).
*
**************************************/
- HANDLE file_handle, event_handle;
+ HANDLE file_handle;
+ HANDLE event_handle = 0;
int retry_count = 0;
TEXT expanded_filename[MAXPATHLEN];
gds__prefix_lock(expanded_filename, filename);
const bool trunc_flag = (length != 0);
+ bool init_flag = false;
/* retry to attach to mmapped file if the process initializing
* dies during initialization.
*/
retry:
- retry_count++;
+ if (retry_count++ > 0)
+ THREAD_SLEEP(10);
file_handle = CreateFile(expanded_filename,
GENERIC_READ | GENERIC_WRITE,
@@ -1946,15 +1957,19 @@
OPEN_ALWAYS,
FILE_ATTRIBUTE_NORMAL,
NULL);
+ DWORD err = GetLastError();
if (file_handle == INVALID_HANDLE_VALUE)
{
- error(status_vector, "CreateFile", GetLastError());
+ if (err == ERROR_SHARING_VIOLATION)
+ goto retry;
+
+ error(status_vector, "CreateFile", err);
return NULL;
}
// Check if file already exists
- const bool file_exists = (GetLastError() == ERROR_ALREADY_EXISTS);
+ const bool file_exists = (err == ERROR_ALREADY_EXISTS);
// Create an event that can be used to determine if someone has already
// initialized shared memory.
@@ -1967,22 +1982,25 @@
return NULL;
}
- event_handle = CreateEvent(ISC_get_security_desc(), TRUE, FALSE, object_name);
- if (!event_handle)
+ if (!init_flag)
{
- error(status_vector, "CreateEvent", GetLastError());
- CloseHandle(file_handle);
- return NULL;
- }
+ event_handle = CreateEvent(ISC_get_security_desc(), TRUE, FALSE, object_name);
+ if (!event_handle)
+ {
+ error(status_vector, "CreateEvent", GetLastError());
+ CloseHandle(file_handle);
+ return NULL;
+ }
- const bool init_flag = (GetLastError() != ERROR_ALREADY_EXISTS);
+ init_flag = (GetLastError() != ERROR_ALREADY_EXISTS);
- if (init_flag && !init_routine)
- {
- CloseHandle(event_handle);
- CloseHandle(file_handle);
- Arg::Gds(isc_unavailable).copyTo(status_vector);
- return NULL;
+ if (init_flag && !init_routine)
+ {
+ CloseHandle(event_handle);
+ CloseHandle(file_handle);
+ Arg::Gds(isc_unavailable).copyTo(status_vector);
+ return NULL;
+ }
}
if (length == 0)
@@ -2022,7 +2040,7 @@
CloseHandle(event_handle);
if (retry_count > 10)
{
- error(status_vector, "WaitForSingleObject", GetLastError());
+ error(status_vector, "WaitForSingleObject", 0);
return NULL;
}
goto retry;
@@ -2046,6 +2064,14 @@
{
const DWORD err = GetLastError();
+ if ((err == ERROR_SHARING_VIOLATION) || (err == ERROR_FILE_NOT_FOUND && fdw_create == TRUNCATE_EXISTING))
+ {
+ if (!init_flag) {
+ CloseHandle(event_handle);
+ }
+ goto retry;
+ }
+
if (err == ERROR_USER_MAPPED_FILE && init_flag && file_exists && trunc_flag)
Arg::Gds(isc_instance_conflict).copyTo(status_vector);
else
@@ -3403,11 +3429,18 @@
TEXT expanded_filename[MAXPATHLEN];
gds__prefix_lock(expanded_filename, shmem_data->sh_mem_name);
- if (!DeleteFile(expanded_filename))
- {
- error(status_vector, "DeleteFile", GetLastError());
- return;
- }
+
+ // Delete file only if it is not used by anyone else
+ HANDLE hFile = CreateFile(expanded_filename,
+ DELETE,
+ 0,
+ NULL,
+ OPEN_EXISTING,
+ FILE_ATTRIBUTE_NORMAL | FILE_FLAG_DELETE_ON_CLOSE,
+ NULL);
+
+ if (hFile != INVALID_HANDLE_VALUE)
+ CloseHandle(hFile);
}
#endif
Modified: firebird/branches/B2_5_Release/src/jrd/isc_version.h
===================================================================
--- firebird/branches/B2_5_Release/src/jrd/isc_version.h 2010-06-05 01:54:52 UTC (rev 51208)
+++ firebird/branches/B2_5_Release/src/jrd/isc_version.h 2010-06-05 02:41:14 UTC (rev 51209)
@@ -17,7 +17,7 @@
* Contributor(s): ______________________________________.
*/
-#define ISC_FILE_VER_STRING "WI-T6.3.4.26024"
-#define ISC_FILE_VER_NUMBER 6, 3, 4, 26024
+#define ISC_FILE_VER_STRING "WI-T6.3.4.26038"
+#define ISC_FILE_VER_NUMBER 6, 3, 4, 26038
#define ISC_MAJOR_VER "6"
#define ISC_MINOR_VER "3"
Modified: firebird/branches/B2_5_Release/src/jrd/jrd.cpp
===================================================================
--- firebird/branches/B2_5_Release/src/jrd/jrd.cpp 2010-06-05 01:54:52 UTC (rev 51208)
+++ firebird/branches/B2_5_Release/src/jrd/jrd.cpp 2010-06-05 02:41:14 UTC (rev 51209)
@@ -525,7 +525,8 @@
static bool drop_files(const jrd_file*);
static void find_intl_charset(thread_db*, Attachment*, const DatabaseOptions*);
static jrd_tra* find_transaction(thread_db*, ISC_STATUS);
-static void init_database_locks(thread_db*);
+static void init_database_lock(thread_db*);
+static void init_monitoring_lock(thread_db*);
static ISC_STATUS handle_error(ISC_STATUS*, ISC_STATUS);
static void run_commit_triggers(thread_db* tdbb, jrd_tra* transaction);
static void verify_request_synchronization(jrd_req*& request, SSHORT level);
@@ -1000,8 +1001,8 @@
LCK_init(tdbb, LCK_OWNER_attachment);
attachment->att_flags |= ATT_lck_init_done;
- // Initialize locks
- init_database_locks(tdbb);
+ // Initialize the database lock
+ init_database_lock(tdbb);
INI_init(tdbb);
SHUT_init(tdbb);
@@ -1032,6 +1033,9 @@
// initialize shadowing as soon as the database is ready for it
// but before any real work is done
SDW_init(tdbb, options.dpb_activate_shadow, options.dpb_delete_shadow);
+
+ // Turn monitoring on
+ init_monitoring_lock(tdbb);
}
else
{
@@ -2040,8 +2044,8 @@
LCK_init(tdbb, LCK_OWNER_attachment);
attachment->att_flags |= ATT_lck_init_done;
- // Initialize locks
- init_database_locks(tdbb);
+ // Initialize the database lock
+ init_database_lock(tdbb);
INI_init(tdbb);
PAG_init(tdbb);
@@ -2116,6 +2120,9 @@
VIO_init(tdbb);
#endif
+ // Turn monitoring on
+ init_monitoring_lock(tdbb);
+
if (options.dpb_set_db_readonly)
{
if (!CCH_exclusive (tdbb, LCK_EX, WAIT_PERIOD))
@@ -4103,7 +4110,9 @@
if (dbb->dbb_ast_flags & DBB_monitor_off)
{
dbb->dbb_ast_flags &= ~DBB_monitor_off;
+ dbb->dbb_flags |= DBB_monitor_locking;
LCK_lock(tdbb, dbb->dbb_monitor_lock, LCK_SR, LCK_WAIT);
+ dbb->dbb_flags &= ~DBB_monitor_locking;
// While waiting for return from LCK_lock call above the blocking AST (see
// DatabaseSnapshot::blockingAst) was called and set DBB_monitor_off flag
@@ -4219,7 +4228,9 @@
if (dbb->dbb_ast_flags & DBB_monitor_off)
{
dbb->dbb_ast_flags &= ~DBB_monitor_off;
+ dbb->dbb_flags |= DBB_monitor_locking;
LCK_lock(tdbb, dbb->dbb_monitor_lock, LCK_SR, LCK_WAIT);
+ dbb->dbb_flags &= ~DBB_monitor_locking;
if (dbb->dbb_ast_flags & DBB_monitor_off)
LCK_release(tdbb, dbb->dbb_monitor_lock);
@@ -4915,16 +4926,16 @@
}
-static void init_database_locks(thread_db* tdbb)
+static void init_database_lock(thread_db* tdbb)
{
/**************************************
*
- * i n i t _ d a t a b a s e _ l o c k s
+ * i n i t _ d a t a b a s e _ l o c k
*
**************************************
*
* Functional description
- * Initialize database locks.
+ * Initialize the database lock.
*
**************************************/
SET_TDBB(tdbb);
@@ -4977,11 +4988,27 @@
}
}
}
+}
+static void init_monitoring_lock(thread_db* tdbb)
+{
+/**************************************
+ *
+ * i n i t _ m o n i t o r i n g _ l o c k
+ *
+ **************************************
+ *
+ * Functional description
+ * Initialize the monitoring lock.
+ *
+ **************************************/
+ SET_TDBB(tdbb);
+ Database* const dbb = tdbb->getDatabase();
+
// Lock shared by all dbb owners, used to signal other processes
// to dump their monitoring data and synchronize operations
- lock = FB_NEW_RPT(*dbb->dbb_permanent, sizeof(SLONG)) Lock();
+ Lock* const lock = FB_NEW_RPT(*dbb->dbb_permanent, sizeof(SLONG)) Lock();
dbb->dbb_monitor_lock = lock;
lock->lck_type = LCK_monitor;
lock->lck_owner_handle = LCK_get_owner_handle(tdbb, lock->lck_type);
Modified: firebird/branches/B2_5_Release/src/jrd/trace/TraceConfigStorage.cpp
===================================================================
--- firebird/branches/B2_5_Release/src/jrd/trace/TraceConfigStorage.cpp 2010-06-05 01:54:52 UTC (rev 51208)
+++ firebird/branches/B2_5_Release/src/jrd/trace/TraceConfigStorage.cpp 2010-06-05 02:41:14 UTC (rev 51209)
@@ -150,6 +150,8 @@
{
unlink(m_base->cfg_file_name);
memset(m_base->cfg_file_name, 0, sizeof(m_base->cfg_file_name));
+
+ ISC_remove_map_file(&m_handle);
}
}
Modified: firebird/branches/B2_5_Release/src/misc/writeBuildNum.sh
===================================================================
--- firebird/branches/B2_5_Release/src/misc/writeBuildNum.sh 2010-06-05 01:54:52 UTC (rev 51208)
+++ firebird/branches/B2_5_Release/src/misc/writeBuildNum.sh 2010-06-05 02:41:14 UTC (rev 51209)
@@ -3,13 +3,13 @@
# This file is used both to rebuild the header file and to set the
# environment variables on the config call
-BuildVersion="$Id: writeBuildNum.sh,v 1.25898.2.18 2010-05-21 05:19:49 dimitr Exp $"
+BuildVersion="$Id: writeBuildNum.sh,v 1.25898.2.19 2010/05/28 14:38:22 alexpeshkoff Exp $"
BuildType=V
MajorVer=2
MinorVer=5
RevNo=0
-BuildNum=26024
+BuildNum=26038
if [ "$SPECIAL_BUILD_SUFFIX" = "" ]; then
# Normal builds
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|