make sure signals are only handled by the main thread. Fix bus error on rclmon exit (double delete)

This commit is contained in:
dockes
2007-05-21 13:30:22 +00:00
parent 28a06096b7
commit a5efd74c71
10 changed files with 74 additions and 42 deletions
+10 -3
View File
@@ -2,7 +2,7 @@
#ifdef RCL_MONITOR
#ifndef lint
static char rcsid[] = "@(#$Id: rclmonprc.cpp,v 1.11 2007-05-21 09:00:29 dockes Exp $ (C) 2006 J.F.Dockes";
static char rcsid[] = "@(#$Id: rclmonprc.cpp,v 1.12 2007-05-21 13:30:21 dockes Exp $ (C) 2006 J.F.Dockes";
#endif
/*
* This program is free software; you can redistribute it and/or modify
@@ -291,6 +291,7 @@ bool startMonitor(RclConfig *conf, int opts)
}
if (!rclEQ.lock()) {
LOGERR(("startMonitor: cant lock queue ???\n"));
return false;
}
LOGDEB(("start_monitoring: entering main loop\n"));
@@ -302,8 +303,11 @@ bool startMonitor(RclConfig *conf, int opts)
while (rclEQ.wait(2, &timedout)) {
// Queue is locked.
if (!rclEQ.ok())
if (!rclEQ.ok()) {
rclEQ.unlock();
break;
}
list<string> modified;
list<string> deleted;
@@ -339,7 +343,7 @@ bool startMonitor(RclConfig *conf, int opts)
didsomething = true;
}
// Recreate the auxiliary dbs every hour.
// Recreate the auxiliary dbs every hour at most.
const int auxinterval = 60 *60;
if (didsomething && time(0) - lastauxtime > auxinterval) {
lastauxtime = time(0);
@@ -355,6 +359,9 @@ bool startMonitor(RclConfig *conf, int opts)
// Lock queue before waiting again
rclEQ.lock();
}
rclEQ.setTerminate();
// Wait for receiver thread before returning
pthread_join(rcv_thrid, 0);
LOGDEB(("Monitor: returning\n"));
return true;
}
+4 -2
View File
@@ -1,7 +1,7 @@
#include "autoconfig.h"
#ifdef RCL_MONITOR
#ifndef lint
static char rcsid[] = "@(#$Id: rclmonrcv.cpp,v 1.10 2007-02-02 10:12:58 dockes Exp $ (C) 2006 J.F.Dockes";
static char rcsid[] = "@(#$Id: rclmonrcv.cpp,v 1.11 2007-05-21 13:30:21 dockes Exp $ (C) 2006 J.F.Dockes";
#endif
/*
* This program is free software; you can redistribute it and/or modify
@@ -25,6 +25,7 @@ static char rcsid[] = "@(#$Id: rclmonrcv.cpp,v 1.10 2007-02-02 10:12:58 dockes E
#include "debuglog.h"
#include "rclmon.h"
#include "rclinit.h"
#include "fstreewalk.h"
#include "indexer.h"
#include "pathut.h"
@@ -108,6 +109,7 @@ void *rclMonRcvRun(void *q)
RclMonEventQueue *queue = (RclMonEventQueue *)q;
LOGDEB(("rclMonRcvRun: running\n"));
recoll_threadinit();
// Create the fam/whatever interface object
RclMonitor *mon;
@@ -163,8 +165,8 @@ void *rclMonRcvRun(void *q)
}
}
LOGINFO(("rclMonRcvRun: exiting\n"));
queue->setTerminate();
LOGINFO(("rclMonRcvRun: monrcv thread routine returning\n"));
return 0;
}
+8 -11
View File
@@ -1,5 +1,5 @@
#ifndef lint
static char rcsid[] = "@(#$Id: recollindex.cpp,v 1.31 2007-02-02 10:09:10 dockes Exp $ (C) 2004 J.F.Dockes";
static char rcsid[] = "@(#$Id: recollindex.cpp,v 1.32 2007-05-21 13:30:21 dockes Exp $ (C) 2004 J.F.Dockes";
#endif
/*
* This program is free software; you can redistribute it and/or modify
@@ -74,8 +74,7 @@ static bool makeDbIndexer(RclConfig *config)
}
// Check if there is already an indexer for the right db
if (dbindexer && dbindexer->getDbDir().compare(dbdir)) {
delete dbindexer;
dbindexer = 0;
deleteZ(dbindexer);
}
if (!dbindexer)
@@ -199,10 +198,8 @@ static bool createstemdb(RclConfig *config, const string &lang)
static void cleanup()
{
delete confindexer;
confindexer = 0;
delete dbindexer;
dbindexer = 0;
deleteZ(confindexer);
deleteZ(dbindexer);
}
static const char *thisprog;
@@ -360,15 +357,15 @@ int main(int argc, const char **argv)
confindexer = new ConfIndexer(config, &updater);
confindexer->index(rezero);
delete confindexer;
deleteZ(confindexer);
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);
bool monret = startMonitor(config, opts);
MONDEB(("Monitor returned %d, exiting\n", monret));
exit(monret == false);
#endif // MONITOR
#ifdef RCL_USE_ASPELL