mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-24 06:43:03 +01:00
Misc
This commit is contained in:
parent
31c8cd9ffc
commit
702ea9585e
@ -91,7 +91,8 @@ private:
|
|||||||
sem_t sem;
|
sem_t sem;
|
||||||
bool init;
|
bool init;
|
||||||
public:
|
public:
|
||||||
SignalSafeSemaphore() : init(false)
|
SignalSafeSemaphore()
|
||||||
|
: init(false)
|
||||||
{
|
{
|
||||||
if (sem_init(&sem, 0, 0) == -1) {
|
if (sem_init(&sem, 0, 0) == -1) {
|
||||||
//gds__log("Error on semaphore.h: constructor");
|
//gds__log("Error on semaphore.h: constructor");
|
||||||
@ -214,7 +215,8 @@ private:
|
|||||||
unsigned short* array;
|
unsigned short* array;
|
||||||
};
|
};
|
||||||
public:
|
public:
|
||||||
Semaphore() : semId(semget(IPC_PRIVATE, 1, 0600))
|
Semaphore()
|
||||||
|
: semId(semget(IPC_PRIVATE, 1, 0600))
|
||||||
{
|
{
|
||||||
if (semId < 0)
|
if (semId < 0)
|
||||||
system_call_failed::raise("semaphore.h: Semaphore: semget()");
|
system_call_failed::raise("semaphore.h: Semaphore: semget()");
|
||||||
@ -255,7 +257,8 @@ public:
|
|||||||
|
|
||||||
while (semtimedop(semId, &sb, 1, t) < 0)
|
while (semtimedop(semId, &sb, 1, t) < 0)
|
||||||
{
|
{
|
||||||
switch (errno) {
|
switch (errno)
|
||||||
|
{
|
||||||
case EAGAIN:
|
case EAGAIN:
|
||||||
return false;
|
return false;
|
||||||
case EINTR:
|
case EINTR:
|
||||||
@ -306,7 +309,8 @@ private:
|
|||||||
pthread_cond_t cv;
|
pthread_cond_t cv;
|
||||||
bool init;
|
bool init;
|
||||||
public:
|
public:
|
||||||
Semaphore() : init(false)
|
Semaphore()
|
||||||
|
: init(false)
|
||||||
{
|
{
|
||||||
int err = pthread_mutex_init(&mu, NULL);
|
int err = pthread_mutex_init(&mu, NULL);
|
||||||
if (err != 0) {
|
if (err != 0) {
|
||||||
@ -371,6 +375,7 @@ public:
|
|||||||
|
|
||||||
system_call_failed::raise("pthread_mutex_trylock", err2);
|
system_call_failed::raise("pthread_mutex_trylock", err2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (seconds < 0)
|
if (seconds < 0)
|
||||||
{
|
{
|
||||||
// Unlimited wait, like enter()
|
// Unlimited wait, like enter()
|
||||||
@ -395,7 +400,6 @@ public:
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
system_call_failed::raise("pthread_mutex_lock", err2);
|
system_call_failed::raise("pthread_mutex_lock", err2);
|
||||||
|
|
||||||
} //seconds < 0
|
} //seconds < 0
|
||||||
|
|
||||||
// Wait with timeout
|
// Wait with timeout
|
||||||
|
Loading…
Reference in New Issue
Block a user