Merge pull request 'Hotfixes for Renaming Update' (#384) from mueller/mutex-fixes into development
Reviewed-on: fsfw/fsfw#384
This commit is contained in:
commit
d62dea442d
@ -1,5 +1,5 @@
|
|||||||
#ifndef FRAMEWORK_IPC_MUTEXHELPER_H_
|
#ifndef FRAMEWORK_IPC_MUTEXGUARD_H_
|
||||||
#define FRAMEWORK_IPC_MUTEXHELPER_H_
|
#define FRAMEWORK_IPC_MUTEXGUARD_H_
|
||||||
|
|
||||||
#include "MutexFactory.h"
|
#include "MutexFactory.h"
|
||||||
#include "../serviceinterface/ServiceInterface.h"
|
#include "../serviceinterface/ServiceInterface.h"
|
||||||
@ -12,9 +12,9 @@ public:
|
|||||||
if(mutex == nullptr) {
|
if(mutex == nullptr) {
|
||||||
#if FSFW_VERBOSE_LEVEL >= 1
|
#if FSFW_VERBOSE_LEVEL >= 1
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
sif::error << "MutexHelper: Passed mutex is invalid!" << std::endl;
|
sif::error << "MutexGuard: Passed mutex is invalid!" << std::endl;
|
||||||
#else
|
#else
|
||||||
sif::printError("MutexHelper: Passed mutex is invalid!\n");
|
sif::printError("MutexGuard: Passed mutex is invalid!\n");
|
||||||
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
|
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
|
||||||
#endif /* FSFW_VERBOSE_LEVEL >= 1 */
|
#endif /* FSFW_VERBOSE_LEVEL >= 1 */
|
||||||
return;
|
return;
|
||||||
@ -24,24 +24,22 @@ public:
|
|||||||
#if FSFW_VERBOSE_LEVEL >= 1
|
#if FSFW_VERBOSE_LEVEL >= 1
|
||||||
if(result == MutexIF::MUTEX_TIMEOUT) {
|
if(result == MutexIF::MUTEX_TIMEOUT) {
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
sif::error << "MutexHelper: Lock of mutex failed with timeout of "
|
sif::error << "MutexGuard: Lock of mutex failed with timeout of "
|
||||||
<< timeoutMs << " milliseconds!" << std::endl;
|
<< timeoutMs << " milliseconds!" << std::endl;
|
||||||
#else
|
#else
|
||||||
sif::printError("MutexHelper: Lock of mutex failed with timeout of %lu milliseconds\n",
|
sif::printError("MutexGuard: Lock of mutex failed with timeout of %lu milliseconds\n",
|
||||||
timeoutMs);
|
timeoutMs);
|
||||||
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
|
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(result != HasReturnvaluesIF::RETURN_OK) {
|
else if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
sif::error << "MutexHelper: Lock of Mutex failed with code " << result << std::endl;
|
sif::error << "MutexGuard: Lock of Mutex failed with code " << result << std::endl;
|
||||||
#else
|
#else
|
||||||
sif::printError("MutexHelper: Lock of Mutex failed with code %d\n", result);
|
sif::printError("MutexGuard: Lock of Mutex failed with code %d\n", result);
|
||||||
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
|
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
/* To avoid unused variable warning */
|
|
||||||
static_cast<void>(status);
|
|
||||||
#endif /* FSFW_VERBOSE_LEVEL >= 1 */
|
#endif /* FSFW_VERBOSE_LEVEL >= 1 */
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,4 +57,4 @@ private:
|
|||||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_FAILED;
|
ReturnValue_t result = HasReturnvaluesIF::RETURN_FAILED;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* FRAMEWORK_IPC_MUTEXHELPER_H_ */
|
#endif /* FRAMEWORK_IPC_MUTEXGUARD_H_ */
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
#include "../../serviceinterface/ServiceInterfaceStream.h"
|
#include "../../serviceinterface/ServiceInterfaceStream.h"
|
||||||
#include "../../ipc/MutexFactory.h"
|
#include "../../ipc/MutexFactory.h"
|
||||||
#include "../../ipc/MutexHelper.h"
|
#include "../../ipc/MutexGuard.h"
|
||||||
|
|
||||||
MessageQueue::MessageQueue(size_t messageDepth, size_t maxMessageSize):
|
MessageQueue::MessageQueue(size_t messageDepth, size_t maxMessageSize):
|
||||||
messageSize(maxMessageSize), messageDepth(messageDepth) {
|
messageSize(maxMessageSize), messageDepth(messageDepth) {
|
||||||
@ -65,7 +65,7 @@ ReturnValue_t MessageQueue::receiveMessage(MessageQueueMessageIF* message) {
|
|||||||
}
|
}
|
||||||
// not sure this will work..
|
// not sure this will work..
|
||||||
//*message = std::move(messageQueue.front());
|
//*message = std::move(messageQueue.front());
|
||||||
MutexHelper mutexLock(queueLock, MutexIF::TimeoutType::WAITING, 20);
|
MutexGuard mutexLock(queueLock, MutexIF::TimeoutType::WAITING, 20);
|
||||||
MessageQueueMessage* currentMessage = &messageQueue.front();
|
MessageQueueMessage* currentMessage = &messageQueue.front();
|
||||||
std::copy(currentMessage->getBuffer(),
|
std::copy(currentMessage->getBuffer(),
|
||||||
currentMessage->getBuffer() + messageSize, message->getBuffer());
|
currentMessage->getBuffer() + messageSize, message->getBuffer());
|
||||||
@ -130,7 +130,7 @@ ReturnValue_t MessageQueue::sendMessageFromMessageQueue(MessageQueueId_t sendTo,
|
|||||||
return HasReturnvaluesIF::RETURN_FAILED;
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
}
|
}
|
||||||
if(targetQueue->messageQueue.size() < targetQueue->messageDepth) {
|
if(targetQueue->messageQueue.size() < targetQueue->messageDepth) {
|
||||||
MutexHelper mutexLock(targetQueue->queueLock,
|
MutexGuard mutexLock(targetQueue->queueLock,
|
||||||
MutexIF::TimeoutType::WAITING, 20);
|
MutexIF::TimeoutType::WAITING, 20);
|
||||||
// not ideal, works for now though.
|
// not ideal, works for now though.
|
||||||
MessageQueueMessage* mqmMessage =
|
MessageQueueMessage* mqmMessage =
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#include "../../serviceinterface/ServiceInterface.h"
|
#include "../../serviceinterface/ServiceInterface.h"
|
||||||
#include "../../ipc/MutexFactory.h"
|
#include "../../ipc/MutexFactory.h"
|
||||||
#include "../../ipc/MutexHelper.h"
|
#include "../../ipc/MutexGuard.h"
|
||||||
|
|
||||||
QueueMapManager* QueueMapManager::mqManagerInstance = nullptr;
|
QueueMapManager* QueueMapManager::mqManagerInstance = nullptr;
|
||||||
|
|
||||||
@ -43,7 +43,7 @@ ReturnValue_t QueueMapManager::addMessageQueue(
|
|||||||
|
|
||||||
MessageQueueIF* QueueMapManager::getMessageQueue(
|
MessageQueueIF* QueueMapManager::getMessageQueue(
|
||||||
MessageQueueId_t messageQueueId) const {
|
MessageQueueId_t messageQueueId) const {
|
||||||
MutexHelper(mapLock, MutexIF::TimeoutType::WAITING, 50);
|
MutexGuard(mapLock, MutexIF::TimeoutType::WAITING, 50);
|
||||||
auto queueIter = queueMap.find(messageQueueId);
|
auto queueIter = queueMap.find(messageQueueId);
|
||||||
if(queueIter != queueMap.end()) {
|
if(queueIter != queueMap.end()) {
|
||||||
return queueIter->second;
|
return queueIter->second;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include "TmTcUnixUdpBridge.h"
|
#include "TmTcUnixUdpBridge.h"
|
||||||
#include "../../serviceinterface/ServiceInterface.h"
|
#include "../../serviceinterface/ServiceInterface.h"
|
||||||
#include "../../ipc/MutexHelper.h"
|
#include "../../ipc/MutexGuard.h"
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
@ -69,7 +69,7 @@ TmTcUnixUdpBridge::~TmTcUnixUdpBridge() {
|
|||||||
ReturnValue_t TmTcUnixUdpBridge::sendTm(const uint8_t *data, size_t dataLen) {
|
ReturnValue_t TmTcUnixUdpBridge::sendTm(const uint8_t *data, size_t dataLen) {
|
||||||
int flags = 0;
|
int flags = 0;
|
||||||
|
|
||||||
MutexHelper lock(mutex, MutexIF::TimeoutType::WAITING, 10);
|
MutexGuard lock(mutex, MutexIF::TimeoutType::WAITING, 10);
|
||||||
|
|
||||||
if(ipAddrAnySet){
|
if(ipAddrAnySet){
|
||||||
clientAddress.sin_addr.s_addr = htons(INADDR_ANY);
|
clientAddress.sin_addr.s_addr = htons(INADDR_ANY);
|
||||||
@ -100,7 +100,7 @@ ReturnValue_t TmTcUnixUdpBridge::sendTm(const uint8_t *data, size_t dataLen) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void TmTcUnixUdpBridge::checkAndSetClientAddress(sockaddr_in& newAddress) {
|
void TmTcUnixUdpBridge::checkAndSetClientAddress(sockaddr_in& newAddress) {
|
||||||
MutexHelper lock(mutex, MutexIF::TimeoutType::WAITING, 10);
|
MutexGuard lock(mutex, MutexIF::TimeoutType::WAITING, 10);
|
||||||
|
|
||||||
// char ipAddress [15];
|
// char ipAddress [15];
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#include "RtemsBasic.h"
|
#include "RtemsBasic.h"
|
||||||
|
|
||||||
#include "../../timemanager/Clock.h"
|
#include "../../timemanager/Clock.h"
|
||||||
#include "../../ipc/MutexHelper.h"
|
#include "../../ipc/MutexGuard.h"
|
||||||
|
|
||||||
#include <rtems/score/todimpl.h>
|
#include <rtems/score/todimpl.h>
|
||||||
#include <rtems/rtems/clockimpl.h>
|
#include <rtems/rtems/clockimpl.h>
|
||||||
@ -183,7 +183,7 @@ ReturnValue_t Clock::setLeapSeconds(const uint16_t leapSeconds_) {
|
|||||||
if(checkOrCreateClockMutex()!=HasReturnvaluesIF::RETURN_OK){
|
if(checkOrCreateClockMutex()!=HasReturnvaluesIF::RETURN_OK){
|
||||||
return HasReturnvaluesIF::RETURN_FAILED;
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
}
|
}
|
||||||
MutexHelper helper(timeMutex);
|
MutexGuard helper(timeMutex);
|
||||||
|
|
||||||
|
|
||||||
leapSeconds = leapSeconds_;
|
leapSeconds = leapSeconds_;
|
||||||
@ -196,7 +196,7 @@ ReturnValue_t Clock::getLeapSeconds(uint16_t* leapSeconds_) {
|
|||||||
if(timeMutex==nullptr){
|
if(timeMutex==nullptr){
|
||||||
return HasReturnvaluesIF::RETURN_FAILED;
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
}
|
}
|
||||||
MutexHelper helper(timeMutex);
|
MutexGuard helper(timeMutex);
|
||||||
|
|
||||||
*leapSeconds_ = leapSeconds;
|
*leapSeconds_ = leapSeconds;
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include "TmTcWinUdpBridge.h"
|
#include "TmTcWinUdpBridge.h"
|
||||||
|
|
||||||
#include <fsfw/ipc/MutexHelper.h>
|
#include <fsfw/ipc/MutexGuard.h>
|
||||||
|
|
||||||
#if defined(_MSC_VER)
|
#if defined(_MSC_VER)
|
||||||
#include <BaseTsd.h>
|
#include <BaseTsd.h>
|
||||||
|
Loading…
Reference in New Issue
Block a user