Switch to unified view

a/src/index/recollindex.cpp b/src/index/recollindex.cpp
...
...
199
    config->getConfParam("monioniceclassdata", classdata);
199
    config->getConfParam("monioniceclassdata", classdata);
200
    rclionice(clss, classdata);
200
    rclionice(clss, classdata);
201
#endif
201
#endif
202
}
202
}
203
203
204
static void setMyPriority(const RclConfig *config)
205
{
206
#ifndef _WIN32
207
    if (setpriority(PRIO_PROCESS, 0, 20) != 0) {
208
        LOGINFO("recollindex: can't setpriority(), errno " << errno << "\n");
209
    }
210
    // Try to ionice. This does not work on all platforms
211
    rclIxIonice(config);
212
#endif
213
}
214
215
204
class MakeListWalkerCB : public FsTreeWalkerCB {
216
class MakeListWalkerCB : public FsTreeWalkerCB {
205
public:
217
public:
206
    MakeListWalkerCB(list<string>& files, const vector<string>& selpats)
218
    MakeListWalkerCB(list<string>& files, const vector<string>& selpats)
207
    : m_files(files), m_pats(selpats)
219
    : m_files(files), m_pats(selpats)
208
    {
220
    {
...
...
314
static bool checktopdirs(RclConfig *config, vector<string>& nonexist)
326
static bool checktopdirs(RclConfig *config, vector<string>& nonexist)
315
{
327
{
316
    vector<string> tdl;
328
    vector<string> tdl;
317
    if (!config->getConfParam("topdirs", &tdl)) {
329
    if (!config->getConfParam("topdirs", &tdl)) {
318
        cerr << "No 'topdirs' parameter in configuration\n";
330
        cerr << "No 'topdirs' parameter in configuration\n";
319
        LOGERR("recollindex:No 'topdirs' parameter in configuration\n");;
331
        LOGERR("recollindex:No 'topdirs' parameter in configuration\n");
320
        return false;
332
        return false;
321
    }
333
    }
322
334
335
    // If a restricted list for real-time monitoring exists check that
336
    // all entries are descendants from a topdir
337
    vector<string> mondirs;
338
    if (config->getConfParam("monitordirs", &mondirs)) {
339
        for (const auto& sub : mondirs) {
340
            bool found{false};
341
            for (const auto& top : tdl) {
342
                if (path_isdesc(top, sub)) {
343
                    found = true;
344
                    break;
345
                }
346
            }
347
            if (!found) {
348
                string s("Real time monitoring directory entry " + sub +
349
                         " is not part of the topdirs tree\n");
350
                cerr << s;
351
                LOGERR(s);
352
                return false;
353
            }
354
        }
355
    }
356
357
    
323
    for (vector<string>::iterator it = tdl.begin(); it != tdl.end(); it++) {
358
    for (vector<string>::iterator it = tdl.begin(); it != tdl.end(); it++) {
324
    *it = path_tildexpand(*it);
359
    *it = path_tildexpand(*it);
325
        if (!it->size() || !path_isabsolute(*it)) {
360
        if (!it->size() || !path_isabsolute(*it)) {
326
            if ((*it)[0] == '~') {
361
            if ((*it)[0] == '~') {
327
                cerr << "Tilde expansion failed: " << *it << endl;
362
                cerr << "Tilde expansion failed: " << *it << endl;
...
...
637
    updater = new MyUpdater(config);
672
    updater = new MyUpdater(config);
638
673
639
    // Log something at LOGINFO to reset the trace file. Else at level
674
    // Log something at LOGINFO to reset the trace file. Else at level
640
    // 3 it's not even truncated if all docs are up to date.
675
    // 3 it's not even truncated if all docs are up to date.
641
    LOGINFO("recollindex: starting up\n");
676
    LOGINFO("recollindex: starting up\n");
642
#ifndef _WIN32
677
    setMyPriority(config);
643
    if (setpriority(PRIO_PROCESS, 0, 20) != 0) {
644
        LOGINFO("recollindex: can't setpriority(), errno " << errno << "\n");
645
    }
678
    
646
    // Try to ionice. This does not work on all platforms
647
    rclIxIonice(config);
648
#endif
649
650
    if (op_flags & OPT_r) {
679
    if (op_flags & OPT_r) {
651
    if (argc != 1) 
680
    if (argc != 1) 
652
        Usage();
681
        Usage();
653
    string top = *argv++; argc--;
682
    string top = *argv++; argc--;
654
    bool status = recursive_index(config, top, selpatterns);
683
    bool status = recursive_index(config, top, selpatterns);
...
...
730
        }
759
        }
731
#endif
760
#endif
732
    }
761
    }
733
    // Need to rewrite pid, it changed
762
    // Need to rewrite pid, it changed
734
    pidfile.write_pid();
763
    pidfile.write_pid();
735
#ifndef _WIN32
736
        // Not too sure if I have to redo the nice thing after daemon(),
764
        // Not too sure if I have to redo the nice thing after daemon(),
737
        // can't hurt anyway (easier than testing on all platforms...)
765
        // can't hurt anyway (easier than testing on all platforms...)
738
        if (setpriority(PRIO_PROCESS, 0, 20) != 0) {
766
        setMyPriority(config);
739
            LOGINFO("recollindex: can't setpriority(), errno " << errno<< "\n");
740
        }
741
  // Try to ionice. This does not work on all platforms
742
  rclIxIonice(config);
743
#endif
744
767
745
    if (sleepsecs > 0) {
768
    if (sleepsecs > 0) {
746
        LOGDEB("recollindex: sleeping " << sleepsecs << "\n");
769
        LOGDEB("recollindex: sleeping " << sleepsecs << "\n");
747
        for (int i = 0; i < sleepsecs; i++) {
770
        for (int i = 0; i < sleepsecs; i++) {
748
          sleep(1);
771
          sleep(1);
...
...
751
        LOGDEB("X11 session went away during initial sleep period\n");
774
        LOGDEB("X11 session went away during initial sleep period\n");
752
        exit(0);
775
        exit(0);
753
          }
776
          }
754
        }
777
        }
755
    }
778
    }
779
756
    if (!(op_flags & OPT_n)) {
780
    if (!(op_flags & OPT_n)) {
757
        makeIndexerOrExit(config, inPlaceReset);
781
        makeIndexerOrExit(config, inPlaceReset);
758
        LOGDEB("Recollindex: initial indexing pass before monitoring\n");
782
        LOGDEB("Recollindex: initial indexing pass before monitoring\n");
759
        if (!confindexer->index(rezero, ConfIndexer::IxTAll, indexerFlags)
783
        if (!confindexer->index(rezero, ConfIndexer::IxTAll, indexerFlags)
760
                || stopindexing) {
784
                || stopindexing) {
...
...
774
        LOGINFO("recollindex: reexecuting with -n after initial full "
798
        LOGINFO("recollindex: reexecuting with -n after initial full "
775
                    "pass\n");
799
                    "pass\n");
776
        // Note that -n will be inside the reexec when we come
800
        // Note that -n will be inside the reexec when we come
777
        // back, but the monitor will explicitely strip it before
801
        // back, but the monitor will explicitely strip it before
778
        // starting a config change exec to ensure that we do a
802
        // starting a config change exec to ensure that we do a
779
        // purging pass in this case.
803
        // purging pass in this latter case (full restart).
780
        o_reexec->reexec();
804
        o_reexec->reexec();
781
#endif
805
#endif
782
    }
806
    }
807
783
        if (updater) {
808
        if (updater) {
784
        updater->status.phase = DbIxStatus::DBIXS_MONITOR;
809
        updater->status.phase = DbIxStatus::DBIXS_MONITOR;
785
        updater->status.fn.clear();
810
        updater->status.fn.clear();
786
        updater->update();
811
        updater->update();
787
    }
812
    }