traces
This commit is contained in:
parent
86cff74c15
commit
7814e0fb0a
@ -2,7 +2,7 @@
|
|||||||
#define _RCLMON_H_INCLUDED_
|
#define _RCLMON_H_INCLUDED_
|
||||||
#include "autoconfig.h"
|
#include "autoconfig.h"
|
||||||
#ifdef RCL_MONITOR
|
#ifdef RCL_MONITOR
|
||||||
/* @(#$Id: rclmon.h,v 1.6 2006-10-25 10:52:02 dockes Exp $ (C) 2006 J.F.Dockes */
|
/* @(#$Id: rclmon.h,v 1.7 2006-11-07 16:51:45 dockes Exp $ (C) 2006 J.F.Dockes */
|
||||||
/**
|
/**
|
||||||
* Definitions for the real-time monitoring recoll.
|
* Definitions for the real-time monitoring recoll.
|
||||||
* We're interested in file modifications, deletions and renaming.
|
* We're interested in file modifications, deletions and renaming.
|
||||||
@ -79,5 +79,9 @@ extern void *rclMonRcvRun(void *);
|
|||||||
* directory. We write our pid in there */
|
* directory. We write our pid in there */
|
||||||
#define RCL_MONITOR_PIDFILENAME "rclmonpid"
|
#define RCL_MONITOR_PIDFILENAME "rclmonpid"
|
||||||
|
|
||||||
|
// Specific debug macro for monitor synchronization events
|
||||||
|
#define MONDEB LOGDEB2
|
||||||
|
|
||||||
|
|
||||||
#endif // RCL_MONITOR
|
#endif // RCL_MONITOR
|
||||||
#endif /* _RCLMON_H_INCLUDED_ */
|
#endif /* _RCLMON_H_INCLUDED_ */
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#ifdef RCL_MONITOR
|
#ifdef RCL_MONITOR
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
static char rcsid[] = "@(#$Id: rclmonprc.cpp,v 1.6 2006-10-25 10:52:02 dockes Exp $ (C) 2006 J.F.Dockes";
|
static char rcsid[] = "@(#$Id: rclmonprc.cpp,v 1.7 2006-11-07 16:51:45 dockes Exp $ (C) 2006 J.F.Dockes";
|
||||||
#endif
|
#endif
|
||||||
/*
|
/*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
@ -92,9 +92,9 @@ RclMonEvent RclMonEventQueue::pop()
|
|||||||
*/
|
*/
|
||||||
bool RclMonEventQueue::wait(int seconds, bool *top)
|
bool RclMonEventQueue::wait(int seconds, bool *top)
|
||||||
{
|
{
|
||||||
LOGDEB(("RclMonEventQueue::wait\n"));
|
MONDEB(("RclMonEventQueue::wait\n"));
|
||||||
if (!empty()) {
|
if (!empty()) {
|
||||||
LOGDEB(("RclMonEventQueue:: imm return\n"));
|
MONDEB(("RclMonEventQueue:: imm return\n"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,7 +109,7 @@ bool RclMonEventQueue::wait(int seconds, bool *top)
|
|||||||
pthread_cond_timedwait(&m_data->m_cond, &m_data->m_mutex, &to))) {
|
pthread_cond_timedwait(&m_data->m_cond, &m_data->m_mutex, &to))) {
|
||||||
if (err == ETIMEDOUT) {
|
if (err == ETIMEDOUT) {
|
||||||
*top = true;
|
*top = true;
|
||||||
LOGDEB(("RclMonEventQueue:: timeout\n"));
|
MONDEB(("RclMonEventQueue:: timeout\n"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
LOGERR(("RclMonEventQueue::wait:pthread_cond_timedwait failed"
|
LOGERR(("RclMonEventQueue::wait:pthread_cond_timedwait failed"
|
||||||
@ -123,23 +123,23 @@ bool RclMonEventQueue::wait(int seconds, bool *top)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LOGDEB(("RclMonEventQueue:: normal return\n"));
|
MONDEB(("RclMonEventQueue:: normal return\n"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RclMonEventQueue::lock()
|
bool RclMonEventQueue::lock()
|
||||||
{
|
{
|
||||||
LOGDEB(("RclMonEventQueue:: lock\n"));
|
MONDEB(("RclMonEventQueue:: lock\n"));
|
||||||
if (pthread_mutex_lock(&m_data->m_mutex)) {
|
if (pthread_mutex_lock(&m_data->m_mutex)) {
|
||||||
LOGERR(("RclMonEventQueue::lock: pthread_mutex_lock failed\n"));
|
LOGERR(("RclMonEventQueue::lock: pthread_mutex_lock failed\n"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
LOGDEB(("RclMonEventQueue:: lock return\n"));
|
MONDEB(("RclMonEventQueue:: lock return\n"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
bool RclMonEventQueue::unlock()
|
bool RclMonEventQueue::unlock()
|
||||||
{
|
{
|
||||||
LOGDEB(("RclMonEventQueue:: unlock\n"));
|
MONDEB(("RclMonEventQueue:: unlock\n"));
|
||||||
if (pthread_mutex_unlock(&m_data->m_mutex)) {
|
if (pthread_mutex_unlock(&m_data->m_mutex)) {
|
||||||
LOGERR(("RclMonEventQueue::lock: pthread_mutex_unlock failed\n"));
|
LOGERR(("RclMonEventQueue::lock: pthread_mutex_unlock failed\n"));
|
||||||
return false;
|
return false;
|
||||||
@ -168,7 +168,7 @@ bool RclMonEventQueue::ok()
|
|||||||
|
|
||||||
void RclMonEventQueue::setTerminate()
|
void RclMonEventQueue::setTerminate()
|
||||||
{
|
{
|
||||||
LOGDEB(("RclMonEventQueue:: setTerminate\n"));
|
MONDEB(("RclMonEventQueue:: setTerminate\n"));
|
||||||
lock();
|
lock();
|
||||||
m_data->m_ok = false;
|
m_data->m_ok = false;
|
||||||
pthread_cond_broadcast(&m_data->m_cond);
|
pthread_cond_broadcast(&m_data->m_cond);
|
||||||
@ -177,7 +177,7 @@ void RclMonEventQueue::setTerminate()
|
|||||||
|
|
||||||
bool RclMonEventQueue::pushEvent(const RclMonEvent &ev)
|
bool RclMonEventQueue::pushEvent(const RclMonEvent &ev)
|
||||||
{
|
{
|
||||||
LOGDEB(("RclMonEventQueue::pushEvent for %s\n", ev.m_path.c_str()));
|
MONDEB(("RclMonEventQueue::pushEvent for %s\n", ev.m_path.c_str()));
|
||||||
lock();
|
lock();
|
||||||
// It seems that a newer event is always correct to override any
|
// It seems that a newer event is always correct to override any
|
||||||
// older. TBVerified ?
|
// older. TBVerified ?
|
||||||
@ -318,7 +318,7 @@ bool startMonitor(RclConfig *conf, bool nofork)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (timedout) {
|
if (timedout) {
|
||||||
LOGDEB(("Monitor: queue wait timed out\n"));
|
MONDEB(("Monitor: queue wait timed out\n"));
|
||||||
// Timed out. there must not be much activity around here.
|
// Timed out. there must not be much activity around here.
|
||||||
// If anything was modified, process the end-of-indexing
|
// If anything was modified, process the end-of-indexing
|
||||||
// tasks: stemming and spelling database creations.
|
// tasks: stemming and spelling database creations.
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
#include "autoconfig.h"
|
#include "autoconfig.h"
|
||||||
#ifdef RCL_MONITOR
|
#ifdef RCL_MONITOR
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
static char rcsid[] = "@(#$Id: rclmonrcv.cpp,v 1.7 2006-10-25 10:52:02 dockes Exp $ (C) 2006 J.F.Dockes";
|
static char rcsid[] = "@(#$Id: rclmonrcv.cpp,v 1.8 2006-11-07 16:51:45 dockes Exp $ (C) 2006 J.F.Dockes";
|
||||||
#endif
|
#endif
|
||||||
/*
|
/*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
@ -78,7 +78,7 @@ public:
|
|||||||
if (ev.m_etyp != RclMonEvent::RCLEVT_NONE)
|
if (ev.m_etyp != RclMonEvent::RCLEVT_NONE)
|
||||||
m_queue->pushEvent(ev);
|
m_queue->pushEvent(ev);
|
||||||
} else {
|
} else {
|
||||||
LOGDEB(("rclMonRcvRun: no event pending\n"));
|
MONDEB(("rclMonRcvRun: no event pending\n"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -138,7 +138,7 @@ void *rclMonRcvRun(void *q)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Forever wait for monitoring events and add them to queue:
|
// Forever wait for monitoring events and add them to queue:
|
||||||
LOGDEB2(("rclMonRcvRun: waiting for events. q->ok() %d\n", queue->ok()));
|
MONDEB(("rclMonRcvRun: waiting for events. q->ok() %d\n", queue->ok()));
|
||||||
while (queue->ok() && mon->ok()) {
|
while (queue->ok() && mon->ok()) {
|
||||||
RclMonEvent ev;
|
RclMonEvent ev;
|
||||||
// Note: I could find no way to get the select
|
// Note: I could find no way to get the select
|
||||||
@ -233,7 +233,7 @@ bool RclFAM::addWatch(const string& path, bool isdir)
|
|||||||
{
|
{
|
||||||
if (!ok())
|
if (!ok())
|
||||||
return false;
|
return false;
|
||||||
LOGDEB(("RclFAM::addWatch: adding %s\n", path.c_str()));
|
MONDEB(("RclFAM::addWatch: adding %s\n", path.c_str()));
|
||||||
FAMRequest req;
|
FAMRequest req;
|
||||||
if (isdir) {
|
if (isdir) {
|
||||||
if (FAMMonitorDirectory(&m_conn, path.c_str(), &req, 0) != 0) {
|
if (FAMMonitorDirectory(&m_conn, path.c_str(), &req, 0) != 0) {
|
||||||
@ -256,14 +256,14 @@ bool RclFAM::getEvent(RclMonEvent& ev, int secs)
|
|||||||
{
|
{
|
||||||
if (!ok())
|
if (!ok())
|
||||||
return false;
|
return false;
|
||||||
LOGDEB2(("RclFAM::getEvent:\n"));
|
MONDEB(("RclFAM::getEvent:\n"));
|
||||||
|
|
||||||
fd_set readfds;
|
fd_set readfds;
|
||||||
int fam_fd = FAMCONNECTION_GETFD(&m_conn);
|
int fam_fd = FAMCONNECTION_GETFD(&m_conn);
|
||||||
FD_ZERO(&readfds);
|
FD_ZERO(&readfds);
|
||||||
FD_SET(fam_fd, &readfds);
|
FD_SET(fam_fd, &readfds);
|
||||||
|
|
||||||
LOGDEB(("RclFAM::getEvent: select\n"));
|
MONDEB(("RclFAM::getEvent: select\n"));
|
||||||
struct timeval timeout;
|
struct timeval timeout;
|
||||||
if (secs >= 0) {
|
if (secs >= 0) {
|
||||||
memset(&timeout, 0, sizeof(timeout));
|
memset(&timeout, 0, sizeof(timeout));
|
||||||
@ -276,23 +276,23 @@ bool RclFAM::getEvent(RclMonEvent& ev, int secs)
|
|||||||
return false;
|
return false;
|
||||||
} else if (ret == 0) {
|
} else if (ret == 0) {
|
||||||
// timeout
|
// timeout
|
||||||
LOGDEB(("RclFAM::getEvent: select timeout\n"));
|
MONDEB(("RclFAM::getEvent: select timeout\n"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOGDEB(("RclFAM::getEvent: select return\n"));
|
MONDEB(("RclFAM::getEvent: select return\n"));
|
||||||
|
|
||||||
if (!FD_ISSET(fam_fd, &readfds))
|
if (!FD_ISSET(fam_fd, &readfds))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
LOGDEB(("RclFAM::getEvent: call FAMNextEvent\n"));
|
MONDEB(("RclFAM::getEvent: call FAMNextEvent\n"));
|
||||||
FAMEvent fe;
|
FAMEvent fe;
|
||||||
if (FAMNextEvent(&m_conn, &fe) < 0) {
|
if (FAMNextEvent(&m_conn, &fe) < 0) {
|
||||||
LOGERR(("RclFAM::getEvent: FAMNextEvent failed, errno %d\n", errno));
|
LOGERR(("RclFAM::getEvent: FAMNextEvent failed, errno %d\n", errno));
|
||||||
close();
|
close();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
LOGDEB(("RclFAM::getEvent: FAMNextEvent returned\n"));
|
MONDEB(("RclFAM::getEvent: FAMNextEvent returned\n"));
|
||||||
|
|
||||||
map<int,string>::const_iterator it;
|
map<int,string>::const_iterator it;
|
||||||
if ((fe.filename[0] != '/') &&
|
if ((fe.filename[0] != '/') &&
|
||||||
@ -301,7 +301,7 @@ bool RclFAM::getEvent(RclMonEvent& ev, int secs)
|
|||||||
} else {
|
} else {
|
||||||
ev.m_path = fe.filename;
|
ev.m_path = fe.filename;
|
||||||
}
|
}
|
||||||
LOGDEB(("RclFAM::getEvent: %-12s %s\n",
|
MONDEB(("RclFAM::getEvent: %-12s %s\n",
|
||||||
event_name(fe.code), ev.m_path.c_str()));
|
event_name(fe.code), ev.m_path.c_str()));
|
||||||
|
|
||||||
switch (fe.code) {
|
switch (fe.code) {
|
||||||
@ -322,7 +322,7 @@ bool RclFAM::getEvent(RclMonEvent& ev, int secs)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case FAMMoved: /* Never generated it seems */
|
case FAMMoved: /* Never generated it seems */
|
||||||
LOGDEB(("RclFAM::getEvent: got move event !\n"));
|
LOGINFO(("RclFAM::getEvent: got move event !\n"));
|
||||||
ev.m_etyp = RclMonEvent::RCLEVT_MODIFY;
|
ev.m_etyp = RclMonEvent::RCLEVT_MODIFY;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -333,7 +333,8 @@ bool RclFAM::getEvent(RclMonEvent& ev, int secs)
|
|||||||
default:
|
default:
|
||||||
// Have to return something, this is different from an empty queue,
|
// Have to return something, this is different from an empty queue,
|
||||||
// esp if we are trying to empty it...
|
// esp if we are trying to empty it...
|
||||||
LOGDEB(("RclFAM::getEvent: got move event !\n"));
|
if (fe.code != FAMEndExist)
|
||||||
|
LOGDEB(("RclFAM::getEvent: got other event %d!\n", fe.code));
|
||||||
ev.m_etyp = RclMonEvent::RCLEVT_NONE;
|
ev.m_etyp = RclMonEvent::RCLEVT_NONE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -423,7 +424,7 @@ bool RclIntf::addWatch(const string& path, bool)
|
|||||||
{
|
{
|
||||||
if (!ok())
|
if (!ok())
|
||||||
return false;
|
return false;
|
||||||
LOGDEB(("RclIntf::addWatch: adding %s\n", path.c_str()));
|
MONDEB(("RclIntf::addWatch: adding %s\n", path.c_str()));
|
||||||
// CLOSE_WRITE is covered through MODIFY. CREATE is needed for mkdirs
|
// CLOSE_WRITE is covered through MODIFY. CREATE is needed for mkdirs
|
||||||
uint32_t mask = IN_MODIFY | IN_CREATE
|
uint32_t mask = IN_MODIFY | IN_CREATE
|
||||||
| IN_MOVED_FROM | IN_MOVED_TO
|
| IN_MOVED_FROM | IN_MOVED_TO
|
||||||
@ -448,7 +449,7 @@ bool RclIntf::getEvent(RclMonEvent& ev, int secs)
|
|||||||
if (!ok())
|
if (!ok())
|
||||||
return false;
|
return false;
|
||||||
ev.m_etyp = RclMonEvent::RCLEVT_NONE;
|
ev.m_etyp = RclMonEvent::RCLEVT_NONE;
|
||||||
LOGDEB2(("RclIntf::getEvent:\n"));
|
MONDEB(("RclIntf::getEvent:\n"));
|
||||||
|
|
||||||
if (m_evp == 0) {
|
if (m_evp == 0) {
|
||||||
fd_set readfds;
|
fd_set readfds;
|
||||||
@ -460,17 +461,17 @@ bool RclIntf::getEvent(RclMonEvent& ev, int secs)
|
|||||||
timeout.tv_sec = secs;
|
timeout.tv_sec = secs;
|
||||||
}
|
}
|
||||||
int ret;
|
int ret;
|
||||||
LOGDEB2(("RclIntf::getEvent: select\n"));
|
MONDEB(("RclIntf::getEvent: select\n"));
|
||||||
if ((ret=select(m_fd + 1, &readfds, 0, 0, secs >= 0 ? &timeout : 0)) < 0) {
|
if ((ret=select(m_fd + 1, &readfds, 0, 0, secs >= 0 ? &timeout : 0)) < 0) {
|
||||||
LOGERR(("RclIntf::getEvent: select failed, errno %d\n", errno));
|
LOGERR(("RclIntf::getEvent: select failed, errno %d\n", errno));
|
||||||
close();
|
close();
|
||||||
return false;
|
return false;
|
||||||
} else if (ret == 0) {
|
} else if (ret == 0) {
|
||||||
LOGDEB2(("RclIntf::getEvent: select timeout\n"));
|
MONDEB(("RclIntf::getEvent: select timeout\n"));
|
||||||
// timeout
|
// timeout
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
LOGDEB(("RclIntf::getEvent: select returned\n"));
|
MONDEB(("RclIntf::getEvent: select returned\n"));
|
||||||
|
|
||||||
if (!FD_ISSET(m_fd, &readfds))
|
if (!FD_ISSET(m_fd, &readfds))
|
||||||
return false;
|
return false;
|
||||||
@ -503,7 +504,7 @@ bool RclIntf::getEvent(RclMonEvent& ev, int secs)
|
|||||||
ev.m_path = path_cat(ev.m_path, evp->name);
|
ev.m_path = path_cat(ev.m_path, evp->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
LOGDEB(("RclIntf::getEvent: %-12s %s\n",
|
MONDEB(("RclIntf::getEvent: %-12s %s\n",
|
||||||
event_name(evp->mask), ev.m_path.c_str()));
|
event_name(evp->mask), ev.m_path.c_str()));
|
||||||
|
|
||||||
if (evp->mask & (IN_MODIFY | IN_MOVED_TO)) {
|
if (evp->mask & (IN_MODIFY | IN_MOVED_TO)) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user