Skip to content

Commit

Permalink
1. Cleanup - use Firebird::Semaphore instead of local events, removed…
Browse files Browse the repository at this point in the history
… code

related with local events from isc_sync.cpp.

2. Cleanup - removed unused parameter 'number of events' from ISC_event_wait()
and two unused parameters from ISC_event_init().

3. Added SYSV-semaphore based implementation of IPC to isc_sync.cpp.
This should fix CORE-2102: Firebird 2.5 does not build on MacOS (Darwin).

4. Fixed use of posic CS without (x)inetd (i.e. fb_inet_server -s).

5. Fixed (to be reviewed by Dmitry) recovery after some process death in lock manager.
  • Loading branch information
AlexPeshkoff committed Oct 10, 2008
1 parent 38a8b41 commit e79f557
Show file tree
Hide file tree
Showing 30 changed files with 1,485 additions and 688 deletions.
4 changes: 2 additions & 2 deletions builds/posix/make.shared.variables
Expand Up @@ -16,7 +16,7 @@ WHY_Sources = why.cpp

JRD_ClientFiles = alt.cpp db_alias.cpp dsc.cpp \
enc.cpp gds.cpp isc.cpp isc_file.cpp isc_ipc.cpp \
isc_sync.cpp perf.cpp sdl.cpp status.cpp \
perf.cpp sdl.cpp status.cpp \
ThreadData.cpp ThreadStart.cpp utl.cpp \
$(WHY_Sources)

Expand All @@ -33,7 +33,7 @@ JRD_ServerFiles= blob_filter.cpp cvt.cpp dpm.epp dyn.epp dyn_def.epp \
err.cpp event.cpp evl.cpp exe.cpp ext.cpp \
execute_statement.cpp filters.cpp flu.cpp functions.cpp \
idx.cpp inf.cpp intl.cpp intl_builtin.cpp IntlManager.cpp \
IntlUtil.cpp \
IntlUtil.cpp isc_sync.cpp \
jrd.cpp Database.cpp lck.cpp \
mov.cpp nav.cpp opt.cpp Optimizer.cpp pag.cpp par.cpp \
ods.cpp plugin_manager.cpp pwd.cpp PreparedStatement.cpp RandomGenerator.cpp \
Expand Down
20 changes: 19 additions & 1 deletion src/common/classes/vector.h
Expand Up @@ -47,43 +47,49 @@ class Vector
fb_assert(index < count);
return data[index];
}

const T& operator[](size_t index) const
{
fb_assert(index < count);
return data[index];
}

T* begin() { return data; }
T* end() { return data + count; }
const T* begin() const { return data; }
const T* end() const { return data + count; }
size_t getCount() const { return count; }
size_t getCapacity() const { return Capacity; }

void clear() { count = 0; }

void insert(size_t index, const T& item)
{
fb_assert(index <= count);
fb_assert(count < Capacity);
memmove(data + index + 1, data + index, sizeof(T) * (count++ - index));
data[index] = item;
}

size_t add(const T& item)
{
fb_assert(count < Capacity);
data[count] = item;
return ++count;
}

T* remove(size_t index)
{
fb_assert(index < count);
memmove(data + index, data + index + 1, sizeof(T) * (--count - index));
return &data[index];
}

void shrink(size_t newCount)
{
fb_assert(newCount <= count);
count = newCount;
}

void join(const Vector<T, Capacity>& L)
{
fb_assert(count + L.count <= Capacity);
Expand All @@ -99,6 +105,18 @@ class Vector
return data;
}

void push(const T& item)
{
add(item);
}

T pop()
{
fb_assert(count > 0);
count--;
return data[count];
}

protected:
size_t count;
T data[Capacity];
Expand Down
4 changes: 1 addition & 3 deletions src/jrd/Database.cpp
Expand Up @@ -29,13 +29,11 @@
#include "../jrd/common.h"
#include "../jrd/ods.h"
#include "../jrd/Database.h"
#include "../jrd/isc.h"
#include "../jrd/tra.h"
#include "../jrd/os/pio_proto.h"

// Thread data block / IPC related data blocks
// Thread data block
#include "../jrd/ThreadData.h"
#include "../jrd/isc.h"

