Windows: fix interactions between GUI and monitor.
This commit is contained in:
parent
b5b48e4f50
commit
67e158b7f4
@ -52,6 +52,7 @@ using std::vector;
|
|||||||
#include "x11mon.h"
|
#include "x11mon.h"
|
||||||
#endif
|
#endif
|
||||||
#include "subtreelist.h"
|
#include "subtreelist.h"
|
||||||
|
#include "idxstatus.h"
|
||||||
|
|
||||||
typedef unsigned long mttcast;
|
typedef unsigned long mttcast;
|
||||||
|
|
||||||
@ -227,7 +228,6 @@ std::unique_lock<std::mutex> RclMonEventQueue::wait(int seconds, bool *top)
|
|||||||
return lock;
|
return lock;
|
||||||
}
|
}
|
||||||
|
|
||||||
int err;
|
|
||||||
if (seconds > 0) {
|
if (seconds > 0) {
|
||||||
if (top)
|
if (top)
|
||||||
*top = false;
|
*top = false;
|
||||||
@ -576,6 +576,10 @@ bool startMonitor(RclConfig *conf, int opts)
|
|||||||
o_reexec->removeArg("-n");
|
o_reexec->removeArg("-n");
|
||||||
o_reexec->reexec();
|
o_reexec->reexec();
|
||||||
}
|
}
|
||||||
|
if (!statusUpdater()->update(DbIxStatus::DBIXS_MONITOR, "")) {
|
||||||
|
LOGDEB("Monitor returning because stop request (stop file)\n");
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
LOGDEB("Rclmonprc: calling queue setTerminate\n");
|
LOGDEB("Rclmonprc: calling queue setTerminate\n");
|
||||||
rclEQ.setTerminate();
|
rclEQ.setTerminate();
|
||||||
|
|||||||
@ -34,11 +34,14 @@
|
|||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
static std::string recollindex;
|
||||||
|
|
||||||
// This is called from periodic100 if we started an indexer, or from
|
// This is called from periodic100 if we started an indexer, or from
|
||||||
// the rclmain idxstatus file watcher, every time the file changes.
|
// the rclmain idxstatus file watcher, every time the file changes.
|
||||||
void RclMain::updateIdxStatus()
|
// Returns true if a real time indexer is currently monitoring, false else.
|
||||||
|
bool RclMain::updateIdxStatus()
|
||||||
{
|
{
|
||||||
|
bool ret{false};
|
||||||
DbIxStatus status;
|
DbIxStatus status;
|
||||||
readIdxStatus(theconfig, status);
|
readIdxStatus(theconfig, status);
|
||||||
QString msg = tr("Indexing in progress: ");
|
QString msg = tr("Indexing in progress: ");
|
||||||
@ -51,7 +54,7 @@ void RclMain::updateIdxStatus()
|
|||||||
case DbIxStatus::DBIXS_STEMDB: phs=tr("Stemdb");break;
|
case DbIxStatus::DBIXS_STEMDB: phs=tr("Stemdb");break;
|
||||||
case DbIxStatus::DBIXS_CLOSING:phs=tr("Closing");break;
|
case DbIxStatus::DBIXS_CLOSING:phs=tr("Closing");break;
|
||||||
case DbIxStatus::DBIXS_DONE:phs=tr("Done");break;
|
case DbIxStatus::DBIXS_DONE:phs=tr("Done");break;
|
||||||
case DbIxStatus::DBIXS_MONITOR:phs=tr("Monitor");break;
|
case DbIxStatus::DBIXS_MONITOR:phs=tr("Monitor"); ret = true;break;
|
||||||
default: phs=tr("Unknown");break;
|
default: phs=tr("Unknown");break;
|
||||||
}
|
}
|
||||||
msg += phs + " ";
|
msg += phs + " ";
|
||||||
@ -83,20 +86,40 @@ void RclMain::updateIdxStatus()
|
|||||||
}
|
}
|
||||||
msg += QString::fromUtf8(mf.c_str());
|
msg += QString::fromUtf8(mf.c_str());
|
||||||
statusBar()->showMessage(msg, 4000);
|
statusBar()->showMessage(msg, 4000);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is called by a periodic timer to check the status of
|
// This is called by a periodic timer to check the status of
|
||||||
// indexing, a possible need to exit, and cleanup exited viewers
|
// indexing, a possible need to exit, and cleanup exited viewers
|
||||||
|
// We don't need thread locking, but we're not reentrant either
|
||||||
|
static bool periodic100busy(false);
|
||||||
|
class Periodic100Guard {
|
||||||
|
public:
|
||||||
|
Periodic100Guard() { periodic100busy = true;}
|
||||||
|
~Periodic100Guard() { periodic100busy = false;}
|
||||||
|
};
|
||||||
void RclMain::periodic100()
|
void RclMain::periodic100()
|
||||||
{
|
{
|
||||||
|
if (periodic100busy)
|
||||||
|
return;
|
||||||
|
Periodic100Guard guard;
|
||||||
|
|
||||||
LOGDEB2("Periodic100\n" );
|
LOGDEB2("Periodic100\n" );
|
||||||
|
if (recollindex.empty()) {
|
||||||
|
#ifdef _WIN32
|
||||||
|
// We are not in the PATH in general. make recollindex a full path
|
||||||
|
recollindex = path_cat(path_thisexecpath(), "recollindex");
|
||||||
|
#else
|
||||||
|
recollindex = "recollindex";
|
||||||
|
#endif
|
||||||
|
}
|
||||||
if (!m_idxreasontmp || !m_idxreasontmp->ok()) {
|
if (!m_idxreasontmp || !m_idxreasontmp->ok()) {
|
||||||
// We just store the pointer and let the tempfile cleaner deal
|
// We just store the pointer and let the tempfile cleaner deal
|
||||||
// with delete on exiting
|
// with delete on exiting
|
||||||
TempFile temp(".txt");
|
TempFile temp(".txt");
|
||||||
m_idxreasontmp = rememberTempFile(temp);
|
m_idxreasontmp = rememberTempFile(temp);
|
||||||
}
|
}
|
||||||
|
bool isMonitor{false};
|
||||||
if (m_idxproc) {
|
if (m_idxproc) {
|
||||||
// An indexing process was launched. If its' done, see status.
|
// An indexing process was launched. If its' done, see status.
|
||||||
int status;
|
int status;
|
||||||
@ -147,7 +170,7 @@ void RclMain::periodic100()
|
|||||||
// update/show status even if the status file did not
|
// update/show status even if the status file did not
|
||||||
// change (else the status line goes blank during
|
// change (else the status line goes blank during
|
||||||
// lengthy operations).
|
// lengthy operations).
|
||||||
updateIdxStatus();
|
isMonitor = updateIdxStatus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Update the "start/stop indexing" menu entry, can't be done from
|
// Update the "start/stop indexing" menu entry, can't be done from
|
||||||
@ -158,7 +181,7 @@ void RclMain::periodic100()
|
|||||||
fileToggleIndexingAction->setText(tr("Stop &Indexing"));
|
fileToggleIndexingAction->setText(tr("Stop &Indexing"));
|
||||||
fileToggleIndexingAction->setEnabled(true);
|
fileToggleIndexingAction->setEnabled(true);
|
||||||
fileStartMonitorAction->setEnabled(false);
|
fileStartMonitorAction->setEnabled(false);
|
||||||
fileBumpIndexingAction->setEnabled(false);
|
fileBumpIndexingAction->setEnabled(isMonitor);
|
||||||
fileRebuildIndexAction->setEnabled(false);
|
fileRebuildIndexAction->setEnabled(false);
|
||||||
actionSpecial_Indexing->setEnabled(false);
|
actionSpecial_Indexing->setEnabled(false);
|
||||||
periodictimer->setInterval(200);
|
periodictimer->setInterval(200);
|
||||||
@ -224,7 +247,7 @@ void RclMain::periodic100()
|
|||||||
bool RclMain::checkIdxPaths()
|
bool RclMain::checkIdxPaths()
|
||||||
{
|
{
|
||||||
string badpaths;
|
string badpaths;
|
||||||
vector<string> args{"recollindex", "-c", theconfig->getConfDir(), "-E"};
|
vector<string> args{recollindex, "-c", theconfig->getConfDir(), "-E"};
|
||||||
ExecCmd::backtick(args, badpaths);
|
ExecCmd::backtick(args, badpaths);
|
||||||
if (!badpaths.empty()) {
|
if (!badpaths.empty()) {
|
||||||
int rep = QMessageBox::warning(
|
int rep = QMessageBox::warning(
|
||||||
@ -240,9 +263,9 @@ bool RclMain::checkIdxPaths()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// This gets called when the "update index" action is activated. It executes
|
// This gets called when the "Update index/Stop indexing" action is
|
||||||
// the requested action, and disables the menu entry. This will be
|
// activated. It executes the requested action. The menu
|
||||||
// re-enabled by the indexing status check
|
// entry will be updated by the indexing status check
|
||||||
void RclMain::toggleIndexing()
|
void RclMain::toggleIndexing()
|
||||||
{
|
{
|
||||||
switch (m_indexerState) {
|
switch (m_indexerState) {
|
||||||
@ -266,7 +289,10 @@ void RclMain::toggleIndexing()
|
|||||||
if (rep == QMessageBox::Ok) {
|
if (rep == QMessageBox::Ok) {
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
// No simple way to signal the process. Use the stop file
|
// No simple way to signal the process. Use the stop file
|
||||||
::close(::creat(theconfig->getIdxStopFile().c_str(), 0666));
|
std::fstream ost;
|
||||||
|
if (!path_streamopen(theconfig->getIdxStopFile(), std::fstream::out, ost)) {
|
||||||
|
LOGSYSERR("toggleIndexing", "path_streamopen", theconfig->getIdxStopFile());
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
Pidfile pidfile(theconfig->getPidfile());
|
Pidfile pidfile(theconfig->getPidfile());
|
||||||
pid_t pid = pidfile.open();
|
pid_t pid = pidfile.open();
|
||||||
@ -293,7 +319,7 @@ void RclMain::toggleIndexing()
|
|||||||
args.push_back(m_idxreasontmp->filename());
|
args.push_back(m_idxreasontmp->filename());
|
||||||
}
|
}
|
||||||
m_idxproc = new ExecCmd;
|
m_idxproc = new ExecCmd;
|
||||||
m_idxproc->startExec("recollindex", args, false, false);
|
m_idxproc->startExec(recollindex, args, false, false);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case IXST_UNKNOWN:
|
case IXST_UNKNOWN:
|
||||||
@ -317,7 +343,7 @@ void RclMain::startMonitor()
|
|||||||
args.push_back("-mw");
|
args.push_back("-mw");
|
||||||
args.push_back("0");
|
args.push_back("0");
|
||||||
m_idxproc = new ExecCmd;
|
m_idxproc = new ExecCmd;
|
||||||
m_idxproc->startExec("recollindex", args, false, false);
|
m_idxproc->startExec(recollindex, args, false, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -361,13 +387,9 @@ void RclMain::rebuildIndex()
|
|||||||
LOGERR("RclMain::rebuildIndex: current indexer exec not null\n" );
|
LOGERR("RclMain::rebuildIndex: current indexer exec not null\n" );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int rep =
|
int rep = QMessageBox::warning(
|
||||||
QMessageBox::warning(0, tr("Erasing index"),
|
0, tr("Erasing index"), tr("Reset the index and start from scratch ?"),
|
||||||
tr("Reset the index and start "
|
QMessageBox::Ok, QMessageBox::Cancel, QMessageBox::NoButton);
|
||||||
"from scratch ?"),
|
|
||||||
QMessageBox::Ok,
|
|
||||||
QMessageBox::Cancel,
|
|
||||||
QMessageBox::NoButton);
|
|
||||||
if (rep == QMessageBox::Ok) {
|
if (rep == QMessageBox::Ok) {
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
// Under windows, it is necessary to close the db here,
|
// Under windows, it is necessary to close the db here,
|
||||||
@ -405,7 +427,7 @@ void RclMain::rebuildIndex()
|
|||||||
args.push_back(m_idxreasontmp->filename());
|
args.push_back(m_idxreasontmp->filename());
|
||||||
}
|
}
|
||||||
m_idxproc = new ExecCmd;
|
m_idxproc = new ExecCmd;
|
||||||
m_idxproc->startExec("recollindex", args, false, false);
|
m_idxproc->startExec(recollindex, args, false, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -548,8 +570,8 @@ void RclMain::specialIndex()
|
|||||||
args.push_back(top);
|
args.push_back(top);
|
||||||
}
|
}
|
||||||
m_idxproc = new ExecCmd;
|
m_idxproc = new ExecCmd;
|
||||||
LOGINFO("specialIndex: exec: " << execToString("recollindex", args) <<endl);
|
LOGINFO("specialIndex: exec: " << execToString(recollindex, args) <<endl);
|
||||||
m_idxproc->startExec("recollindex", args, false, false);
|
m_idxproc->startExec(recollindex, args, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RclMain::updateIdxForDocs(vector<Rcl::Doc>& docs)
|
void RclMain::updateIdxForDocs(vector<Rcl::Doc>& docs)
|
||||||
@ -570,7 +592,7 @@ void RclMain::updateIdxForDocs(vector<Rcl::Doc>& docs)
|
|||||||
}
|
}
|
||||||
args.insert(args.end(), paths.begin(), paths.end());
|
args.insert(args.end(), paths.begin(), paths.end());
|
||||||
m_idxproc = new ExecCmd;
|
m_idxproc = new ExecCmd;
|
||||||
m_idxproc->startExec("recollindex", args, false, false);
|
m_idxproc->startExec(recollindex, args, false, false);
|
||||||
// Call periodic100 to update the menu entries states
|
// Call periodic100 to update the menu entries states
|
||||||
periodic100();
|
periodic100();
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -176,7 +176,7 @@ public slots:
|
|||||||
virtual void zoomOut();
|
virtual void zoomOut();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
virtual void updateIdxStatus();
|
virtual bool updateIdxStatus();
|
||||||
virtual void onWebcacheDestroyed(QObject *);
|
virtual void onWebcacheDestroyed(QObject *);
|
||||||
virtual void onSSTypMenu(QAction *act);
|
virtual void onSSTypMenu(QAction *act);
|
||||||
virtual void onSSTypCMB(int);
|
virtual void onSSTypCMB(int);
|
||||||
|
|||||||
@ -1185,6 +1185,7 @@ ReExec::ReExec(const std::vector<std::string>& args)
|
|||||||
|
|
||||||
void ReExec::insertArgs(const vector<string>& args, int idx)
|
void ReExec::insertArgs(const vector<string>& args, int idx)
|
||||||
{
|
{
|
||||||
|
LOGDEB2("ReExec::insertArgs: args before [" << stringsToString(m_argv) << "]\n");
|
||||||
vector<string>::iterator it;
|
vector<string>::iterator it;
|
||||||
unsigned int cmpoffset = (unsigned int) - 1;
|
unsigned int cmpoffset = (unsigned int) - 1;
|
||||||
|
|
||||||
@ -1215,19 +1216,23 @@ void ReExec::insertArgs(const vector<string>& args, int idx)
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_argv.insert(it, args.begin(), args.end());
|
m_argv.insert(it, args.begin(), args.end());
|
||||||
|
LOGDEB2("ReExec::insertArgs: args after [" << stringsToString(m_argv) << "]\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReExec::removeArg(const string& arg)
|
void ReExec::removeArg(const string& arg)
|
||||||
{
|
{
|
||||||
|
LOGDEB2("ReExec::removeArg: args before [" << stringsToString(m_argv) << "]\n");
|
||||||
for (vector<string>::iterator it = m_argv.begin(); it != m_argv.end(); it++) {
|
for (vector<string>::iterator it = m_argv.begin(); it != m_argv.end(); it++) {
|
||||||
if (*it == arg) {
|
if (*it == arg) {
|
||||||
it = m_argv.erase(it);
|
it = m_argv.erase(it);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
LOGDEB2("ReExec::removeArg: args after [" << stringsToString(m_argv) << "]\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReExec::reexec()
|
void ReExec::reexec()
|
||||||
{
|
{
|
||||||
|
LOGDEB("ReExec::reexec: args [" << stringsToString(m_argv) << "]\n");
|
||||||
// Execute the atexit funcs
|
// Execute the atexit funcs
|
||||||
while (!m_atexitfuncs.empty()) {
|
while (!m_atexitfuncs.empty()) {
|
||||||
(m_atexitfuncs.top())();
|
(m_atexitfuncs.top())();
|
||||||
@ -1263,6 +1268,9 @@ void ReExec::reexec()
|
|||||||
//libclf_closefrom(3);
|
//libclf_closefrom(3);
|
||||||
|
|
||||||
auto ret = _wexecvp(cmd.get(), argv);
|
auto ret = _wexecvp(cmd.get(), argv);
|
||||||
LOGERR("_WEXECVP ["<<argv[0]<< "] FAILED: returned: " << ret << " errno " << errno << "\n");
|
LOGERR("_WEXECVP ["<<wchartoutf8(cmd.get())<< "] FAILED: returned: " << ret <<
|
||||||
std::cerr<<"_WEXECVP ["<<argv[0]<< "] FAILED: returned: " << ret << " errno " << errno << "\n";
|
" errno " << errno << "\n");
|
||||||
|
std::cerr<<"_WEXECVP ["<<wchartoutf8(cmd.get())<< "] FAILED: returned: " << ret <<
|
||||||
|
" errno " << errno << "\n";
|
||||||
|
_exit(1);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user