From f84bcf97a8e2c289db2c4e0be7149cb79c704786 Mon Sep 17 00:00:00 2001 From: Javi Morales Date: Wed, 4 Apr 2018 13:12:51 +0200 Subject: [PATCH] Fix return code check for Semaphore operations #47 (#48) * Fix take and give semaphore operations in RTI Perftest #47 * Add CR changes * CR Changes and documentation --- srcCpp/RTIDDSImpl.cxx | 47 ++++++++++++++++++++-------------------- srcDoc/release_notes.rst | 7 ++++++ 2 files changed, 30 insertions(+), 24 deletions(-) diff --git a/srcCpp/RTIDDSImpl.cxx b/srcCpp/RTIDDSImpl.cxx index cbce27ba..127a5b3b 100644 --- a/srcCpp/RTIDDSImpl.cxx +++ b/srcCpp/RTIDDSImpl.cxx @@ -99,8 +99,8 @@ void RTIDDSImpl::Shutdown() } if(_pongSemaphore != NULL) { - RTIOsapiSemaphore_delete(_pongSemaphore); - _pongSemaphore = NULL; + RTIOsapiSemaphore_delete(_pongSemaphore); + _pongSemaphore = NULL; } DDSDomainParticipantFactory::finalize_instance(); @@ -885,13 +885,11 @@ class RTIPublisher : public IMessagingWriter } } - bool waitForPingResponse() - { - if(_pongSemaphore != NULL) - { - if(!RTIOsapiSemaphore_take(_pongSemaphore, NULL)) - { - fprintf(stderr,"Unexpected error taking semaphore\n"); + bool waitForPingResponse() { + if(_pongSemaphore != NULL) { + if(RTIOsapiSemaphore_take(_pongSemaphore, NULL) + == RTI_OSAPI_SEMAPHORE_STATUS_ERROR) { + fprintf(stderr, "Unexpected error taking semaphore\n"); return false; } } @@ -899,28 +897,26 @@ class RTIPublisher : public IMessagingWriter } /* time out in milliseconds */ - bool waitForPingResponse(int timeout) + bool waitForPingResponse(int timeout) { struct RTINtpTime blockDurationIn; RTINtpTime_packFromMillisec(blockDurationIn, 0, timeout); - if(_pongSemaphore != NULL) - { - if(!RTIOsapiSemaphore_take(_pongSemaphore, &blockDurationIn)) - { - fprintf(stderr,"Unexpected error taking semaphore\n"); + if(_pongSemaphore != NULL) { + if (RTIOsapiSemaphore_take(_pongSemaphore, &blockDurationIn) + == RTI_OSAPI_SEMAPHORE_STATUS_ERROR) { + fprintf(stderr, "Unexpected error taking semaphore\n"); return false; } } return true; - } + } - bool notifyPingResponse() + bool notifyPingResponse() { - if(_pongSemaphore != NULL) - { - if(!RTIOsapiSemaphore_give(_pongSemaphore)) - { + if(_pongSemaphore != NULL) { + if(RTIOsapiSemaphore_give(_pongSemaphore) + != RTI_OSAPI_SEMAPHORE_STATUS_OK) { fprintf(stderr,"Unexpected error giving semaphore\n"); return false; } @@ -1134,7 +1130,8 @@ class RTIDynamicDataPublisher : public IMessagingWriter bool waitForPingResponse() { if (_pongSemaphore != NULL) { - if (!RTIOsapiSemaphore_take(_pongSemaphore, NULL)) { + if (RTIOsapiSemaphore_take(_pongSemaphore, NULL) + == RTI_OSAPI_SEMAPHORE_STATUS_ERROR) { fprintf(stderr, "Unexpected error taking semaphore\n"); return false; } @@ -1148,7 +1145,8 @@ class RTIDynamicDataPublisher : public IMessagingWriter RTINtpTime_packFromMillisec(blockDuration, 0, timeout); if (_pongSemaphore != NULL) { - if (!RTIOsapiSemaphore_take(_pongSemaphore, &blockDuration)) { + if (RTIOsapiSemaphore_take(_pongSemaphore, &blockDuration) + == RTI_OSAPI_SEMAPHORE_STATUS_ERROR) { fprintf(stderr, "Unexpected error taking semaphore\n"); return false; } @@ -1158,7 +1156,8 @@ class RTIDynamicDataPublisher : public IMessagingWriter bool notifyPingResponse() { if (_pongSemaphore != NULL) { - if (!RTIOsapiSemaphore_give(_pongSemaphore)) { + if (RTIOsapiSemaphore_give(_pongSemaphore) + != RTI_OSAPI_SEMAPHORE_STATUS_OK) { fprintf(stderr, "Unexpected error giving semaphore\n"); return false; } diff --git a/srcDoc/release_notes.rst b/srcDoc/release_notes.rst index 47b1fb18..bec88c28 100644 --- a/srcDoc/release_notes.rst +++ b/srcDoc/release_notes.rst @@ -51,6 +51,13 @@ Release Notes 2.3.2 What's Fixed in 2.3.2 ~~~~~~~~~~~~~~~~~~~~~~ +Classic C++ Semaphore Take() and Give() operations not checking for errors properly (#47) +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +In previous versions, the semaphore Take() and Give() operations +were not being checked for error in a correct way in the Classic C++ API implementation. +This has been fixed. + Update Security Certificates and Governance files (#49) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^