I don't remember if this problem (of /tmp getting cleared up after
sometime) was ever discussed at all.
Ack,
Mathi.

On Thu, Feb 13, 2020 at 2:46 PM Alex Jones <ajo...@rbbn.com> wrote:

> Message queues stop working correctly after queue file is removed from
> /tmp.
>
> Message queue API uses "ftok" which relies on the file being permanent. The
> behaviour is undefined if the file is removed. Many systems clean out /tmp
> periodically, so this can break if the message queue is long lived.
>
> Create the queue file in /var/run.
> ---
> src/base/os_defs.c | 19 +++++++++++++++++--
> 1 file changed, 17 insertions(+), 2 deletions(-)
>
> diff --git a/src/base/os_defs.c b/src/base/os_defs.c
> index da38cd71c..83458c208 100644
> --- a/src/base/os_defs.c
> +++ b/src/base/os_defs.c
> @@ -55,6 +55,8 @@
> #include "base/osaf_time.h"
> #include "base/logtrace.h"
>
> +#include "osaf/configmake.h"
> +
> NCS_OS_LOCK gl_ncs_atomic_mtx;
> #ifndef NDEBUG
> bool gl_ncs_atomic_mtx_initialise = false;
> @@ -658,7 +660,7 @@ uint32_t ncs_os_posix_mq(NCS_OS_POSIX_MQ_REQ_INFO *req)
>
> memset(&buf, 0, sizeof(struct msqid_ds));
>
> - sprintf(filename, "/tmp/%s%d", req->info.open.qname,
> + sprintf(filename, PKGPIDDIR "/%s%d", req->info.open.qname,
> req->info.open.node);
>
> if (req->info.open.iflags & O_CREAT) {
> @@ -669,6 +671,13 @@ uint32_t ncs_os_posix_mq(NCS_OS_POSIX_MQ_REQ_INFO
> *req)
> return NCSCC_RC_FAILURE;
>
> key = ftok(filename, 1);
> +
> + if (key < 0) {
> + LOG_ER("ftok failed for %s: %i", filename,
> + errno);
> + return NCSCC_RC_FAILURE;
> + }
> +
> os_req.info.create.i_key = &key;
>
> if (fclose(file) != 0)
> @@ -678,6 +687,12 @@ uint32_t ncs_os_posix_mq(NCS_OS_POSIX_MQ_REQ_INFO
> *req)
> os_req.req = NCS_OS_MQ_REQ_OPEN;
>
> key = ftok(filename, 1);
> +
> + if (key < 0) {
> + LOG_ER("ftok failed for %s: %i", filename,
> + errno);
> + return NCSCC_RC_FAILURE;
> + }
> os_req.info.open.i_key = &key;
> }
>
> @@ -721,7 +736,7 @@ uint32_t ncs_os_posix_mq(NCS_OS_POSIX_MQ_REQ_INFO *req)
> char filename[264];
>
> memset(filename, 0, sizeof(filename));
> - sprintf(filename, "/tmp/%s%d", req->info.unlink.qname,
> + sprintf(filename, PKGPIDDIR "%s%d", req->info.unlink.qname,
> req->info.unlink.node);
>
> if (unlink(filename) != 0)
> --
> 2.21.1
>
>
> ------------------------------
> Notice: This e-mail together with any attachments may contain information
> of Ribbon Communications Inc. that is confidential and/or proprietary for
> the sole use of the intended recipient. Any review, disclosure, reliance or
> distribution by others or forwarding without express permission is strictly
> prohibited. If you are not the intended recipient, please notify the sender
> immediately and then delete all copies, including any attachments.
> ------------------------------
>

_______________________________________________
Opensaf-devel mailing list
Opensaf-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensaf-devel

Reply via email to