|
a/src/index/rclmonprc.cpp |
|
b/src/index/rclmonprc.cpp |
1 |
#include "autoconfig.h"
|
1 |
#include "autoconfig.h"
|
2 |
|
2 |
|
3 |
#ifdef RCL_MONITOR
|
3 |
#ifdef RCL_MONITOR
|
4 |
#ifndef lint
|
4 |
#ifndef lint
|
5 |
static char rcsid[] = "@(#$Id: rclmonprc.cpp,v 1.9 2006-12-23 13:07:21 dockes Exp $ (C) 2006 J.F.Dockes";
|
5 |
static char rcsid[] = "@(#$Id: rclmonprc.cpp,v 1.10 2006-12-24 07:40:26 dockes Exp $ (C) 2006 J.F.Dockes";
|
6 |
#endif
|
6 |
#endif
|
7 |
/*
|
7 |
/*
|
8 |
* This program is free software; you can redistribute it and/or modify
|
8 |
* This program is free software; you can redistribute it and/or modify
|
9 |
* it under the terms of the GNU General Public License as published by
|
9 |
* it under the terms of the GNU General Public License as published by
|
10 |
* the Free Software Foundation; either version 2 of the License, or
|
10 |
* the Free Software Foundation; either version 2 of the License, or
|
|
... |
|
... |
45 |
/** Private part of RclEQ: things that we don't wish to exist in the interface
|
45 |
/** Private part of RclEQ: things that we don't wish to exist in the interface
|
46 |
* include file.
|
46 |
* include file.
|
47 |
*/
|
47 |
*/
|
48 |
class RclEQData {
|
48 |
class RclEQData {
|
49 |
public:
|
49 |
public:
|
|
|
50 |
int m_opts;
|
50 |
queue_type m_queue;
|
51 |
queue_type m_queue;
|
51 |
RclConfig *m_config;
|
52 |
RclConfig *m_config;
|
52 |
bool m_ok;
|
53 |
bool m_ok;
|
53 |
pthread_mutex_t m_mutex;
|
54 |
pthread_mutex_t m_mutex;
|
54 |
pthread_cond_t m_cond;
|
55 |
pthread_cond_t m_cond;
|
|
... |
|
... |
73 |
}
|
74 |
}
|
74 |
|
75 |
|
75 |
bool RclMonEventQueue::empty()
|
76 |
bool RclMonEventQueue::empty()
|
76 |
{
|
77 |
{
|
77 |
return m_data == 0 ? true : m_data->m_queue.empty();
|
78 |
return m_data == 0 ? true : m_data->m_queue.empty();
|
|
|
79 |
}
|
|
|
80 |
|
|
|
81 |
void RclMonEventQueue::setopts(int opts)
|
|
|
82 |
{
|
|
|
83 |
if (m_data)
|
|
|
84 |
m_data->m_opts = opts;
|
78 |
}
|
85 |
}
|
79 |
|
86 |
|
80 |
// Must be called with the queue locked
|
87 |
// Must be called with the queue locked
|
81 |
RclMonEvent RclMonEventQueue::pop()
|
88 |
RclMonEvent RclMonEventQueue::pop()
|
82 |
{
|
89 |
{
|
|
... |
|
... |
164 |
{
|
171 |
{
|
165 |
if (m_data == 0) {
|
172 |
if (m_data == 0) {
|
166 |
LOGDEB(("RclMonEventQueue: not ok: bad state\n"));
|
173 |
LOGDEB(("RclMonEventQueue: not ok: bad state\n"));
|
167 |
return false;
|
174 |
return false;
|
168 |
}
|
175 |
}
|
169 |
if (!x11IsAlive()) {
|
176 |
if (!(m_data->m_opts & RCLMON_NOX11) && !x11IsAlive()) {
|
170 |
LOGDEB(("RclMonEventQueue: not ok: x11\n"));
|
177 |
LOGDEB(("RclMonEventQueue: not ok: x11\n"));
|
171 |
return false;
|
178 |
return false;
|
172 |
}
|
179 |
}
|
173 |
if (stopindexing) {
|
180 |
if (stopindexing) {
|
174 |
LOGDEB(("RclMonEventQueue: not ok: stop request\n"));
|
181 |
LOGDEB(("RclMonEventQueue: not ok: stop request\n"));
|
|
... |
|
... |
266 |
unlink(pidfile.c_str());
|
273 |
unlink(pidfile.c_str());
|
267 |
}
|
274 |
}
|
268 |
|
275 |
|
269 |
pthread_t rcv_thrid;
|
276 |
pthread_t rcv_thrid;
|
270 |
|
277 |
|
271 |
bool startMonitor(RclConfig *conf, bool nofork)
|
278 |
bool startMonitor(RclConfig *conf, int opts)
|
272 |
{
|
279 |
{
|
273 |
if (!processlock(conf->getConfDir())) {
|
280 |
if (!processlock(conf->getConfDir())) {
|
274 |
LOGERR(("startMonitor: lock error. Other process running ?\n"));
|
281 |
LOGERR(("startMonitor: lock error. Other process running ?\n"));
|
275 |
return false;
|
282 |
return false;
|
276 |
}
|
283 |
}
|
277 |
atexit(processunlock);
|
284 |
atexit(processunlock);
|
278 |
|
285 |
|
279 |
rclEQ.setConfig(conf);
|
286 |
rclEQ.setConfig(conf);
|
|
|
287 |
rclEQ.setopts(opts);
|
280 |
if (pthread_create(&rcv_thrid, 0, &rclMonRcvRun, &rclEQ) != 0) {
|
288 |
if (pthread_create(&rcv_thrid, 0, &rclMonRcvRun, &rclEQ) != 0) {
|
281 |
LOGERR(("startMonitor: cant create event-receiving thread\n"));
|
289 |
LOGERR(("startMonitor: cant create event-receiving thread\n"));
|
282 |
return false;
|
290 |
return false;
|
283 |
}
|
291 |
}
|
284 |
|
292 |
|