summaryrefslogtreecommitdiffstats
path: root/source/cSemaphore.cpp
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-02-01 14:43:47 +0100
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-02-01 14:43:47 +0100
commit2568bad3cc1ae70350f5ad31e97b4c13194e437e (patch)
tree31d0713dfe1b4e42c1f17ddae8ea0114c420fc61 /source/cSemaphore.cpp
parentRemoved a few duplicate includes (diff)
downloadcuberite-2568bad3cc1ae70350f5ad31e97b4c13194e437e.tar
cuberite-2568bad3cc1ae70350f5ad31e97b4c13194e437e.tar.gz
cuberite-2568bad3cc1ae70350f5ad31e97b4c13194e437e.tar.bz2
cuberite-2568bad3cc1ae70350f5ad31e97b4c13194e437e.tar.lz
cuberite-2568bad3cc1ae70350f5ad31e97b4c13194e437e.tar.xz
cuberite-2568bad3cc1ae70350f5ad31e97b4c13194e437e.tar.zst
cuberite-2568bad3cc1ae70350f5ad31e97b4c13194e437e.zip
Diffstat (limited to 'source/cSemaphore.cpp')
-rw-r--r--source/cSemaphore.cpp46
1 files changed, 23 insertions, 23 deletions
diff --git a/source/cSemaphore.cpp b/source/cSemaphore.cpp
index 3bc83f393..438b83e2c 100644
--- a/source/cSemaphore.cpp
+++ b/source/cSemaphore.cpp
@@ -7,33 +7,33 @@
cSemaphore::cSemaphore( unsigned int a_MaxCount, unsigned int a_InitialCount /* = 0 */ )
#ifndef _WIN32
- : m_bNamed( false )
+ : m_bNamed( false )
#endif
{
#ifndef _WIN32
- (void)a_MaxCount;
- m_Handle = new sem_t;
- if( sem_init( (sem_t*)m_Handle, 0, 0 ) )
- {
- LOG("WARNING cSemaphore: Could not create unnamed semaphore, fallback to named.");
- delete (sem_t*)m_Handle; // named semaphores return their own address
- m_bNamed = true;
+ (void)a_MaxCount;
+ m_Handle = new sem_t;
+ if (sem_init( (sem_t*)m_Handle, 0, 0))
+ {
+ LOG("WARNING cSemaphore: Could not create unnamed semaphore, fallback to named.");
+ delete (sem_t*)m_Handle; // named semaphores return their own address
+ m_bNamed = true;
- char c_Str[32];
- sprintf( c_Str, "cSemaphore%p", this );
- m_Handle = sem_open( c_Str, O_CREAT, 777, a_InitialCount );
- if( m_Handle == SEM_FAILED )
- {
- LOG("ERROR: Could not create Semaphore. (%i)", errno );
- }
- else
- {
- if( sem_unlink( c_Str ) != 0 )
- {
- LOG("ERROR: Could not unlink cSemaphore. (%i)", errno);
- }
- }
- }
+ AString Name;
+ Printf(Name, "cSemaphore%p", this );
+ m_Handle = sem_open(Name.c_str(), O_CREAT, 777, a_InitialCount);
+ if( m_Handle == SEM_FAILED )
+ {
+ LOG("ERROR: Could not create Semaphore. (%i)", errno );
+ }
+ else
+ {
+ if( sem_unlink( c_Str ) != 0 )
+ {
+ LOG("ERROR: Could not unlink cSemaphore. (%i)", errno);
+ }
+ }
+ }
#else
m_Handle = CreateSemaphore(
NULL, // security attribute