diff options
author | XVSALGE <aleksandar.gerasimovski@seavus.com> | 2012-02-22 08:14:11 +0100 |
---|---|---|
committer | Viktor Mladenovski <viktor.mladenovski@seavus.com> | 2012-05-25 14:44:00 +0200 |
commit | 9dc2897fef041426347e80385707b7c86324c63e (patch) | |
tree | b7525770a2da28553426465f47a6d65efaa22c3b /source/api_wrappers/linux/CSemaphore.cpp | |
parent | 828be7d08c886347641d8bba675993caf5a13d1a (diff) |
Sync lcm with CC source
Synchronize loader_communication with clearcase source
ST-Ericsson ID: 413947
ST-Ericsson FOSS-OUT ID: STETL-FOSS-OUT-10204
Change-Id: Ib23b84360b351a2598190d9d6b510895cc892436
Depends-On: I4b049943fc2acc63ed5f94dff6d4bc0e36fde1cf
Reviewed-on: http://gerrit.lud.stericsson.com/gerrit/48934
Reviewed-by: QABUILD
Reviewed-by: QATEST
Reviewed-by: Zoran ANCEVSKI <zoran.ancevski@seavus.com>
Tested-by: Aleksandar GASOSKI <aleksandar.gasoski@seavus.com>
Tested-by: Cvetko MLADENOVSKI <cvetko.mladenovski@seavus.com>
Reviewed-by: Vlatko PISTOLOV <vlatko.pistolov@seavus.com>
Tested-by: Vlatko PISTOLOV <vlatko.pistolov@seavus.com>
Diffstat (limited to 'source/api_wrappers/linux/CSemaphore.cpp')
-rw-r--r-- | source/api_wrappers/linux/CSemaphore.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/source/api_wrappers/linux/CSemaphore.cpp b/source/api_wrappers/linux/CSemaphore.cpp index 5dae856..166ab88 100644 --- a/source/api_wrappers/linux/CSemaphore.cpp +++ b/source/api_wrappers/linux/CSemaphore.cpp @@ -16,13 +16,17 @@ CSemaphore::CSemaphore(unsigned int initial_count) { char sem_name[SEM_NAME_MAX_LENGTH]; int sem_nr = 1; - while(sem_nr <= SEM_MAX_NR) { + + while (sem_nr <= SEM_MAX_NR) { snprintf(sem_name, SEM_NAME_MAX_LENGTH, "lcdriversem_%d", sem_nr); /* open semaphore with "rw" permissions for everyone - 0666 */ m_semaphore = sem_open(sem_name, O_CREAT | O_EXCL, 0666 , 0); - if (m_semaphore != SEM_FAILED) + + if (m_semaphore != SEM_FAILED) { break; + } + sem_nr++; } } @@ -60,6 +64,7 @@ DWORD CSemaphore::Wait(DWORD timeout) /* Try to lock the semaphore */ ret = sem_trywait(m_semaphore); + if (ret != 0) { while (dwTimePassed < timeout) { /* Sleep 1ms */ @@ -67,6 +72,7 @@ DWORD CSemaphore::Wait(DWORD timeout) /* Try to lock the semaphore again*/ ret = sem_trywait(m_semaphore); + if (ret == 0) { return WAIT_OBJECT_0; } |