trunk: backport eventing from 1.4.3

This commit is contained in:
Marian Krivos
2012-02-05 12:16:58 +00:00
parent 59fe68edbe
commit 7d7c02c579
412 changed files with 3564 additions and 3634 deletions

View File

@@ -1,7 +1,7 @@
//
// NamedMutex_UNIX.cpp
//
// $Id: //poco/svn/Foundation/src/NamedMutex_UNIX.cpp#2 $
// $Id: //poco/1.4/Foundation/src/NamedMutex_UNIX.cpp#1 $
//
// Library: Foundation
// Package: Processes
@@ -57,13 +57,13 @@ namespace Poco {
{
int val;
struct semid_ds* buf;
unsigned short int* array;
struct seminfo* __buf;
};
unsigned short int* array;
struct seminfo* __buf;
};
#elif defined(__hpux)
union semun
{
int val;
union semun
{
int val;
struct semid_ds* buf;
ushort* array;
};
@@ -71,13 +71,13 @@ namespace Poco {
NamedMutexImpl::NamedMutexImpl(const std::string& name):
_name(name)
_name(name)
{
std::string fileName = getFileName();
std::string fileName = getFileName();
#if defined(sun) || defined(__APPLE__) || defined(__osf__) || defined(__QNX__) || defined(_AIX)
_sem = sem_open(fileName.c_str(), O_CREAT, S_IRWXU | S_IRWXG | S_IRWXO, 1);
if ((long) _sem == (long) SEM_FAILED)
throw SystemException("cannot create named mutex (sem_open() failed)", _name);
_sem = sem_open(fileName.c_str(), O_CREAT, S_IRWXU | S_IRWXG | S_IRWXO, 1);
if ((long) _sem == (long) SEM_FAILED)
throw SystemException("cannot create named mutex (sem_open() failed)", _name);
#else
int fd = open(fileName.c_str(), O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
if (fd != -1)
@@ -96,9 +96,9 @@ NamedMutexImpl::NamedMutexImpl(const std::string& name):
}
else if (errno == EEXIST)
{
_semid = semget(key, 1, 0);
}
else throw SystemException("cannot create named mutex (semget() failed)", _name);
_semid = semget(key, 1, 0);
}
else throw SystemException("cannot create named mutex (semget() failed)", _name);
#endif // defined(sun) || defined(__APPLE__) || defined(__osf__) || defined(__QNX__) || defined(_AIX)
}
@@ -106,7 +106,7 @@ NamedMutexImpl::NamedMutexImpl(const std::string& name):
NamedMutexImpl::~NamedMutexImpl()
{
#if defined(sun) || defined(__APPLE__) || defined(__osf__) || defined(__QNX__) || defined(_AIX)
sem_close(_sem);
sem_close(_sem);
#endif
}
@@ -114,9 +114,9 @@ NamedMutexImpl::~NamedMutexImpl()
void NamedMutexImpl::lockImpl()
{
#if defined(sun) || defined(__APPLE__) || defined(__osf__) || defined(__QNX__) || defined(_AIX)
int err;
do
{
int err;
do
{
err = sem_wait(_sem);
}
while (err && errno == EINTR);
@@ -140,9 +140,9 @@ void NamedMutexImpl::lockImpl()
bool NamedMutexImpl::tryLockImpl()
{
#if defined(sun) || defined(__APPLE__) || defined(__osf__) || defined(__QNX__) || defined(_AIX)
return sem_trywait(_sem) == 0;
return sem_trywait(_sem) == 0;
#else
struct sembuf op;
struct sembuf op;
op.sem_num = 0;
op.sem_op = -1;
op.sem_flg = SEM_UNDO | IPC_NOWAIT;
@@ -154,8 +154,8 @@ bool NamedMutexImpl::tryLockImpl()
void NamedMutexImpl::unlockImpl()
{
#if defined(sun) || defined(__APPLE__) || defined(__osf__) || defined(__QNX__) || defined(_AIX)
if (sem_post(_sem) != 0)
throw SystemException("cannot unlock named mutex", _name);
if (sem_post(_sem) != 0)
throw SystemException("cannot unlock named mutex", _name);
#else
struct sembuf op;
op.sem_num = 0;