kit/Kit.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
New commits: commit 1d22f7bc548dc48c95390c6f23b67f1972825617 Author: Pranav Kant <pran...@collabora.co.uk> Date: Fri Jan 26 21:04:49 2018 +0530 kit: start spamming the logs when linking/copying is slowww This is sometimes the case in docker when the link operation 'copies up' things from lower layers to the working docker container's layer. In such cases, let the admin know. Change-Id: Ib72b67304a292c3832838379cc76bcb4a7268cb3 Reviewed-on: https://gerrit.libreoffice.org/48710 Reviewed-by: pranavk <pran...@collabora.co.uk> Tested-by: pranavk <pran...@collabora.co.uk> diff --git a/kit/Kit.cpp b/kit/Kit.cpp index f38af663..c853b3ed 100644 --- a/kit/Kit.cpp +++ b/kit/Kit.cpp @@ -120,6 +120,9 @@ namespace LinkOrCopyType linkOrCopyType; std::string sourceForLinkOrCopy; Path destinationForLinkOrCopy; + std::chrono::time_point<std::chrono::steady_clock> linkOrCopyStartTime; + bool linkOrCopyVerboseLogging = false; + unsigned slowLinkOrCopyLimitInSecs = 10; // after this much seconds, start spamming the logs bool shouldCopyDir(const char *path) { @@ -151,6 +154,18 @@ namespace if (strcmp(fpath, sourceForLinkOrCopy.c_str()) == 0) return 0; + if (!linkOrCopyVerboseLogging) + { + const auto durationInSecs = std::chrono::duration_cast<std::chrono::seconds>( + std::chrono::steady_clock::now() - linkOrCopyStartTime); + if (durationInSecs.count() > slowLinkOrCopyLimitInSecs) + { + LOG_WRN("Linking/copying files from " << sourceForLinkOrCopy << " to " << destinationForLinkOrCopy.toString() << + " is taking too much time. Enabling verbose link/copy logging at information level."); + linkOrCopyVerboseLogging = true; + } + } + assert(fpath[strlen(sourceForLinkOrCopy.c_str())] == '/'); const char *relativeOldPath = fpath + strlen(sourceForLinkOrCopy.c_str()) + 1; Path newPath(destinationForLinkOrCopy, Path(relativeOldPath)); @@ -160,6 +175,9 @@ namespace case FTW_F: case FTW_SLN: File(newPath.parent()).createDirectories(); + + if (linkOrCopyVerboseLogging) + LOG_INF("Linking file \"" << fpath << "\" to \"" << newPath.toString() << "\""); if (link(fpath, newPath.toString().c_str()) == -1) { LOG_SYS("link(\"" << fpath << "\", \"" << @@ -223,10 +241,16 @@ namespace if (sourceForLinkOrCopy.back() == '/') sourceForLinkOrCopy.pop_back(); destinationForLinkOrCopy = destination; + linkOrCopyStartTime = std::chrono::steady_clock::now(); if (nftw(source.c_str(), linkOrCopyFunction, 10, FTW_ACTIONRETVAL) == -1) { LOG_ERR("linkOrCopy: nftw() failed for '" << source << "'"); } + if (linkOrCopyVerboseLogging) + { + LOG_INF("Linking/Copying of files to " << destinationForLinkOrCopy.toString() << " finished."); + linkOrCopyVerboseLogging = false; + } } void dropCapability(cap_value_t capability) _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits