improved diagnostic messages for linux
This commit is contained in:
parent
04236859da
commit
95bc5a871b
@ -36,7 +36,7 @@ DeviceHandlerBase::DeviceHandlerBase(object_id_t setObjectId,
|
|||||||
childTransitionDelay(5000),
|
childTransitionDelay(5000),
|
||||||
transitionSourceMode(_MODE_POWER_DOWN), transitionSourceSubMode(
|
transitionSourceMode(_MODE_POWER_DOWN), transitionSourceSubMode(
|
||||||
SUBMODE_NONE), deviceSwitch(setDeviceSwitch) {
|
SUBMODE_NONE), deviceSwitch(setDeviceSwitch) {
|
||||||
commandQueue = QueueFactory::instance()->createMessageQueue(1,
|
commandQueue = QueueFactory::instance()->createMessageQueue(cmdQueueSize,
|
||||||
CommandMessage::MAX_MESSAGE_SIZE);
|
CommandMessage::MAX_MESSAGE_SIZE);
|
||||||
cookieInfo.state = COOKIE_UNUSED;
|
cookieInfo.state = COOKIE_UNUSED;
|
||||||
insertInCommandMap(RAW_COMMAND_ID);
|
insertInCommandMap(RAW_COMMAND_ID);
|
||||||
|
@ -1,12 +1,14 @@
|
|||||||
#include <framework/serviceinterface/ServiceInterfaceStream.h>
|
#include <framework/serviceinterface/ServiceInterfaceStream.h>
|
||||||
#include <framework/osal/linux/MessageQueue.h>
|
#include <framework/osal/linux/MessageQueue.h>
|
||||||
|
|
||||||
|
#include <fstream>
|
||||||
|
|
||||||
#include <fcntl.h> /* For O_* constants */
|
#include <fcntl.h> /* For O_* constants */
|
||||||
#include <sys/stat.h> /* For mode constants */
|
#include <sys/stat.h> /* For mode constants */
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
MessageQueue::MessageQueue(uint32_t messageDepth, size_t maxMessageSize): id(0),
|
MessageQueue::MessageQueue(uint32_t messageDepth, size_t maxMessageSize): id(0),
|
||||||
lastPartner(0), defaultDestination(NO_QUEUE) {
|
lastPartner(0), defaultDestination(NO_QUEUE) {
|
||||||
//debug << "MessageQueue::MessageQueue: Creating a queue" << std::endl;
|
//debug << "MessageQueue::MessageQueue: Creating a queue" << std::endl;
|
||||||
@ -22,10 +24,11 @@ MessageQueue::MessageQueue(uint32_t messageDepth, size_t maxMessageSize): id(0),
|
|||||||
|
|
||||||
// Create a nonblocking queue if the name is available (the queue is read
|
// Create a nonblocking queue if the name is available (the queue is read
|
||||||
// and writable for the owner as well as the group)
|
// and writable for the owner as well as the group)
|
||||||
mqd_t tempId = mq_open(name, O_NONBLOCK | O_RDWR | O_CREAT | O_EXCL,
|
int oflag = O_NONBLOCK | O_RDWR | O_CREAT | O_EXCL;
|
||||||
S_IWUSR | S_IREAD | S_IWGRP | S_IRGRP | S_IROTH | S_IWOTH, &attributes);
|
mode_t mode = S_IWUSR | S_IREAD | S_IWGRP | S_IRGRP | S_IROTH | S_IWOTH;
|
||||||
|
mqd_t tempId = mq_open(name, oflag, mode, &attributes);
|
||||||
if (tempId == -1) {
|
if (tempId == -1) {
|
||||||
handleError(&attributes);
|
handleError(&attributes, messageDepth);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
//Successful mq_open call
|
//Successful mq_open call
|
||||||
@ -46,10 +49,27 @@ MessageQueue::~MessageQueue() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t MessageQueue::handleError(mq_attr* attributes) {
|
ReturnValue_t MessageQueue::handleError(mq_attr* attributes,
|
||||||
|
uint32_t messageDepth) {
|
||||||
switch(errno) {
|
switch(errno) {
|
||||||
case(EINVAL): {
|
case(EINVAL): {
|
||||||
sif::error << "MessageQueue::MessageQueue: Invalid Name " << std::endl;
|
sif::error << "MessageQueue::MessageQueue: Invalid Name or attributes"
|
||||||
|
" for message size" << std::endl;
|
||||||
|
size_t defaultMqMaxMsg;
|
||||||
|
if(std::ifstream("/proc/sys/fs/mqueue/msg_max",std::ios::in) >>
|
||||||
|
defaultMqMaxMsg and defaultMqMaxMsg < messageDepth) {
|
||||||
|
// See: https://www.man7.org/linux/man-pages/man3/mq_open.3.html
|
||||||
|
// This happens if the msg_max value is not large enough
|
||||||
|
// It is ignored if the executable is run in privileged mode.
|
||||||
|
// Run the unlockRealtime script or grant the mode manully by using:
|
||||||
|
// sudo setcap 'CAP_SYS_RESOURCE=+ep' <pathToBinary>
|
||||||
|
|
||||||
|
// Permanent solution:
|
||||||
|
// echo msg_max | sudo tee /proc/sys/fs/mqueue/msg_max
|
||||||
|
sif::error << "MessageQueue::MessageQueue: Default MQ size "
|
||||||
|
<< defaultMqMaxMsg << " is too small for requested size "
|
||||||
|
<< messageDepth << std::endl;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case(EEXIST): {
|
case(EEXIST): {
|
||||||
|
@ -175,7 +175,7 @@ private:
|
|||||||
|
|
||||||
static uint16_t queueCounter;
|
static uint16_t queueCounter;
|
||||||
|
|
||||||
ReturnValue_t handleError(mq_attr* attributes);
|
ReturnValue_t handleError(mq_attr* attributes, uint32_t messageDepth);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* MESSAGEQUEUE_H_ */
|
#endif /* MESSAGEQUEUE_H_ */
|
||||||
|
@ -138,7 +138,7 @@ void PosixThread::createTask(void* (*fnc_)(void*), void* arg_) {
|
|||||||
void* sp;
|
void* sp;
|
||||||
status = posix_memalign(&sp, sysconf(_SC_PAGESIZE), stackSize);
|
status = posix_memalign(&sp, sysconf(_SC_PAGESIZE), stackSize);
|
||||||
if(status != 0){
|
if(status != 0){
|
||||||
sif::error << "Posix Thread stack init failed with: " <<
|
sif::error << "PosixThread::createTask: Stack init failed with: " <<
|
||||||
strerror(status) << std::endl;
|
strerror(status) << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user