Fix semaphore segfault when tryWait'ing on invalid semaphore.
This commit is contained in:
parent
108499bc58
commit
422c839ae2
1 changed files with 2 additions and 0 deletions
|
@ -222,6 +222,7 @@ namespace IPC {
|
||||||
|
|
||||||
///\brief Tries to wait for the semaphore, returns true if successful, false otherwise
|
///\brief Tries to wait for the semaphore, returns true if successful, false otherwise
|
||||||
bool semaphore::tryWait() {
|
bool semaphore::tryWait() {
|
||||||
|
if (!(*this)){return false;}
|
||||||
int result;
|
int result;
|
||||||
#if defined(__CYGWIN__) || defined(_WIN32)
|
#if defined(__CYGWIN__) || defined(_WIN32)
|
||||||
result = WaitForSingleObject(mySem, 0);//wait at most 1ms
|
result = WaitForSingleObject(mySem, 0);//wait at most 1ms
|
||||||
|
@ -237,6 +238,7 @@ namespace IPC {
|
||||||
|
|
||||||
///\brief Tries to wait for the semaphore for a single second, returns true if successful, false otherwise
|
///\brief Tries to wait for the semaphore for a single second, returns true if successful, false otherwise
|
||||||
bool semaphore::tryWaitOneSecond() {
|
bool semaphore::tryWaitOneSecond() {
|
||||||
|
if (!(*this)){return false;}
|
||||||
int result;
|
int result;
|
||||||
#if defined(__CYGWIN__) || defined(_WIN32)
|
#if defined(__CYGWIN__) || defined(_WIN32)
|
||||||
result = WaitForSingleObject(mySem, 1000);//wait at most 1s
|
result = WaitForSingleObject(mySem, 1000);//wait at most 1s
|
||||||
|
|
Loading…
Add table
Reference in a new issue