Commit 4a481a43 authored by claes's avatar claes

Try with smaller queue if mq_open returns EINVAL

parent 1f8962c2
/* /*
* Proview $Id: rt_errl.c,v 1.7 2006-01-31 08:31:01 claes Exp $ * Proview $Id: rt_errl.c,v 1.8 2006-07-20 10:23:52 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB. * Copyright (C) 2005 SSAB Oxelsund AB.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
...@@ -28,11 +28,13 @@ ...@@ -28,11 +28,13 @@
#include <sys/stat.h> #include <sys/stat.h>
#include <fcntl.h> #include <fcntl.h>
#include <unistd.h> #include <unistd.h>
#if defined _POSIX_MESSAGE_PASSING //#if defined _POSIX_MESSAGE_PASSING
# include <mqueue.h> # include <mqueue.h>
#else //#else
# include "rt_mq.h" //# include "rt_mq.h"
#endif //#endif
#include <mqueue.h>
#include <limits.h> #include <limits.h>
#include <pthread.h> #include <pthread.h>
#include <sys/time.h> #include <sys/time.h>
...@@ -40,11 +42,8 @@ ...@@ -40,11 +42,8 @@
#include "rt_errl.h" #include "rt_errl.h"
#include "rt_errh.h" #include "rt_errh.h"
#if defined _POSIX_MESSAGE_PASSING #define MAX_NO_MSG 100;
# define MAX_NO_MSG 10; #define DEF_MAX_NO_MSG 10;
#else
# define MAX_NO_MSG 100;
#endif
static pthread_mutex_t fileMutex; static pthread_mutex_t fileMutex;
static pthread_mutex_t termMutex; static pthread_mutex_t termMutex;
...@@ -106,16 +105,25 @@ errl_Init ( ...@@ -106,16 +105,25 @@ errl_Init (
mqattr.mq_msgsize = LOG_MAX_MSG_SIZE; /* max mess size */ mqattr.mq_msgsize = LOG_MAX_MSG_SIZE; /* max mess size */
mqattr.mq_maxmsg = MAX_NO_MSG; /* max no of msg in this queue */ mqattr.mq_maxmsg = MAX_NO_MSG; /* max no of msg in this queue */
mqattr.mq_flags = 0; /* not used entry */ mqattr.mq_flags = 0; // O_NONBLOCK;
oflags = O_CREAT | O_RDWR; oflags = O_CREAT | O_RDWR;
mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH; mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH;
sprintf(name, "%s_%s", LOG_QUEUE_NAME, busid ? busid : ""); sprintf(name, "%s_%s", LOG_QUEUE_NAME, busid ? busid : "");
mqid = mq_open(name, oflags, mode, &mqattr); mqid = mq_open(name, oflags, mode, &mqattr);
if (mqid == (mqd_t)-1) { if (mqid == (mqd_t)-1) {
if (errno == EINVAL) {
mqattr.mq_maxmsg = DEF_MAX_NO_MSG; /* Try with smaller queue */
mqid = mq_open(name, oflags, mode, &mqattr);
if (mqid == (mqd_t)-1) {
perror("rt_logmod: mq_open ");
return;
}
} else {
perror("rt_logmod: mq_open "); perror("rt_logmod: mq_open ");
return; return;
} }
}
pthread_attr_init(&pthreadattr); pthread_attr_init(&pthreadattr);
if (pthread_create(&tid, &pthreadattr, log_thread, NULL) == -1) { if (pthread_create(&tid, &pthreadattr, log_thread, NULL) == -1) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment