better error handling for mq_receive()
This commit is contained in:
parent
567699954c
commit
e961f3f038
@ -12,8 +12,7 @@
|
||||
|
||||
MessageQueue::MessageQueue(uint32_t messageDepth, size_t maxMessageSize):
|
||||
id(MessageQueueIF::NO_QUEUE),lastPartner(MessageQueueIF::NO_QUEUE),
|
||||
defaultDestination(MessageQueueIF::NO_QUEUE),
|
||||
maxMessageSize(maxMessageSize) {
|
||||
defaultDestination(MessageQueueIF::NO_QUEUE), maxMessageSize(maxMessageSize) {
|
||||
//debug << "MessageQueue::MessageQueue: Creating a queue" << std::endl;
|
||||
mq_attr attributes;
|
||||
this->id = 0;
|
||||
@ -91,7 +90,6 @@ ReturnValue_t MessageQueue::handleError(mq_attr* attributes,
|
||||
sif::error << "This error can be fixed by setting the maximum "
|
||||
"allowed message size higher!" << std::endl;
|
||||
#endif
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -204,14 +202,15 @@ ReturnValue_t MessageQueue::receiveMessage(MessageQueueMessageIF* message) {
|
||||
//O_NONBLOCK or MQ_NONBLOCK was set and there are no messages
|
||||
//currently on the specified queue.
|
||||
return MessageQueueIF::EMPTY;
|
||||
case EBADF:
|
||||
case EBADF: {
|
||||
//mqdes doesn't represent a valid queue open for reading.
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "MessageQueue::receive: configuration error "
|
||||
<< strerror(errno) << std::endl;
|
||||
#endif
|
||||
/*NO BREAK*/
|
||||
case EINVAL:
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
case EINVAL: {
|
||||
/*
|
||||
* This value indicates one of the following:
|
||||
* - The pointer to the buffer for storing the received message,
|
||||
@ -222,11 +221,12 @@ ReturnValue_t MessageQueue::receiveMessage(MessageQueueMessageIF* message) {
|
||||
* been set in the queue's mq_flags.
|
||||
*/
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "MessageQueue::receive: configuration error "
|
||||
sif::error << "MessageQueue::receive: EINVAL error "
|
||||
<< strerror(errno) << std::endl;
|
||||
#endif
|
||||
/*NO BREAK*/
|
||||
case EMSGSIZE:
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
case EMSGSIZE: {
|
||||
/*
|
||||
* This value indicates one of the following:
|
||||
* - the QNX extended option MQ_READBUF_DYNAMIC hasn't been set,
|
||||
@ -237,12 +237,29 @@ ReturnValue_t MessageQueue::receiveMessage(MessageQueueMessageIF* message) {
|
||||
* been received.
|
||||
*/
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "MessageQueue::receive: configuration error "
|
||||
sif::error << "MessageQueue::receive: EMSGSIZE error "
|
||||
<< strerror(errno) << std::endl;
|
||||
#endif
|
||||
/*NO BREAK*/
|
||||
case EINTR:
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
|
||||
case EINTR: {
|
||||
//The operation was interrupted by a signal.
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "MessageQueue::receiveMessage: EINTR error " << strerror(errno) <<
|
||||
std::endl;
|
||||
#endif
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
case ETIMEDOUT: {
|
||||
//The operation was interrupted by a signal.
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "MessageQueue::receiveMessage: ETIMEDOUT error " << strerror(errno) <<
|
||||
std::endl;
|
||||
#endif
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
|
||||
default:
|
||||
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
|
Loading…
x
Reference in New Issue
Block a user