# HG changeset patch # User František Kučera # Date 1677095140 -3600 # Node ID 7722d28539d55075fe5e0d5416ed6084d6d363f8 # Parent 04550f27162304a11dc30c0b2db6b3384f5e64b3 default maxmsg + msgsize diff -r 04550f271623 -r 7722d28539d5 src/PosixMQ.h --- a/src/PosixMQ.h Thu Dec 15 21:43:59 2022 +0100 +++ b/src/PosixMQ.h Wed Feb 22 20:45:40 2023 +0100 @@ -27,6 +27,7 @@ class PosixMQ { private: + const static size_t MSG_COUNT = 10; // TODO: configurable/dynamic const static size_t MSG_SIZE = 8192; // TODO: configurable/dynamic std::string queueName; mqd_t handle = -2; @@ -43,7 +44,11 @@ } static PosixMQ* open(std::string queueName, bool unlinkOnClose = false) { - mqd_t handle = mq_open(queueName.c_str(), O_RDONLY | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP); + struct mq_attr attr = (struct mq_attr){0}; + attr.mq_maxmsg = MSG_COUNT; + attr.mq_msgsize = MSG_SIZE; + + mqd_t handle = mq_open(queueName.c_str(), O_RDONLY | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP, &attr); if (handle >= 0) return new PosixMQ(queueName, handle, unlinkOnClose); else throw std::logic_error("Unable to open PosixMQ: " + queueName + " error: " + strerror(errno)); }