lockfile: only compute and log once
This commit is contained in:
parent
2c60e382f8
commit
310d28a4a1
@ -1398,36 +1398,38 @@ string RclConfig::getIdxStatusFile() const
|
|||||||
// Thanks to user Madhu for this fix.
|
// Thanks to user Madhu for this fix.
|
||||||
string RclConfig::getPidfile() const
|
string RclConfig::getPidfile() const
|
||||||
{
|
{
|
||||||
string fn;
|
static string fn;
|
||||||
|
if (fn.empty()) {
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
const char *p = getenv("XDG_RUNTIME_DIR");
|
const char *p = getenv("XDG_RUNTIME_DIR");
|
||||||
string rundir;
|
string rundir;
|
||||||
if (nullptr == p) {
|
if (nullptr == p) {
|
||||||
// Problem is, we may have been launched outside the desktop, maybe by cron. Basing
|
// Problem is, we may have been launched outside the desktop, maybe by cron. Basing
|
||||||
// everything on XDG_RUNTIME_DIR was a mistake, sometimes resulting in different pidfiles
|
// everything on XDG_RUNTIME_DIR was a mistake, sometimes resulting in different pidfiles
|
||||||
// being used by recollindex instances. So explicitely test for /run/user/$uid, still
|
// being used by recollindex instances. So explicitely test for /run/user/$uid, still
|
||||||
// leaving open the remote possibility that XDG_RUNTIME_DIR would be set to something
|
// leaving open the remote possibility that XDG_RUNTIME_DIR would be set to something
|
||||||
// else...
|
// else...
|
||||||
rundir = path_cat("/run/user", lltodecstr(getuid()));
|
rundir = path_cat("/run/user", lltodecstr(getuid()));
|
||||||
if (path_isdir(rundir)) {
|
if (path_isdir(rundir)) {
|
||||||
p = rundir.c_str();
|
p = rundir.c_str();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (p) {
|
||||||
|
string base = path_canon(p);
|
||||||
|
string digest, hex;
|
||||||
|
string cfdir = path_canon(getConfDir());
|
||||||
|
path_catslash(cfdir);
|
||||||
|
MD5String(cfdir, digest);
|
||||||
|
MD5HexPrint(digest, hex);
|
||||||
|
fn = path_cat(base, "recoll-" + hex + "-index.pid");
|
||||||
|
goto out;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (p) {
|
|
||||||
string base = path_canon(p);
|
|
||||||
string digest, hex;
|
|
||||||
string cfdir = path_canon(getConfDir());
|
|
||||||
path_catslash(cfdir);
|
|
||||||
MD5String(cfdir, digest);
|
|
||||||
MD5HexPrint(digest, hex);
|
|
||||||
fn = path_cat(base, "recoll-" + hex + "-index.pid");
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
#endif // ! _WIN32
|
#endif // ! _WIN32
|
||||||
|
|
||||||
fn = path_cat(getCacheDir(), "index.pid");
|
fn = path_cat(getCacheDir(), "index.pid");
|
||||||
out:
|
out:
|
||||||
LOGINF("RclConfig: pid/lock file: " << fn << "\n");
|
LOGINF("RclConfig: pid/lock file: " << fn << "\n");
|
||||||
|
}
|
||||||
return fn;
|
return fn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user