// recursive mutexes
#include "../common/thd.h"
Expand Down
18 changes: 11 additions & 7 deletions src/jrd/Database.h
Expand Up @@ -55,6 +55,7 @@
#include "../common/classes/GenericMap.h"
#include "../common/classes/RefCounted.h"
#include "../common/classes/PublicHandle.h"
#include "../common/classes/semaphore.h"
#include "../jrd/RandomGenerator.h"
#include "../jrd/os/guid.h"
#include "../jrd/sbm.h"
Expand Down Expand Up @@ -398,17 +399,20 @@ class Database : public pool_alloc<type_dbb>, public Firebird::PublicHandle
SLONG dbb_page_incarnation; // Cache page incarnation counter
ULONG dbb_page_buffers; // Page buffers from header page

event_t dbb_writer_event[1]; // Event to wake up cache writer
event_t dbb_writer_event_init[1]; // Event for initialization cache writer
event_t dbb_writer_event_fini[1]; // Event for finalization cache writer
Firebird::Semaphore dbb_writer_sem; // Wwake up cache writer
Firebird::Semaphore dbb_writer_init;// Cache writer initialization
Firebird::Semaphore dbb_writer_fini;// Cache writer finalization
#ifdef SUPERSERVER_V2
event_t dbb_reader_event[1]; // Event to wake up cache reader
// the code in cch.cpp is not tested for semaphore instead event !!!
Firebird::Semaphore dbb_reader_sem; // Wake up cache reader
Firebird::Semaphore dbb_reader_init;// Cache reader initialization
Firebird::Semaphore dbb_reader_fini;// Cache reader finalization
#endif

#ifdef GARBAGE_THREAD
event_t dbb_gc_event[1]; // Event to wake up garbage collector
event_t dbb_gc_event_init[1]; // Event for initialization garbage collector
event_t dbb_gc_event_fini[1]; // Event for finalization garbage collector
Firebird::Semaphore dbb_gc_sem; // Event to wake up garbage collector
Firebird::Semaphore dbb_gc_init; // Event for initialization garbage collector
Firebird::Semaphore dbb_gc_fini; // Event for finalization garbage collector
#endif

Firebird::MemoryStats dbb_memory_stats;
Expand Down
4 changes: 2 additions & 2 deletions src/jrd/DatabaseSnapshot.h
Expand Up @@ -48,7 +48,7 @@ class DatabaseSnapshot
size_t used;
size_t allocated;
#ifndef WIN_NT
MTX_T mutex;
struct mtx mutex;
#endif
};

Expand All @@ -75,7 +75,7 @@ class DatabaseSnapshot

SH_MEM_T handle;
#ifdef WIN_NT
MTX_T mutex;
struct mtx mutex;
#endif
Header* base;
};
Expand Down
1 change: 0 additions & 1 deletion src/jrd/GlobalRWLock.h
Expand Up @@ -31,7 +31,6 @@
#include "../jrd/lck.h"
#include "../jrd/lck_proto.h"
#include "../include/fb_types.h"
#include "../jrd/isc.h"
#include "os/pio.h"

//#define COS_DEBUG
Expand Down
1 change: 0 additions & 1 deletion src/jrd/ThreadData.cpp
Expand Up @@ -32,7 +32,6 @@
#include <errno.h>
#include "../jrd/common.h"
#include "../jrd/ThreadData.h"
#include "../jrd/isc.h"
#include "../jrd/gds_proto.h"
#include "../jrd/isc_s_proto.h"
#include "../jrd/gdsassert.h"
Expand Down
1 change: 0 additions & 1 deletion src/jrd/ThreadData.h
Expand Up @@ -31,7 +31,6 @@
#define JRD_THREADDATA_H

#include "firebird.h"
//#include "../jrd/isc.h"
#include "../common/classes/locks.h"
#include "../common/classes/rwlock.h"
#include "../common/classes/alloc.h"
Expand Down
1 change: 0 additions & 1 deletion src/jrd/ThreadStart.cpp
Expand Up @@ -32,7 +32,6 @@
#include <errno.h>
#include "../jrd/common.h"
#include "../jrd/ThreadStart.h"
#include "../jrd/isc.h"
#include "../jrd/os/thd_priority.h"
#include "../jrd/gds_proto.h"
#include "../jrd/isc_s_proto.h"
Expand Down

0 comments on commit e79f557

Please sign in to comment.