# HG changeset patch # User František Kučera # Date 1677095157 -3600 # Node ID 2f116bd15f27f0ded1271385696cf0bf5056fdc6 # Parent 9f89ecc071bf4f906712cae977037d4d19549623 default maxmsg + msgsize diff -r 9f89ecc071bf -r 2f116bd15f27 src/PosixMQ.h --- a/src/PosixMQ.h Thu Dec 15 21:43:59 2022 +0100 +++ b/src/PosixMQ.h Wed Feb 22 20:45:57 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_RDWR | 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_RDWR | 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)); }