option -x to disable x11 session monitoring
This commit is contained in:
+5
-2
@@ -2,7 +2,7 @@
|
||||
#define _RCLMON_H_INCLUDED_
|
||||
#include "autoconfig.h"
|
||||
#ifdef RCL_MONITOR
|
||||
/* @(#$Id: rclmon.h,v 1.7 2006-11-07 16:51:45 dockes Exp $ (C) 2006 J.F.Dockes */
|
||||
/* @(#$Id: rclmon.h,v 1.8 2006-12-24 07:40:26 dockes Exp $ (C) 2006 J.F.Dockes */
|
||||
/**
|
||||
* Definitions for the real-time monitoring recoll.
|
||||
* We're interested in file modifications, deletions and renaming.
|
||||
@@ -37,6 +37,8 @@ class RclMonEvent {
|
||||
RclMonEvent() : m_etyp(RCLEVT_NONE) {}
|
||||
};
|
||||
|
||||
enum RclMonitorOption {RCLMON_NONE=0, RCLMON_NOFORK=1, RCLMON_NOX11=2};
|
||||
|
||||
/**
|
||||
* Monitoring event queue. This is the shared object between the main thread
|
||||
* (which does the actual indexing work), and the monitoring thread which
|
||||
@@ -60,6 +62,7 @@ class RclMonEventQueue {
|
||||
bool ok();
|
||||
bool empty();
|
||||
RclMonEvent pop();
|
||||
void setopts(int opts);
|
||||
|
||||
// Convenience function for initially communicating config to mon thr
|
||||
void setConfig(RclConfig *conf);
|
||||
@@ -70,7 +73,7 @@ class RclMonEventQueue {
|
||||
};
|
||||
|
||||
/** Start monitoring on the topdirs described in conf */
|
||||
extern bool startMonitor(RclConfig *conf, bool nofork);
|
||||
extern bool startMonitor(RclConfig *conf, int flags);
|
||||
|
||||
/** Main routine for the event receiving thread */
|
||||
extern void *rclMonRcvRun(void *);
|
||||
|
||||
+11
-3
@@ -2,7 +2,7 @@
|
||||
|
||||
#ifdef RCL_MONITOR
|
||||
#ifndef lint
|
||||
static char rcsid[] = "@(#$Id: rclmonprc.cpp,v 1.9 2006-12-23 13:07:21 dockes Exp $ (C) 2006 J.F.Dockes";
|
||||
static char rcsid[] = "@(#$Id: rclmonprc.cpp,v 1.10 2006-12-24 07:40:26 dockes Exp $ (C) 2006 J.F.Dockes";
|
||||
#endif
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -47,6 +47,7 @@ typedef map<string, RclMonEvent> queue_type;
|
||||
*/
|
||||
class RclEQData {
|
||||
public:
|
||||
int m_opts;
|
||||
queue_type m_queue;
|
||||
RclConfig *m_config;
|
||||
bool m_ok;
|
||||
@@ -77,6 +78,12 @@ bool RclMonEventQueue::empty()
|
||||
return m_data == 0 ? true : m_data->m_queue.empty();
|
||||
}
|
||||
|
||||
void RclMonEventQueue::setopts(int opts)
|
||||
{
|
||||
if (m_data)
|
||||
m_data->m_opts = opts;
|
||||
}
|
||||
|
||||
// Must be called with the queue locked
|
||||
RclMonEvent RclMonEventQueue::pop()
|
||||
{
|
||||
@@ -166,7 +173,7 @@ bool RclMonEventQueue::ok()
|
||||
LOGDEB(("RclMonEventQueue: not ok: bad state\n"));
|
||||
return false;
|
||||
}
|
||||
if (!x11IsAlive()) {
|
||||
if (!(m_data->m_opts & RCLMON_NOX11) && !x11IsAlive()) {
|
||||
LOGDEB(("RclMonEventQueue: not ok: x11\n"));
|
||||
return false;
|
||||
}
|
||||
@@ -268,7 +275,7 @@ static void processunlock()
|
||||
|
||||
pthread_t rcv_thrid;
|
||||
|
||||
bool startMonitor(RclConfig *conf, bool nofork)
|
||||
bool startMonitor(RclConfig *conf, int opts)
|
||||
{
|
||||
if (!processlock(conf->getConfDir())) {
|
||||
LOGERR(("startMonitor: lock error. Other process running ?\n"));
|
||||
@@ -277,6 +284,7 @@ bool startMonitor(RclConfig *conf, bool nofork)
|
||||
atexit(processunlock);
|
||||
|
||||
rclEQ.setConfig(conf);
|
||||
rclEQ.setopts(opts);
|
||||
if (pthread_create(&rcv_thrid, 0, &rclMonRcvRun, &rclEQ) != 0) {
|
||||
LOGERR(("startMonitor: cant create event-receiving thread\n"));
|
||||
return false;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#ifndef lint
|
||||
static char rcsid[] = "@(#$Id: recollindex.cpp,v 1.29 2006-12-21 09:22:31 dockes Exp $ (C) 2004 J.F.Dockes";
|
||||
static char rcsid[] = "@(#$Id: recollindex.cpp,v 1.30 2006-12-24 07:40:26 dockes Exp $ (C) 2004 J.F.Dockes";
|
||||
#endif
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -217,6 +217,7 @@ static int op_flags;
|
||||
#define OPT_D 0x100
|
||||
#define OPT_e 0x200
|
||||
#define OPT_w 0x400
|
||||
#define OPT_x 0x800
|
||||
|
||||
static const char usage [] =
|
||||
"\n"
|
||||
@@ -226,8 +227,10 @@ static const char usage [] =
|
||||
" Index everything according to configuration file\n"
|
||||
" -z : reset database before starting indexation\n"
|
||||
#ifdef RCL_MONITOR
|
||||
"recollindex -m [-D]\n"
|
||||
" Perform real time indexation. Don't become a daemon if -D is set\n"
|
||||
"recollindex -m [-w <secs>] -x [-D]\n"
|
||||
" Perform real time indexation. Don't become a daemon if -D is set.\n"
|
||||
" -w sets number of seconds to wait before starting.\n"
|
||||
" -x disables exit on end of x11 session\n"
|
||||
#endif
|
||||
"recollindex -e <filename [filename ...]>\n"
|
||||
" Purge data for individual files. No stem database updates\n"
|
||||
@@ -288,6 +291,7 @@ int main(int argc, const char **argv)
|
||||
Usage();
|
||||
argc--; goto b1;
|
||||
#endif
|
||||
case 'x': op_flags |= OPT_x; break;
|
||||
case 'z': op_flags |= OPT_z; break;
|
||||
default: Usage(); break;
|
||||
}
|
||||
@@ -352,7 +356,12 @@ int main(int argc, const char **argv)
|
||||
confindexer = new ConfIndexer(config, &updater);
|
||||
confindexer->index(rezero);
|
||||
delete confindexer;
|
||||
if (startMonitor(config, (op_flags&OPT_D)!=0))
|
||||
int opts = RCLMON_NONE;
|
||||
if (op_flags & OPT_D)
|
||||
opts |= RCLMON_NOFORK;
|
||||
if (op_flags & OPT_x)
|
||||
opts |= RCLMON_NOX11;
|
||||
if (startMonitor(config, opts))
|
||||
exit(0);
|
||||
exit(1);
|
||||
#endif // MONITOR
|
||||
|
||||
Reference in New Issue
Block a user