Commit b9ef9d81 authored by claes's avatar claes

Local mq replaced

parent 89280853
/* /*
* Proview $Id: rt_errh.c,v 1.8 2005-12-15 07:40:16 claes Exp $ * Proview $Id: rt_errh.c,v 1.9 2006-07-07 07:06:55 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
...@@ -48,7 +48,7 @@ ...@@ -48,7 +48,7 @@
# include "rt_errl.h" # include "rt_errl.h"
# if defined(OS_LINUX) # if defined(OS_LINUX)
# include <time.h> # include <time.h>
# include "rt_mq.h" # include <mqueue.h>
# elif defined(OS_LYNX) # elif defined(OS_LYNX)
# include <mqueue.h> # include <mqueue.h>
# endif # endif
...@@ -120,7 +120,6 @@ typedef struct { ...@@ -120,7 +120,6 @@ typedef struct {
typedef pid_t sPid; typedef pid_t sPid;
static mqd_t mqid = (mqd_t)-1; static mqd_t mqid = (mqd_t)-1;
static const unsigned int prio = PWR_MQ_PRIO_MAX - 1;
#endif #endif
...@@ -534,16 +533,21 @@ openLog () ...@@ -534,16 +533,21 @@ openLog ()
#if defined OS_LYNX || defined OS_LINUX #if defined OS_LYNX || defined OS_LINUX
if (mqid == (mqd_t)-1) { if (mqid == (mqd_t)-1) {
char name[64]; char name[64];
struct mq_attr attr;
char *busid = getenv(pwr_dEnvBusId); char *busid = getenv(pwr_dEnvBusId);
sprintf(name, "%s_%s", LOG_QUEUE_NAME, busid ? busid : ""); sprintf(name, "%s_%s", LOG_QUEUE_NAME, busid ? busid : "");
mqid = mq_open(name, O_WRONLY | O_NONBLOCK, 0, NULL); attr.mq_maxmsg = 2048;
attr.mq_msgsize = sizeof(errh_sMsg);
attr.mq_flags = O_NONBLOCK;
mqid = mq_open(name, O_WRONLY | O_NONBLOCK, 0, &attr);
if (mqid == (mqd_t)-1) { if (mqid == (mqd_t)-1) {
char string[256]; char string[256];
char *s; char *s;
s = errh_Message(string, 'E', "Open messageQ, mq_open(%s)\n%s", name, strerror(errno)); s = errh_Message(string, 'E', "Open messageQ, mq_open(%s)\n%s", name, strerror(errno));
printf("%s\n", s); printf("%s\n", s);
return;
} }
} }
#endif #endif
...@@ -1089,6 +1093,7 @@ errh_send (char *s, char severity, pwr_tStatus sts, errh_eMsgType message_type) ...@@ -1089,6 +1093,7 @@ errh_send (char *s, char severity, pwr_tStatus sts, errh_eMsgType message_type)
len = sizeof(msg) - sizeof(msg.message_type) - sizeof(msg.str); len = sizeof(msg) - sizeof(msg.message_type) - sizeof(msg.str);
break; break;
} }
unsigned int prio = sysconf(_SC_MQ_PRIO_MAX) - 1;
if (mq_send(mqid, (char *)&msg, MIN(len, LOG_MAX_MSG_SIZE - 1), prio) == -1) { if (mq_send(mqid, (char *)&msg, MIN(len, LOG_MAX_MSG_SIZE - 1), prio) == -1) {
/* /*
perror("mq_send"); perror("mq_send");
......
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