diff --git a/src/jrd/dls.cpp b/src/jrd/dls.cpp index 875ed3f627..2504263fe0 100644 --- a/src/jrd/dls.cpp +++ b/src/jrd/dls.cpp @@ -73,14 +73,8 @@ bool DLS_get_temp_space(ULONG size, sort_work_file* sfb) mutexed_dir_list* ptr = DLS_get_access(); -#ifdef V4_THREADING - if (!ptr->mdls_mutex_init) { - V4_MUTEX_INIT(ptr->mdls_mutex); - ptr->mdls_mutex_init = true; - } + Firebird::MutexLockGuard guard(ptr->mdls_mutex); - V4_MUTEX_LOCK(ptr->mdls_mutex); -#endif if (!sfb->sfb_dls) { /* allocate temp. space starting search from the begining of the dir_list */ for (sfb->sfb_dls = ptr->mdls_dls; @@ -101,11 +95,8 @@ bool DLS_get_temp_space(ULONG size, sort_work_file* sfb) result = true; } } -#ifdef V4_THREADING - V4_MUTEX_UNLOCK(ptr->mdls_mutex); -#endif - return (result); + return result; } @@ -123,18 +114,12 @@ void DLS_put_temp_space(sort_work_file* sfb) **************************************/ if (sfb && sfb->sfb_dls) { mutexed_dir_list* ptr = DLS_get_access(); -#ifdef V4_THREADING - fb_assert(ptr->mdls_mutex_init); - V4_MUTEX_LOCK(ptr->mdls_mutex); -#endif + Firebird::MutexLockGuard guard(ptr->mdls_mutex); fb_assert(sfb->sfb_dls->dls_inuse >= sfb->sfb_file_size); if (sfb->sfb_dls->dls_inuse > sfb->sfb_file_size) sfb->sfb_dls->dls_inuse -= sfb->sfb_file_size; else sfb->sfb_dls->dls_inuse = 0; -#ifdef V4_THREADING - V4_MUTEX_UNLOCK(ptr->mdls_mutex); -#endif } } @@ -168,16 +153,7 @@ bool DLS_add_dir(ULONG size, const TEXT* dir_name) mutexed_dir_list* mdls = DLS_get_access(); -#ifdef V4_THREADING -/* lock mutex, initialize it in case of the first access */ - - if (!mdls->mdls_mutex_init) { - V4_MUTEX_INIT(mdls->mdls_mutex); - mdls->mdls_mutex_init = true; - } - - V4_MUTEX_LOCK(mdls->mdls_mutex); -#endif + Firebird::MutexLockGuard guard(mdls->mdls_mutex); /* add new entry to the end of list */ @@ -191,12 +167,6 @@ bool DLS_add_dir(ULONG size, const TEXT* dir_name) dls_iterator->dls_next = new_dls; } -#ifdef V4_THREADING -/* release lock */ - - V4_MUTEX_UNLOCK(mdls->mdls_mutex); -#endif - return true; } diff --git a/src/jrd/fil.h b/src/jrd/fil.h index 33b546d7d5..009341cb1f 100644 --- a/src/jrd/fil.h +++ b/src/jrd/fil.h @@ -47,11 +47,10 @@ struct dir_list { struct mutexed_dir_list { dir_list* mdls_dls; /* Pointer to the directory list */ - bool mdls_mutex_init; - MUTX_T mdls_mutex[1]; /* Mutex for directory list. Must + MUTX_T mdls_mutex; /* Mutex for directory list. Must be locked before list operations */ mutexed_dir_list() - : mdls_dls(0), mdls_mutex_init(false) {} + : mdls_dls(NULL) {} }; /* external function directory list */ diff --git a/src/jrd/thd.h b/src/jrd/thd.h index 8ac0bba570..94e403823f 100644 --- a/src/jrd/thd.h +++ b/src/jrd/thd.h @@ -199,19 +199,15 @@ struct wlck_t { int THD_wlck_lock(wlck_t*, enum WLCK_type); int THD_wlck_unlock(wlck_t*); -#define V4_MUTEX_LOCK(mutx) THD_mutex_lock (mutx) -#define V4_MUTEX_UNLOCK(mutx) THD_mutex_unlock (mutx) -#define V4_GLOBAL_MUTEX_LOCK THD_mutex_lock_global() -#define V4_GLOBAL_MUTEX_UNLOCK THD_mutex_unlock_global() -#define V4_RW_LOCK_LOCK(wlck, type) THD_wlck_lock (wlck, type) -#define V4_RW_LOCK_UNLOCK(wlck) THD_wlck_unlock (wlck) +#define V4_RW_LOCK_LOCK(wlck, type) THD_wlck_lock(wlck, type) +#define V4_RW_LOCK_UNLOCK(wlck) THD_wlck_unlock(wlck) #endif // V4_THREADING #ifdef ANY_THREADING #define THD_GLOBAL_MUTEX_LOCK THD_mutex_lock_global() #define THD_GLOBAL_MUTEX_UNLOCK THD_mutex_unlock_global() -#define THD_MUTEX_LOCK(mutx) THD_mutex_lock (mutx) -#define THD_MUTEX_UNLOCK(mutx) THD_mutex_unlock (mutx) +#define THD_MUTEX_LOCK(mutx) THD_mutex_lock(mutx) +#define THD_MUTEX_UNLOCK(mutx) THD_mutex_unlock(mutx) #else #define THD_GLOBAL_MUTEX_LOCK #define THD_GLOBAL_MUTEX_UNLOCK diff --git a/src/jrd/vio.cpp b/src/jrd/vio.cpp index 3a35e3cf59..730edaa922 100644 --- a/src/jrd/vio.cpp +++ b/src/jrd/vio.cpp @@ -1620,10 +1620,6 @@ Record* VIO_gc_record(thread_db* tdbb, jrd_rel* relation) Database* dbb = tdbb->tdbb_database; CHECK_DBB(dbb); -/* This will require mutex synchronization for pre-emptive multithreading. */ - -/* V4_MUTEX_LOCK (&relation->rel_mutex); */ - /* Allocate a vector of garbage collect record blocks for relation. */ vec* vector = relation->rel_gc_rec; if (!vector) { @@ -1638,7 +1634,6 @@ Record* VIO_gc_record(thread_db* tdbb, jrd_rel* relation) Record* record = *rec_ptr; if (record && !(record->rec_flags & REC_gc_active)) { record->rec_flags |= REC_gc_active; -/* V4_MUTEX_UNLOCK (&relation->rel_mutex); */ return record; } } @@ -1659,7 +1654,6 @@ Record* VIO_gc_record(thread_db* tdbb, jrd_rel* relation) } (*vector)[slot] = record; -/* V4_MUTEX_UNLOCK (&relation->rel_mutex); */ return record; } @@ -4624,8 +4618,6 @@ static Record* replace_gc_record(jrd_rel* relation, Record** gc_record, USHORT l * **************************************/ -/* V4_MUTEX_LOCK (&relation->rel_mutex); */ - vec* vector = relation->rel_gc_rec; vec::iterator rec_ptr, end; for (rec_ptr = vector->begin(), end = vector->end(); rec_ptr < end; @@ -4635,12 +4627,10 @@ static Record* replace_gc_record(jrd_rel* relation, Record** gc_record, USHORT l // 26 Sep 2002, SKIDDER: Failure to do so (*gc_record = ...) causes nasty memory corruption in // some cases. *gc_record = realloc_record(*rec_ptr, length); -/* V4_MUTEX_UNLOCK (&relation->rel_mutex); */ return *rec_ptr; } } -/* V4_MUTEX_UNLOCK (&relation->rel_mutex); */ BUGCHECK(288); /* msg 288 garbage collect record disappeared */ return NULL; /* Added to remove compiler warnings */ }