bgsave: Add SLEEPBACKGROUNDFORDEBUGGER environment variable.
Change-Id: I7284d03ddcd79a0848d1cca9b219e2ef96548511 Signed-off-by: Michael Meeks <michael.meeks@collabora.com>pull/8790/head
parent
a80477a16c
commit
030acb1a85
|
@ -957,6 +957,24 @@ namespace Util
|
|||
|
||||
assert(sameThread);
|
||||
}
|
||||
}
|
||||
|
||||
void sleepFromEnvIfSet(const char *domain, const char *envVar)
|
||||
{
|
||||
const char *value;
|
||||
if ((value = std::getenv(envVar)))
|
||||
{
|
||||
const size_t delaySecs = std::stoul(value);
|
||||
if (delaySecs > 0)
|
||||
{
|
||||
std::cerr << domain << ": Sleeping " << delaySecs
|
||||
<< " seconds to give you time to attach debugger to process "
|
||||
<< getpid() << std::endl
|
||||
<< "sudo gdb --pid=" << getpid() << std::endl;
|
||||
std::this_thread::sleep_for(std::chrono::seconds(delaySecs));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Util
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
|
|
|
@ -1509,6 +1509,9 @@ int main(int argc, char**argv)
|
|||
*/
|
||||
int safe_atoi(const char* p, int len);
|
||||
|
||||
/// Sleep based on count of seconds in env. var
|
||||
void sleepFromEnvIfSet(const char *domain, const char *envVar);
|
||||
|
||||
/// Close logs and forcefully exit with the given exit code.
|
||||
/// This calls std::_Exit, which terminates the program without cleaning up
|
||||
/// static instances (i.e. anything registered with `atexit' or `on_exit').
|
||||
|
|
|
@ -374,17 +374,7 @@ static void cleanupChildren()
|
|||
|
||||
void sleepForDebugger()
|
||||
{
|
||||
if (std::getenv("SLEEPKITFORDEBUGGER"))
|
||||
{
|
||||
const size_t delaySecs = std::stoul(std::getenv("SLEEPKITFORDEBUGGER"));
|
||||
if (delaySecs > 0)
|
||||
{
|
||||
std::cerr << "Kit: Sleeping " << delaySecs
|
||||
<< " seconds to give you time to attach debugger to process " << getpid()
|
||||
<< std::endl;
|
||||
std::this_thread::sleep_for(std::chrono::seconds(delaySecs));
|
||||
}
|
||||
}
|
||||
Util::sleepFromEnvIfSet("Kit", "SLEEPKITFORDEBUGGER");
|
||||
}
|
||||
|
||||
static int createLibreOfficeKit(const std::string& childRoot,
|
||||
|
@ -584,17 +574,7 @@ int forkit_main(int argc, char** argv)
|
|||
// * the user is a non-priviled user, the binary is not privileged
|
||||
// either (no caps set), and --disable-cool-user-checking was provided
|
||||
|
||||
if (std::getenv("SLEEPFORDEBUGGER"))
|
||||
{
|
||||
const size_t delaySecs = std::stoul(std::getenv("SLEEPFORDEBUGGER"));
|
||||
if (delaySecs > 0)
|
||||
{
|
||||
std::cerr << "Forkit: Sleeping " << delaySecs
|
||||
<< " seconds to give you time to attach debugger to process "
|
||||
<< getpid() << std::endl;
|
||||
std::this_thread::sleep_for(std::chrono::seconds(delaySecs));
|
||||
}
|
||||
}
|
||||
Util::sleepFromEnvIfSet("Forkit", "SLEEPFORDEBUGGER");
|
||||
|
||||
if (!Util::isKitInProcess())
|
||||
{
|
||||
|
|
|
@ -1425,6 +1425,8 @@ bool Document::forkToSave(const std::function<void()> &childSave, int viewId)
|
|||
childSocket.reset();
|
||||
// now we just have a single socket to our parent
|
||||
|
||||
Util::sleepFromEnvIfSet("KitBackgroundSave", "SLEEPBACKGROUNDFORDEBUGGER");
|
||||
|
||||
UnitKit::get().postBackgroundSaveFork();
|
||||
|
||||
// Hard drop our previous connections to coolwsd and shared wakeups.x
|
||||
|
|
|
@ -25,6 +25,11 @@ SLEEPKITFORDEBUGGER <seconds to sleep>
|
|||
to allow a 'sudo gdb' session to attach and debug that
|
||||
process.
|
||||
|
||||
SLEEPBACKGROUNDFORDEBUGGER <seconds to sleep>
|
||||
sleep <n> seconds in each kit spawned background save process
|
||||
after forking, to allow a 'sudo gdb' session to attach and debug
|
||||
that process.
|
||||
|
||||
COOL_STORAGE_COOKIE <key:value>
|
||||
Sets a cookie to all the requests made to storage. This is extremely useful for
|
||||
debugging WOPI implementations. For eg: Using XDebug with OwnCloud/NextCloud.
|
||||
|
@ -33,3 +38,6 @@ COOL_SERVE_FROM_FS
|
|||
If mentioned, files are not loaded into the memory on start, instead they are
|
||||
read from the filesystem. This can be helpful in COOL development
|
||||
where you can tweak it without restarting wsd.
|
||||
|
||||
COOL_FORCE_BGSAVE
|
||||
If set, force all saves to be done in a background kit process.
|
||||
|
|
Loading…
Reference in New Issue