[Libreoffice-commits] online.git: loolwsd/Util.cpp
loolwsd/Util.cpp | 15 --- 1 file changed, 12 insertions(+), 3 deletions(-) New commits: commit 303d173ae10348433f9b0b845267a317cb69eff6 Author: Ashod Nakashian Date: Mon Nov 14 00:09:26 2016 -0500 loolwsd: gracefully shutdown on first CTRL+C then force termination on second Change-Id: I1c84663d10de8ece715a296eec284b74cdda69df Reviewed-on: https://gerrit.libreoffice.org/30834 Reviewed-by: Ashod Nakashian Tested-by: Ashod Nakashian diff --git a/loolwsd/Util.cpp b/loolwsd/Util.cpp index 2bc780c..11d19d1 100644 --- a/loolwsd/Util.cpp +++ b/loolwsd/Util.cpp @@ -199,14 +199,23 @@ namespace Util static void handleTerminationSignal(const int signal) { -if (!TerminationFlag) +if (!ShutdownFlag) { -TerminationFlag = true; +Log::signalLogPrefix(); +Log::signalLog(" Shutdown signal received: "); +Log::signalLog(signalName(signal)); +Log::signalLog("\n"); +ShutdownFlag = true; +return; +} +if (!TerminationFlag) +{ Log::signalLogPrefix(); -Log::signalLog(" Termination signal received: "); +Log::signalLog(" Forced-Termination signal received: "); Log::signalLog(signalName(signal)); Log::signalLog("\n"); +TerminationFlag = true; } } ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] online.git: loolwsd/Util.cpp
loolwsd/Util.cpp |7 +++ 1 file changed, 7 insertions(+) New commits: commit f3d5b73c4e4e3879b036e8202a3486cb9658ef51 Author: Ashod Nakashian Date: Sun Nov 6 10:50:43 2016 -0500 loolwsd: sleep more with LOOL_DEBUG after dumping stacktrace Change-Id: I52d764634af3faa0b08d7c4ff7483e0dcc1db312 Reviewed-on: https://gerrit.libreoffice.org/30630 Reviewed-by: Ashod Nakashian Tested-by: Ashod Nakashian diff --git a/loolwsd/Util.cpp b/loolwsd/Util.cpp index ffcbf03..1b9a63c 100644 --- a/loolwsd/Util.cpp +++ b/loolwsd/Util.cpp @@ -404,6 +404,7 @@ namespace Util if (std::getenv("LOOL_DEBUG")) { Log::signalLog(FatalGdbString); +LOG_ERR("Sleeping 30s to allow debugging."); sleep(30); } @@ -444,6 +445,12 @@ namespace Util } } +if (std::getenv("LOOL_DEBUG")) +{ +LOG_ERR("Sleeping 30s to allow debugging."); +sleep(30); +} + // let default handler process the signal kill(Poco::Process::id(), signal); } ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] online.git: loolwsd/Util.cpp loolwsd/Util.hpp
loolwsd/Util.cpp |2 +- loolwsd/Util.hpp |2 +- 2 files changed, 2 insertions(+), 2 deletions(-) New commits: commit 3dbaae7f448f35fff443e9a13347cd7ea1d82285 Author: Miklos Vajna Date: Mon Oct 3 08:38:01 2016 +0200 Util: avoid unnecessary copy Change-Id: I773cc9bafc1593e125af2dbcd2471daf4685d125 diff --git a/loolwsd/Util.cpp b/loolwsd/Util.cpp index add0fdd..548698a 100644 --- a/loolwsd/Util.cpp +++ b/loolwsd/Util.cpp @@ -157,7 +157,7 @@ namespace Util return std::getenv("DISPLAY") != nullptr; } -bool saveDataToFileSafely(std::string fileName, const char *data, size_t size) +bool saveDataToFileSafely(const std::string& fileName, const char *data, size_t size) { const auto tempFileName = fileName + ".temp"; std::fstream outStream(tempFileName, std::ios::out); diff --git a/loolwsd/Util.hpp b/loolwsd/Util.hpp index 935264e..ffb269d 100644 --- a/loolwsd/Util.hpp +++ b/loolwsd/Util.hpp @@ -54,7 +54,7 @@ namespace Util // if everything goes well. In case of any error, both the destination file (if it already // exists) and the temporary file (if was created, or existed already) are removed. Return true // if everything succeeded. -bool saveDataToFileSafely(std::string fileName, const char *data, size_t size); +bool saveDataToFileSafely(const std::string& fileName, const char *data, size_t size); // We work around some of the mess of using the same sources both on the server side and in unit // tests with conditional compilation based on BUILDING_TESTS. ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] online.git: loolwsd/Util.cpp
loolwsd/Util.cpp |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) New commits: commit e7d587d69460102f6ba690134c0ed3becc846e23 Author: Tor Lillqvist Date: Thu Sep 22 14:35:16 2016 +0300 Don't use << to write a non-nul-terminated naked char pointer diff --git a/loolwsd/Util.cpp b/loolwsd/Util.cpp index 6599959..0d137c4 100644 --- a/loolwsd/Util.cpp +++ b/loolwsd/Util.cpp @@ -87,7 +87,7 @@ namespace rng { std::stringstream ss; Poco::Base64Encoder b64(ss); -b64 << getBytes(length).data(); +b64.write(getBytes(length).data(), length); return ss.str().substr(0, length); } ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] online.git: loolwsd/Util.cpp loolwsd/Util.hpp
loolwsd/Util.cpp |2 +- loolwsd/Util.hpp |2 +- 2 files changed, 2 insertions(+), 2 deletions(-) New commits: commit 5e1b21089117a8df25003879ad7cbf46dc588e43 Author: Miklos Vajna Date: Fri Jun 17 09:18:26 2016 +0200 Util: pass by const ref diff --git a/loolwsd/Util.cpp b/loolwsd/Util.cpp index 3920ae1..6224534 100644 --- a/loolwsd/Util.cpp +++ b/loolwsd/Util.cpp @@ -128,7 +128,7 @@ namespace Util return name; } -std::string getTempFilePath(const std::string srcDir, const std::string& srcFilename) +std::string getTempFilePath(const std::string& srcDir, const std::string& srcFilename) { const std::string srcPath = srcDir + '/' + srcFilename; const std::string dstPath = Poco::Path::temp() + encodeId(rng::getNext()) + '_' + srcFilename; diff --git a/loolwsd/Util.hpp b/loolwsd/Util.hpp index b3065a4..fd76c54 100644 --- a/loolwsd/Util.hpp +++ b/loolwsd/Util.hpp @@ -82,7 +82,7 @@ namespace Util /// Primarily used by tests to avoid tainting the originals. /// srcDir shouldn't end with '/' and srcFilename shouldn't contain '/'. /// Returns the created file path. -std::string getTempFilePath(const std::string srcDir, const std::string& srcFilename); +std::string getTempFilePath(const std::string& srcDir, const std::string& srcFilename); /// Returns the name of the signal. const char *signalName(int signo); ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] online.git: loolwsd/Util.cpp
loolwsd/Util.cpp |6 +- 1 file changed, 1 insertion(+), 5 deletions(-) New commits: commit 6b1a57c9eb3122135452a8053c512091e6f9c505 Author: Ashod Nakashian Date: Sun Jun 5 20:34:24 2016 -0400 loolwsd: improved random directory generator Change-Id: I611debe9cd33b8b15c2fab3c49ad19cc6ad6a995 Reviewed-on: https://gerrit.libreoffice.org/25946 Reviewed-by: Ashod Nakashian Tested-by: Ashod Nakashian diff --git a/loolwsd/Util.cpp b/loolwsd/Util.cpp index 78a90f0..f6bfa78 100644 --- a/loolwsd/Util.cpp +++ b/loolwsd/Util.cpp @@ -95,10 +95,7 @@ namespace rng /// file/directory names. std::string getFilename(const size_t length) { -std::stringstream ss; -Poco::Base64Encoder b64(ss); -b64 << getBytes(length).data(); -std::string s = ss.str(); +std::string s = getB64String(length); std::replace(s.begin(), s.end(), '/', '_'); return s.substr(0, length); } @@ -126,7 +123,6 @@ namespace Util /// Create a secure, random directory path. std::string createRandomDir(const std::string& path) { -Poco::File(path).createDirectories(); const auto name = rng::getFilename(64); Poco::File(Poco::Path(path, name)).createDirectories(); return name; ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] online.git: loolwsd/Util.cpp loolwsd/Util.hpp
loolwsd/Util.cpp | 10 ++ loolwsd/Util.hpp | 12 +--- 2 files changed, 11 insertions(+), 11 deletions(-) New commits: commit 68b8b2af4f154f99612762c1ff2d7b2197a23162 Author: Ashod Nakashian Date: Fri May 13 08:44:22 2016 -0400 loolwsd: improve temp file creation and delayed delete Change-Id: I174b87f1aceaacee58121bc60edb420004e69c44 Reviewed-on: https://gerrit.libreoffice.org/24967 Reviewed-by: Ashod Nakashian Tested-by: Ashod Nakashian diff --git a/loolwsd/Util.cpp b/loolwsd/Util.cpp index 519cb66..a814ae2 100644 --- a/loolwsd/Util.cpp +++ b/loolwsd/Util.cpp @@ -36,6 +36,7 @@ #include #include #include +#include #include #include "Common.hpp" @@ -127,6 +128,15 @@ namespace Util } } +std::string getTempFilePath(const std::string srcDir, const std::string& srcFilename) +{ +const std::string srcPath = srcDir + '/' + srcFilename; +const std::string dstPath = Poco::Path::temp() + encodeId(rng::getNext()) + '_' + srcFilename; +Poco::File(srcPath).copyTo(dstPath); +Poco::TemporaryFile::registerForDeletion(dstPath); +return dstPath; +} + bool windowingAvailable() { return std::getenv("DISPLAY") != nullptr; diff --git a/loolwsd/Util.hpp b/loolwsd/Util.hpp index 28cdb94..5340899 100644 --- a/loolwsd/Util.hpp +++ b/loolwsd/Util.hpp @@ -90,17 +90,7 @@ namespace Util /// Primarily used by tests to avoid tainting the originals. /// srcDir shouldn't end with '/' and srcFilename shouldn't contain '/'. /// Returns the created file path. -inline -std::string getTempFilePath(const std::string srcDir, const std::string& srcFilename) -{ -const std::string srcPath = srcDir + '/' + srcFilename; - -std::string dstPath = std::tmpnam(nullptr); -dstPath += '_' + srcFilename; - -Poco::File(srcPath).copyTo(dstPath); -return dstPath; -} +std::string getTempFilePath(const std::string srcDir, const std::string& srcFilename); /// Returns the name of the signal. const char *signalName(int signo); ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] online.git: loolwsd/Util.cpp
loolwsd/Util.cpp |5 - 1 file changed, 4 insertions(+), 1 deletion(-) New commits: commit 5871ef32a946d1f33e276700102d7f8e8217ad2c Author: Ashod Nakashian Date: Fri Apr 29 23:08:32 2016 -0400 loolwsd: log the pid in the backtrace Change-Id: Ic0565f266f1ad56d855a76fb42fac8066066fd45 Reviewed-on: https://gerrit.libreoffice.org/24526 Reviewed-by: Ashod Nakashian Tested-by: Ashod Nakashian diff --git a/loolwsd/Util.cpp b/loolwsd/Util.cpp index 77cfb3d..519cb66 100644 --- a/loolwsd/Util.cpp +++ b/loolwsd/Util.cpp @@ -291,6 +291,9 @@ namespace Util sigaction(signal, &action, NULL); +char header[32]; +sprintf(header, "Backtrace %d:\n", getpid()); + const int maxSlots = 50; void *backtraceBuffer[maxSlots]; int numSlots = backtrace(backtraceBuffer, maxSlots); @@ -300,7 +303,7 @@ namespace Util if (symbols != NULL) { struct iovec ioVector[maxSlots*2+1]; -ioVector[0].iov_base = (void*)"Backtrace:\n"; +ioVector[0].iov_base = (void*)header; ioVector[0].iov_len = std::strlen((const char*)ioVector[0].iov_base); for (int i = 0; i < numSlots; i++) { ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] online.git: loolwsd/Util.cpp loolwsd/Util.hpp
loolwsd/Util.cpp | 14 -- loolwsd/Util.hpp |2 -- 2 files changed, 16 deletions(-) New commits: commit a25b7ad712c800aad873a84351c30abd388543cb Author: Tor Lillqvist Date: Mon Apr 25 11:23:08 2016 +0300 Bin unused Util::createRandomFile() diff --git a/loolwsd/Util.cpp b/loolwsd/Util.cpp index aef31fe..77cfb3d 100644 --- a/loolwsd/Util.cpp +++ b/loolwsd/Util.cpp @@ -127,20 +127,6 @@ namespace Util } } -std::string createRandomFile(const std::string& path) -{ -Poco::File(path).createDirectories(); -for (;;) -{ -const auto name = Util::encodeId(rng::getNext()); -Poco::File file(Poco::Path(path, name)); -if (file.createFile()) -{ -return name; -} -} -} - bool windowingAvailable() { return std::getenv("DISPLAY") != nullptr; diff --git a/loolwsd/Util.hpp b/loolwsd/Util.hpp index ff1b877..00cf54c 100644 --- a/loolwsd/Util.hpp +++ b/loolwsd/Util.hpp @@ -45,8 +45,6 @@ namespace Util /// Creates a randomly name directory within path and returns the name. std::string createRandomDir(const std::string& path); -/// Creates a randomly name file within path and returns the name. -std::string createRandomFile(const std::string& path); bool windowingAvailable(); ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] online.git: loolwsd/Util.cpp loolwsd/Util.hpp
loolwsd/Util.cpp | 28 loolwsd/Util.hpp |3 --- 2 files changed, 31 deletions(-) New commits: commit 1bd6cdde3b441ced6f93a231d699ea9483002170 Author: Tor Lillqvist Date: Thu Apr 14 11:35:38 2016 +0300 Util::getSignalStatus() is unused Good, its semantics was a bit odd anyway. diff --git a/loolwsd/Util.cpp b/loolwsd/Util.cpp index 2162b26..eaea899 100644 --- a/loolwsd/Util.cpp +++ b/loolwsd/Util.cpp @@ -491,34 +491,6 @@ namespace Util strncpy(FatalGdbString, streamStr.c_str(), sizeof(FatalGdbString)); } -int getSignalStatus(const int code) -{ -int retVal; - -switch (code) -{ -case SIGSEGV: -case SIGBUS: -case SIGABRT: -case SIGILL: -case SIGFPE: -case SIGTERM: -case SIGINT: -case SIGQUIT: -case SIGHUP: -retVal = EXIT_FAILURE; -break; - -// Why are other signals treated as success? Will this function ever be called when a -// child was *not* terminated by a signal? -default: -retVal = EXIT_SUCCESS; -break; -} - -return retVal; -} - void requestTermination(const Poco::Process::PID& pid) { try diff --git a/loolwsd/Util.hpp b/loolwsd/Util.hpp index e56528d..109a78a 100644 --- a/loolwsd/Util.hpp +++ b/loolwsd/Util.hpp @@ -101,9 +101,6 @@ namespace Util void setTerminationSignals(); void setFatalSignals(); -/// Returns EXIT_SUCCESS or EXIT_FAILURE from -int getSignalStatus(const int code); - void requestTermination(const Poco::Process::PID& pid); int getMemoryUsage(const Poco::Process::PID nPid); ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] online.git: loolwsd/Util.cpp
loolwsd/Util.cpp |4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) New commits: commit ee1e036aa9d3ed41a0d766935f1ca4a8c944173d Author: Miklos Vajna Date: Mon Apr 11 09:12:59 2016 +0200 Util: strcpy -> strncpy Change-Id: I03f50f4e5e7f404364fdf90197750bf7cd762c9c diff --git a/loolwsd/Util.cpp b/loolwsd/Util.cpp index c26e63b..c6fae82 100644 --- a/loolwsd/Util.cpp +++ b/loolwsd/Util.cpp @@ -148,7 +148,7 @@ namespace Log << std::setw(5) << std::setfill('0') << Poco::Process::id(); Source.id = oss.str(); assert (sizeof (LogPrefix) > strlen(oss.str().c_str()) + 1); -strcpy(LogPrefix, oss.str().c_str()); +strncpy(LogPrefix, oss.str().c_str(), sizeof(LogPrefix)); auto channel = (isatty(fileno(stdout)) || std::getenv("LOOL_LOGCOLOR") ? static_cast(new Poco::ColorConsoleChannel()) @@ -488,7 +488,7 @@ namespace Util << Poco::Process::id() << "\n"; std::string streamStr = stream.str(); assert (sizeof (FatalGdbString) > strlen(streamStr.c_str()) + 1); -strcpy(FatalGdbString, streamStr.c_str()); +strncpy(FatalGdbString, streamStr.c_str(), sizeof(FatalGdbString)); } int getChildStatus(const int code) ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] online.git: loolwsd/Util.cpp
loolwsd/Util.cpp |6 +- 1 file changed, 5 insertions(+), 1 deletion(-) New commits: commit e5846ee2ccab145e68865e13c890208a3dfdc7ec Author: Ashod Nakashian Date: Sat Apr 9 15:40:51 2016 -0400 loolwsd: supress unused-result and log error Change-Id: I0ca04d5d9e18fdda6c2dca29386dbcc9a6df7784 Reviewed-on: https://gerrit.libreoffice.org/23941 Reviewed-by: Ashod Nakashian Tested-by: Ashod Nakashian diff --git a/loolwsd/Util.cpp b/loolwsd/Util.cpp index f60f9a0..c26e63b 100644 --- a/loolwsd/Util.cpp +++ b/loolwsd/Util.cpp @@ -454,7 +454,11 @@ namespace Util ioVector[1+i*2+1].iov_base = (void*)"\n"; ioVector[1+i*2+1].iov_len = 1; } -writev(STDERR_FILENO, ioVector, numSlots*2+1); + +if (writev(STDERR_FILENO, ioVector, numSlots*2+1) == -1) +{ +Log::syserror("Failed to dump backtrace to stderr."); +} } } ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] online.git: loolwsd/Util.cpp loolwsd/Util.hpp
loolwsd/Util.cpp |8 loolwsd/Util.hpp |2 +- 2 files changed, 5 insertions(+), 5 deletions(-) New commits: commit 7d82e059a227f6960785ee6a92ebe68b53d0e7b3 Author: Tor Lillqvist Date: Fri Apr 8 16:06:39 2016 +0300 Make Util::signalName() return a const char *instead Makes its use in handleTerminationSignal() and handleFatalSignal() less complicated. diff --git a/loolwsd/Util.cpp b/loolwsd/Util.cpp index 77c8cdb..f60f9a0 100644 --- a/loolwsd/Util.cpp +++ b/loolwsd/Util.cpp @@ -303,7 +303,7 @@ namespace Util return true; } -std::string signalName(const int signo) +const char *signalName(const int signo) { switch (signo) { @@ -359,7 +359,7 @@ namespace Util #endif #undef CASE default: -return std::to_string(signo); +return "unknown"; } } @@ -393,7 +393,7 @@ namespace Util log_signal(LogPrefix); log_signal(" Termination signal received: "); -log_signal(signalName(signal).c_str()); +log_signal(signalName(signal)); log_signal("\n"); } } @@ -419,7 +419,7 @@ namespace Util { log_signal(LogPrefix); log_signal(" Fatal signal received: "); -log_signal(signalName(signal).c_str()); +log_signal(signalName(signal)); log_signal("\n"); if (std::getenv("LOOL_DEBUG")) diff --git a/loolwsd/Util.hpp b/loolwsd/Util.hpp index 008d02a..09c63bd 100644 --- a/loolwsd/Util.hpp +++ b/loolwsd/Util.hpp @@ -113,7 +113,7 @@ namespace Util } /// Returns the name of the signal. -std::string signalName(int signo); +const char *signalName(int signo); /// Trap signals to cleanup and exit the process gracefully. void setTerminationSignals(); ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] online.git: loolwsd/Util.cpp
loolwsd/Util.cpp |1 + 1 file changed, 1 insertion(+) New commits: commit c034165a9059b1a83e3ebc70d4568e5a05487cfd Author: Miklos Vajna Date: Thu Apr 7 12:12:15 2016 +0200 Util: avoid leaking the channel Poco::Channel is reference counted, but the initial refcount is 1, so we need to release channel in order to have it deleted when Poco::Logger releases it. Calls to Poco::Logger::shutdown() are still missing though (from forkit/kit/wsd). Change-Id: I12ab32047d32e55902c60639d71eb6ef30ffa3bd diff --git a/loolwsd/Util.cpp b/loolwsd/Util.cpp index 678b1d7..5e2bd92 100644 --- a/loolwsd/Util.cpp +++ b/loolwsd/Util.cpp @@ -152,6 +152,7 @@ namespace Log ? static_cast(new Poco::ColorConsoleChannel()) : static_cast(new Poco::ConsoleChannel())); auto& logger = Poco::Logger::create(Source.name, channel, Poco::Message::PRIO_TRACE); +channel->release(); // Configure the logger. // TODO: This should come from a file. ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] online.git: loolwsd/Util.cpp
loolwsd/Util.cpp |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) New commits: commit 05f8757f1ded716e67382f25b4575c06984b2163 Author: Ashod Nakashian Date: Wed Mar 9 08:22:31 2016 -0500 loolwsd: colored logs enabled automatically in tty It is desirable to have colored logs when running loolwsd in a terminal, but not redirecting its output to a file. Outputting to a terminal is now detected and colored logs are automatically enabled. To force colored logs in files as well, define LOOL_LOGCOLOR in the environ. The output color codes can then be processed using, f.e., `less -r`. Change-Id: I09fbee4441f210d814ac5ad23dd99d1c33b560b7 Reviewed-on: https://gerrit.libreoffice.org/23080 Reviewed-by: Ashod Nakashian Tested-by: Ashod Nakashian diff --git a/loolwsd/Util.cpp b/loolwsd/Util.cpp index ee7aaca..78e9356 100644 --- a/loolwsd/Util.cpp +++ b/loolwsd/Util.cpp @@ -115,7 +115,7 @@ namespace Log << std::setw(5) << std::setfill('0') << Poco::Process::id(); SourceId = oss.str(); -auto channel = (std::getenv("LOOL_LOGCOLOR") +auto channel = (isatty(fileno(stdout)) || std::getenv("LOOL_LOGCOLOR") ? static_cast(new Poco::ColorConsoleChannel()) : static_cast(new Poco::ConsoleChannel())); auto& logger = Poco::Logger::create(SourceName, channel, Poco::Message::PRIO_INFORMATION); ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] online.git: loolwsd/Util.cpp
loolwsd/Util.cpp |5 - 1 file changed, 4 insertions(+), 1 deletion(-) New commits: commit 18a224b4135457ca59cb17c962ccb9c8c8e7c510 Author: Ashod Nakashian Date: Tue Mar 8 19:19:41 2016 -0500 loolwsd: Color logs can be enabled by defining LOOL_LOGCOLOR envar Change-Id: I12a38562f05c5d0b5d1c970a4b67240167322daf Reviewed-on: https://gerrit.libreoffice.org/23051 Reviewed-by: Ashod Nakashian Tested-by: Ashod Nakashian diff --git a/loolwsd/Util.cpp b/loolwsd/Util.cpp index e4d1352..ee7aaca 100644 --- a/loolwsd/Util.cpp +++ b/loolwsd/Util.cpp @@ -115,7 +115,10 @@ namespace Log << std::setw(5) << std::setfill('0') << Poco::Process::id(); SourceId = oss.str(); -auto& logger = Poco::Logger::create(SourceName, new Poco::ConsoleChannel(), Poco::Message::PRIO_INFORMATION); +auto channel = (std::getenv("LOOL_LOGCOLOR") + ? static_cast(new Poco::ColorConsoleChannel()) + : static_cast(new Poco::ConsoleChannel())); +auto& logger = Poco::Logger::create(SourceName, channel, Poco::Message::PRIO_INFORMATION); // Configure the logger. // TODO: This should come from a file. ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] online.git: loolwsd/Util.cpp
loolwsd/Util.cpp |4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) New commits: commit cdb0c08bb89e5e7d8c5237beeed0e39513d2b481 Author: Tor Lillqvist Date: Tue Mar 1 15:27:36 2016 +0200 Let's be consistent diff --git a/loolwsd/Util.cpp b/loolwsd/Util.cpp index 220f6c1..fab7a06 100644 --- a/loolwsd/Util.cpp +++ b/loolwsd/Util.cpp @@ -50,7 +50,7 @@ extern "C" std::vector *outputp = (std::vector *) png_get_io_ptr(png_ptr); const size_t oldsize = outputp->size(); outputp->resize(oldsize + length); -memcpy(outputp->data() + oldsize, data, length); +std::memcpy(outputp->data() + oldsize, data, length); } static void user_flush_fn(png_structp) @@ -443,7 +443,7 @@ namespace Util << Util::signalName(signal) << " " << strsignal(signal) << Log::end; -if (getenv("LOOL_DEBUG")) +if (std::getenv("LOOL_DEBUG")) { Log::error() << "\nSegfault! Attach debugger with:\n" << "sudo gdb --pid=" << Poco::Process::id() << "\n or \n" ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] online.git: loolwsd/Util.cpp loolwsd/Util.hpp
loolwsd/Util.cpp | 134 +++ loolwsd/Util.hpp | 16 +++--- 2 files changed, 75 insertions(+), 75 deletions(-) New commits: commit e9de06842328a7b5bef17a1c21a7ce777851c851 Author: Henry Castro Date: Thu Feb 18 12:59:25 2016 -0400 loolwsd: fixes coding style naming convention rules in Util files diff --git a/loolwsd/Util.cpp b/loolwsd/Util.cpp index 697c1b5..33738de 100644 --- a/loolwsd/Util.cpp +++ b/loolwsd/Util.cpp @@ -351,71 +351,71 @@ namespace Util } } -ssize_t writeFIFO(int nPipe, const char* pBuffer, ssize_t nSize) +ssize_t writeFIFO(int pipe, const char* buffer, ssize_t size) { -ssize_t nBytes = -1; -ssize_t nCount = 0; +ssize_t bytes = -1; +ssize_t count = 0; while(true) { -nBytes = write(nPipe, pBuffer + nCount, nSize - nCount); -if (nBytes < 0) +bytes = write(pipe, buffer + count, size - count); +if (bytes < 0) { if (errno == EINTR || errno == EAGAIN) continue; -nCount = -1; +count = -1; break; } -else if ( nCount + nBytes < nSize ) +else if (count + bytes < size) { -nCount += nBytes; +count += bytes; } else { -nCount = nBytes; +count = bytes; break; } } -return nCount; +return count; } -ssize_t readFIFO(int nPipe, char* pBuffer, ssize_t nSize) +ssize_t readFIFO(int pipe, char* buffer, ssize_t size) { -ssize_t nBytes; +ssize_t bytes; do { -nBytes = read(nPipe, pBuffer, nSize); +bytes = read(pipe, buffer, size); } -while ( nBytes < 0 && errno == EINTR ); +while (bytes < 0 && errno == EINTR); -return nBytes; +return bytes; } -ssize_t readMessage(int nPipe, char* pBuffer, ssize_t nSize) +ssize_t readMessage(int pipe, char* buffer, ssize_t size) { -struct pollfd aPoll; +struct pollfd pollPipe; -aPoll.fd = nPipe; -aPoll.events = POLLIN; -aPoll.revents = 0; +pollPipe.fd = pipe; +pollPipe.events = POLLIN; +pollPipe.revents = 0; -const int nPoll = poll(&aPoll, 1, CHILD_TIMEOUT_SECS * 1000); +const int nPoll = poll(&pollPipe, 1, CHILD_TIMEOUT_SECS * 1000); if ( nPoll < 0 ) return -1; if ( nPoll == 0 ) errno = ETIME; -if( (aPoll.revents & POLLIN) != 0 ) -return readFIFO(nPipe, pBuffer, nSize); +if( (pollPipe.revents & POLLIN) != 0 ) +return readFIFO(pipe, buffer, size); return -1; } static -void handleTerminationSignal(const int aSignal) +void handleTerminationSignal(const int signal) { if (!TerminationFlag) { @@ -425,33 +425,33 @@ namespace Util TerminationFlag = true; Log::info() << "Termination signal received: " -<< Util::signalName(aSignal) << " " -<< strsignal(aSignal) << Log::end; +<< Util::signalName(signal) << " " +<< strsignal(signal) << Log::end; } } void setTerminationSignals() { #ifdef __linux -struct sigaction aSigAction; +struct sigaction action; -sigemptyset(&aSigAction.sa_mask); -aSigAction.sa_flags = 0; -aSigAction.sa_handler = handleTerminationSignal; +sigemptyset(&action.sa_mask); +action.sa_flags = 0; +action.sa_handler = handleTerminationSignal; -sigaction(SIGTERM, &aSigAction, nullptr); -sigaction(SIGINT, &aSigAction, nullptr); -sigaction(SIGQUIT, &aSigAction, nullptr); -sigaction(SIGHUP, &aSigAction, nullptr); +sigaction(SIGTERM, &action, nullptr); +sigaction(SIGINT, &action, nullptr); +sigaction(SIGQUIT, &action, nullptr); +sigaction(SIGHUP, &action, nullptr); #endif } static -void handleFatalSignal(const int aSignal) +void handleFatalSignal(const int signal) { Log::error() << "Fatal signal received: " - << Util::signalName(aSignal) << " " - << strsignal(aSignal) << Log::end; + << Util::signalName(signal) << " " + << strsignal(signal) << Log::end; if (getenv("LOOL_DEBUG")) { @@ -463,66 +463,66 @@ namespace Util } #ifdef __linux -struct sigaction aSigAction; +struct sigaction action; -sigemptyset(&aSigAction.sa_mask); -aSigAction.sa_flags = 0; -aSigAction.sa_handl
[Libreoffice-commits] online.git: loolwsd/Util.cpp loolwsd/Util.hpp
loolwsd/Util.cpp | 52 loolwsd/Util.hpp | 19 +++ 2 files changed, 71 insertions(+) New commits: commit 1b6425913d475a2b15866876fe50a9e58a0ea2ce Author: Henry Castro Date: Mon Feb 1 22:23:58 2016 -0400 loolwsd: add LO core exit codes diff --git a/loolwsd/Util.cpp b/loolwsd/Util.cpp index 088620c..a764ff4 100644 --- a/loolwsd/Util.cpp +++ b/loolwsd/Util.cpp @@ -491,6 +491,58 @@ namespace Util sigaction(SIGFPE, &aSigAction, NULL); #endif } + +int getChildStatus(const int nCode) +{ +int nRetVal; + +switch (static_cast(nCode)) +{ +case LOOLExitCode::LOOL_SECOND_OFFICE: +case LOOLExitCode::LOOL_FATAL_ERROR: +case LOOLExitCode::LOOL_CRASH_WITH_RESTART: +case LOOLExitCode::LOOL_NORMAL_RESTART: +case LOOLExitCode::LOOL_EXIT_SOFTWARE: +nRetVal = EXIT_FAILURE; +break; + +case LOOLExitCode::LOOL_NO_ERROR: +nRetVal = EXIT_SUCCESS; +break; + +default: +nRetVal = EXIT_SUCCESS; +break; +} + +return nRetVal; +} + +int getSignalStatus(const int nCode) +{ +int nRetVal; + +switch (nCode) +{ +case SIGSEGV: +case SIGBUS: +case SIGABRT: +case SIGILL: +case SIGFPE: +case SIGTERM: +case SIGINT: +case SIGQUIT: +case SIGHUP: +nRetVal = EXIT_FAILURE; +break; + +default: +nRetVal = EXIT_SUCCESS; +break; +} + +return nRetVal; +} } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/loolwsd/Util.hpp b/loolwsd/Util.hpp index b599508..b6f6f08 100644 --- a/loolwsd/Util.hpp +++ b/loolwsd/Util.hpp @@ -25,6 +25,22 @@ // Possible states of LOOL processes. enum class LOOLState { LOOL_RUNNING, LOOL_STOPPING, LOOL_ABNORMAL }; + +enum class LOOLExitCode +{ +LOOL_NO_ERROR = 0, +/* pipe was detected - second office must terminate itself */ +LOOL_SECOND_OFFICE = 1, +/* an uno exception was catched during startup */ +LOOL_FATAL_ERROR = 77, /* Only the low 8 bits are significant 333 % 256 = 77 */ +/* user force automatic restart after crash */ +LOOL_CRASH_WITH_RESTART = 79, +/* the office restarts itself */ +LOOL_NORMAL_RESTART = 81, +/* internal software error */ +LOOL_EXIT_SOFTWARE = 70 +}; + extern volatile LOOLState TerminationState; /// Flag to stop pump loops. @@ -100,6 +116,9 @@ namespace Util /// Trap signals to cleanup and exit the process gracefully. void setTerminationSignals(); void setFatalSignals(); + +int getChildStatus(const int nCode); +int getSignalStatus(const int nCode); }; //TODO: Move to own file. ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] online.git: loolwsd/Util.cpp
loolwsd/Util.cpp | 26 -- 1 file changed, 16 insertions(+), 10 deletions(-) New commits: commit 11f7746640df5d97d9adcc259017402512ed917f Author: Ashod Nakashian Date: Tue Jan 19 20:06:23 2016 -0500 loolwsd: avoid reentering Poco::Log and deadlocking while handling signal Change-Id: I3ee16ac32a337a9e1ff798495d45fb1359f4f063 Reviewed-on: https://gerrit.libreoffice.org/21674 Reviewed-by: Ashod Nakashian Tested-by: Ashod Nakashian diff --git a/loolwsd/Util.cpp b/loolwsd/Util.cpp index 44baa40..ec8d9b9 100644 --- a/loolwsd/Util.cpp +++ b/loolwsd/Util.cpp @@ -418,17 +418,23 @@ namespace Util static void handleSignal(int aSignal) { -Log::info() << "Signal received: " << strsignal(aSignal) << Log::end; -TerminationFlag = true; -TerminationState = ( aSignal == SIGTERM ? LOOLState::LOOL_ABNORMAL : LOOLState::LOOL_STOPPING ); - -if (aSignal == SIGSEGV || aSignal == SIGBUS) +if (!TerminationFlag) { -Log::error() << "\nSegfault! Stalling for 10 seconds to attach debugger. Use:\n" - << "sudo gdb --pid=" << Poco::Process::id() << "\n or \n" - << "sudo gdb --q --n --ex 'thread apply all backtrace full' --batch --pid=" - << Poco::Process::id() << "\n" << Log::end; -sleep(10); +// Poco::Log takes a lock that isn't recursive. +// If we are signaled while having that lock, +// logging again will deadlock on it. +TerminationFlag = true; +TerminationState = ( aSignal == SIGTERM ? LOOLState::LOOL_ABNORMAL : LOOLState::LOOL_STOPPING ); + +Log::info() << "Signal received: " << strsignal(aSignal) << Log::end; +if (aSignal == SIGSEGV || aSignal == SIGBUS) +{ +Log::error() << "\nSegfault! Attach debugger with:\n" + << "sudo gdb --pid=" << Poco::Process::id() << "\n or \n" + << "sudo gdb --q --n --ex 'thread apply all backtrace full' --batch --pid=" + << Poco::Process::id() << "\n" << Log::end; +sleep(10); +} } } ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] online.git: loolwsd/Util.cpp
loolwsd/Util.cpp |4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) New commits: commit 5270383baa81a6752221cc986ee83b06955a87db Author: Ashod Nakashian Date: Sat Jan 16 15:40:01 2016 -0500 loolwsd: removed extra period in warn and error logs Change-Id: Ie7a42451009cfe9ffc7c3a0f91ff550b66e9158d Reviewed-on: https://gerrit.libreoffice.org/21671 Reviewed-by: Ashod Nakashian Tested-by: Ashod Nakashian diff --git a/loolwsd/Util.cpp b/loolwsd/Util.cpp index 5da99de..44baa40 100644 --- a/loolwsd/Util.cpp +++ b/loolwsd/Util.cpp @@ -165,7 +165,7 @@ namespace Log logger().warning(logPrefix() + msg + (append_errno ? (std::string(" (errno: ") + strerror(errno) + ").") - : std::string("."))); + : std::string(""))); } void error(const std::string& msg, const bool append_errno) @@ -173,7 +173,7 @@ namespace Log logger().error(logPrefix() + msg + (append_errno ? (std::string(" (errno: ") + strerror(errno) + ").") -: std::string("."))); +: std::string(""))); } } ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] online.git: loolwsd/Util.cpp loolwsd/Util.hpp
loolwsd/Util.cpp | 22 ++ loolwsd/Util.hpp |9 + 2 files changed, 19 insertions(+), 12 deletions(-) New commits: commit 5d07c460652fa6b7ffbf2ef8bc2a6a3190508e77 Author: Ashod Nakashian Date: Wed Jan 13 09:34:43 2016 -0500 loolwsd: logging improvements Error can supress printing errno and warning can be asked to print it by setting a bool argument. Formatting has been improved for readability. Change-Id: I93d2808fbff4f6cacc583923905438ada7b8e90e Reviewed-on: https://gerrit.libreoffice.org/21471 Reviewed-by: Ashod Nakashian Tested-by: Ashod Nakashian diff --git a/loolwsd/Util.cpp b/loolwsd/Util.cpp index ed8757d..af263f0 100644 --- a/loolwsd/Util.cpp +++ b/loolwsd/Util.cpp @@ -98,15 +98,15 @@ namespace Log std::ostringstream stream; stream << Log::SourceId << '-' << std::setw(2) << std::setfill('0') - << (Poco::Thread::current() ? Poco::Thread::current()->id() : 0) << ',' + << (Poco::Thread::current() ? Poco::Thread::current()->id() : 0) << ' ' << std::setw(2) << hours << ':' << std::setw(2) << minutes << ':' << std::setw(2) << seconds << "." << std::setw(6) << usec - << ", "; + << ' '; #ifdef __linux char buf[32]; // we really need only 16 if (prctl(PR_GET_NAME, reinterpret_cast(buf), 0, 0, 0) == 0) -stream << '[' << buf << "] "; +stream << '[' << std::setw(15) << std::setfill(' ') << std::left << buf << "] "; #endif return stream.str(); @@ -160,14 +160,20 @@ namespace Log logger().information(logPrefix() + msg); } -void warn(const std::string& msg) +void warn(const std::string& msg, const bool append_errno) { -logger().warning(logPrefix() + msg); +logger().warning(logPrefix() + msg + + (append_errno + ? (std::string(" (errno: ") + strerror(errno) + ").") + : std::string("."))); } -void error(const std::string& msg) +void error(const std::string& msg, const bool append_errno) { -logger().error(logPrefix() + msg + " (" + strerror(errno) + ")."); +logger().error(logPrefix() + msg + + (append_errno +? (std::string(" (errno: ") + strerror(errno) + ").") +: std::string("."))); } } @@ -285,7 +291,7 @@ namespace Util } } -std::string signalName(int signo) +std::string signalName(const int signo) { switch (signo) { diff --git a/loolwsd/Util.hpp b/loolwsd/Util.hpp index 702fe98..9dac84c 100644 --- a/loolwsd/Util.hpp +++ b/loolwsd/Util.hpp @@ -59,8 +59,6 @@ namespace Util // Call WebSocket::shutdown() ignoring Poco::IOException void shutdownWebSocket(Poco::Net::WebSocket& ws); -std::string signalName(int signo); - ssize_t writeFIFO(int nPipe, const char* pBuffer, ssize_t nSize); ssize_t readFIFO(int nPipe, char* pBuffer, ssize_t nSize); @@ -90,6 +88,9 @@ namespace Util removeFile(path.toString(), recursive); } +/// Returns the name of the signal. +std::string signalName(int signo); + /// Trap signals to cleanup and exit the process gracefully. void setSignals(bool isIgnored); }; @@ -103,8 +104,8 @@ namespace Log void trace(const std::string& msg); void debug(const std::string& msg); void info(const std::string& msg); -void warn(const std::string& msg); -void error(const std::string& msg); +void warn(const std::string& msg, const bool append_errno = false); +void error(const std::string& msg, const bool append_errno = true); // The following is to write streaming logs. // Log::info() << "Value: 0x" << std::hex << value ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] online.git: loolwsd/Util.cpp loolwsd/Util.hpp
loolwsd/Util.cpp | 21 + loolwsd/Util.hpp |1 + 2 files changed, 22 insertions(+) New commits: commit a06247fa5dc820d66e9371d548d238711c80df62 Author: Ashod Nakashian Date: Wed Dec 23 16:58:38 2015 -0500 loolwsd: Log level and warnings Log level can be set from LOOL_LOGLEVEL environment variable (values are those supported by Poco::Logger::setLevel). Added warning logging via warn function. Change-Id: I450511d5132893b93391b287fa5b3d6f522f4744 Reviewed-on: https://gerrit.libreoffice.org/20928 Reviewed-by: Ashod Nakashian Tested-by: Ashod Nakashian diff --git a/loolwsd/Util.cpp b/loolwsd/Util.cpp index 87dd14a..c6ee312 100644 --- a/loolwsd/Util.cpp +++ b/loolwsd/Util.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #include "Util.hpp" #include "Png.hpp" @@ -77,7 +78,22 @@ namespace Log { binname = name; auto& logger = Poco::Logger::get(name); + +// Configure the logger. +// TODO: This should come from a file. +try +{ +// See Poco::Logger::setLevel docs for values. +// Try: error, information, debug +const auto level = Poco::Environment::get("LOOL_LOGLEVEL"); +logger.setLevel(level); +} +catch (Poco::NotFoundException& aError) +{ +} + logger.information("Initializing " + name); +logger.information("Log level is " + logger.getLevel()); } Poco::Logger& logger() @@ -95,6 +111,11 @@ namespace Log logger().information(Util::logPrefix() + msg); } +void warn(const std::string& msg) +{ +return logger().warning(Util::logPrefix() + msg); +} + void error(const std::string& msg) { return logger().error(Util::logPrefix() + msg); diff --git a/loolwsd/Util.hpp b/loolwsd/Util.hpp index 8b1babf..aba885b 100644 --- a/loolwsd/Util.hpp +++ b/loolwsd/Util.hpp @@ -53,6 +53,7 @@ namespace Log void debug(const std::string& msg); void info(const std::string& msg); +void warn(const std::string& msg); void error(const std::string& msg); } ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] online.git: loolwsd/Util.cpp loolwsd/Util.hpp
loolwsd/Util.cpp | 67 +++ loolwsd/Util.hpp |6 2 files changed, 73 insertions(+) New commits: commit 961f853d6d19021075c5afdd5289e2e50def9f79 Author: Henry Castro Date: Sun Dec 13 12:04:45 2015 -0500 loolwsd: Added FIFO utils. Change-Id: Ifc4e3dafce669c615d5f0d156227f31fcf959936 Reviewed-on: https://gerrit.libreoffice.org/20896 Reviewed-by: Ashod Nakashian Tested-by: Henry Castro diff --git a/loolwsd/Util.cpp b/loolwsd/Util.cpp index 02a2c2f..9d74278 100644 --- a/loolwsd/Util.cpp +++ b/loolwsd/Util.cpp @@ -7,6 +7,8 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#include + #include #include #include @@ -193,6 +195,71 @@ namespace Util return std::to_string(signo); } } + +ssize_t writeFIFO(int nPipe, const char* pBuffer, ssize_t nSize) +{ +ssize_t nBytes = -1; +ssize_t nCount = 0; + +while(true) +{ +nBytes = write(nPipe, pBuffer + nCount, nSize - nCount); +if (nBytes < 0) +{ +if (errno == EINTR || errno == EAGAIN) +continue; + +nCount = -1; +break; +} +else if ( nCount + nBytes < nSize ) +{ +nCount += nBytes; +} +else +{ +nCount = nBytes; +break; +} +} + +return nCount; +} + +ssize_t readFIFO(int nPipe, char* pBuffer, ssize_t nSize) +{ +ssize_t nBytes; +do +{ +nBytes = read(nPipe, pBuffer, nSize); +} +while ( nBytes < 0 && errno == EINTR ); + +return nBytes; +} + +ssize_t readMessage(int nPipe, char* pBuffer, ssize_t nSize) +{ +ssize_t nBytes = -1; +struct pollfd aPoll; + +aPoll.fd = nPipe; +aPoll.events = POLLIN; +aPoll.revents = 0; + +int nPoll = poll(&aPoll, 1, 3000); +if ( nPoll < 0 ) +goto ErrorPoll; + +if ( nPoll == 0 ) +errno = ETIME; + +if( (aPoll.revents & POLLIN) != 0 ) +nBytes = readFIFO(nPipe, pBuffer, nSize); + +ErrorPoll: +return nBytes; +} } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/loolwsd/Util.hpp b/loolwsd/Util.hpp index 02a21d6..7a82fa4 100644 --- a/loolwsd/Util.hpp +++ b/loolwsd/Util.hpp @@ -31,6 +31,12 @@ namespace Util void shutdownWebSocket(Poco::Net::WebSocket& ws); std::string signalName(int signo); + +ssize_t writeFIFO(int nPipe, const char* pBuffer, ssize_t nSize); + +ssize_t readFIFO(int nPipe, char* pBuffer, ssize_t nSize); + +ssize_t readMessage(int nPipe, char* pBuffer, ssize_t nSize); }; #endif ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] online.git: loolwsd/Util.cpp
loolwsd/Util.cpp |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) New commits: commit dfa6fd134f365dc5f0fd6863cd98d71419b22df3 Author: Caolán McNamara Date: Fri Nov 20 15:43:09 2015 + info_ptr leak I bet Change-Id: Ica1a162a9ff1e1648c1ee5ef9edf4177b756ea51 Reviewed-on: https://gerrit.libreoffice.org/20091 Reviewed-by: Miklos Vajna Tested-by: Miklos Vajna diff --git a/loolwsd/Util.cpp b/loolwsd/Util.cpp index c1836cd..bf8be1f 100644 --- a/loolwsd/Util.cpp +++ b/loolwsd/Util.cpp @@ -104,7 +104,7 @@ namespace Util png_write_end(png_ptr, info_ptr); -png_destroy_write_struct(&png_ptr, NULL); +png_destroy_write_struct(&png_ptr, &info_ptr); return true; } ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] online.git: loolwsd/Util.cpp
loolwsd/Util.cpp | 21 ++--- 1 file changed, 18 insertions(+), 3 deletions(-) New commits: commit fbb184d256397f665f01e3f6d86538e428c532dc Author: Jan Holesovsky Date: Fri Nov 6 11:46:31 2015 +0100 loolwsd: More readable timestamps, 100ns resolution. Actually POCO doc claims 100ns resolution, but unfortunately it seems it is ms only; will improve later in case it is necessary. diff --git a/loolwsd/Util.cpp b/loolwsd/Util.cpp index b6e0b64..cac9c33 100644 --- a/loolwsd/Util.cpp +++ b/loolwsd/Util.cpp @@ -9,6 +9,8 @@ #include #include +#include +#include #include #include @@ -48,12 +50,25 @@ extern "C" namespace Util { +static const Poco::Int64 epochStart = Poco::Timestamp().utcTime(); std::string logPrefix() { -Poco::Timestamp timestamp; -Poco::Int64 now = timestamp.epochMicroseconds(); -return std::to_string(Poco::Process::id()) + "," + (Poco::Thread::current() ? std::to_string(Poco::Thread::current()->id()) : "0") + "," + std::to_string(now / 1000) + ","; +Poco::Int64 nanosec100 = Poco::Timestamp().utcTime() - epochStart; + +const Poco::Int64 n100 = 1000; +Poco::Int64 hours = nanosec100 / (n100*60*60); +nanosec100 %= (n100*60*60); +Poco::Int64 minutes = nanosec100 / (n100*60); +nanosec100 %= (n100*60); +Poco::Int64 seconds = nanosec100 / (n100); +nanosec100 %= (n100); + +std::ostringstream stream; +stream << Poco::Process::id() << "," << std::setw(2) << std::setfill('0') << (Poco::Thread::current() ? Poco::Thread::current()->id() : 0) << "," << +std::setw(2) << hours << ":" << std::setw(2) << minutes << ":" << std::setw(2) << seconds << "." << std::setw(7) << nanosec100 << ","; + +return stream.str(); } bool windowingAvailable() ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits