Commit graph

71 commits

Author SHA1 Message Date
Michael Meeks
b6ab8982e6 Guard logger so it can be used during static destructors safely. 2016-04-07 19:38:33 +01:00
Tor Lillqvist
5637064e9a Factor out the prctl() calls
Silly to keep copy-pasting the same couple of lines over and over
again.
2016-04-07 11:53:33 +03:00
Tor Lillqvist
ec604599f1 Introduce separate Log::syserror() function for logging actual syscall errors
Much better than assuming that errno would be relevant at all
Log::error() calls (or alternatively, having to remember to append a
false parameter to the Log::error() call, which had not been done a
single time anyway.)

Call log::syserror() right after a system call has returned an
error. Don't call it otherwise.
2016-04-07 10:36:38 +03:00
Tor Lillqvist
94caec287f We never call Log::warn() with an append_errno parameter
So just drop it. Default parameters are ugly IMHO.
2016-04-07 10:15:51 +03:00
Ashod Nakashian
6e5e9033f2 loolwsd: removed Admin pipe
Admin no longer needs a pipe as it's notified
from WSD. It is now a singleton with improved
locking.

The tracking of documents and views still needs
improvement and corrections.

Change-Id: If614331de6dd595c6dd4443f480d4ab588ca4551
Reviewed-on: https://gerrit.libreoffice.org/23860
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-04-06 13:52:57 +00:00
Tor Lillqvist
422834ebef Improve logging
Don't embed newlines in "lines" written to the log. When logging stuff
read from or written to the fifos, translate newlines to " / " for
clarity.

(If we would want complete, exact verbose logging, we should be really
pedantic and log all non-printable bytes in hex anyway, etc, so
displaying newlines as space-separated slashes should be OK. It isn't
as if there would be totally arbitary data passed through the fifos
anyway.)
2016-03-31 11:01:52 +03:00
Ashod Nakashian
ce2fabb733 loolwsd: moved IO utilities into IoUtil file
Change-Id: I1e8d5562787134cbb490c38b19d83b7514ec9baa
Reviewed-on: https://gerrit.libreoffice.org/23586
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-03-29 14:09:04 +00:00
Jan Holesovsky
09ee912e08 loolwsd: Default to the most verbose log level.
Still in heavy development, useful to know about everything...
2016-03-29 14:47:09 +02:00
Ashod Nakashian
019aed134e loolwsd: using random jailId
Change-Id: Ie9501e4346a124994270ca1fac61869ed04b9b72
Reviewed-on: https://gerrit.libreoffice.org/23213
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-03-14 03:06:29 +00:00
Ashod Nakashian
0d8fcf5699 loolwsd: logging
Change-Id: I9a4dc248aca87983e3d7d3ace0071e5bbf92e688
Reviewed-on: https://gerrit.libreoffice.org/23209
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-03-14 03:04:17 +00:00
Ashod Nakashian
05f8757f1d 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 <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-03-09 13:27:15 +00:00
Ashod Nakashian
18a224b413 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 <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-03-09 02:32:47 +00:00
Pranav Kant
76542d8d52 loolwsd: Add total memory, total active docs, total active users
Further changes/refactoring to make it possible:
* Add broker pid to Admin class
* Move getMemoryUsage for process to Util
* Change variable name to accurately reflect *active* items
  _nViews -> _nActiveViews, etc.

Change-Id: I4c9206c49ab829b73ebfe226874bfbbcc8f95342
Reviewed-on: https://gerrit.libreoffice.org/22989
Reviewed-by: Tor Lillqvist <tml@collabora.com>
Tested-by: Tor Lillqvist <tml@collabora.com>
2016-03-08 09:34:51 +00:00
Tor Lillqvist
e7e1ef58ae Cosmetics: Sort and prune #include and 'using' lines 2016-03-08 09:44:04 +02:00
Tor Lillqvist
61ee1ae842 Use std::getenv() instead of Poco::Environment::get()
Much simpler.

Also, don't duplicate the code informing that LD_BIND_NOW or
LOK_VIEW_CALLBACK are not set. Not that I understand why we need to
inform about that? If the "normal" thing should be that they are set,
why don't make it so by default then?
2016-03-08 09:16:01 +02:00
Tor Lillqvist
9f67eecadd Improve exception logging
Always try to identify *where* we caught the exception. It is not that
useful to have half a dozen places that all just log "Exception:".
2016-03-07 18:36:01 +02:00
Tor Lillqvist
8fc4f1d95f 10 seconds is a bit short 2016-03-07 17:44:54 +02:00
Tor Lillqvist
d27e798e0f It is not only a 'segfault' that is handled here 2016-03-07 17:44:11 +02:00
Pranav Kant
1908613951 loolwsd: Factor out pipe reading polling logic
Change-Id: I7c06c68031ea14147130d21376ab348bdc672a7f
Reviewed-on: https://gerrit.libreoffice.org/22820
Reviewed-by: Tor Lillqvist <tml@collabora.com>
Tested-by: Tor Lillqvist <tml@collabora.com>
2016-03-03 16:23:21 +00:00
Tor Lillqvist
8bc05765bf Make writeFIFO() return total number of bytes written if successful
That is probably what was the intent. As originally written, in case
the function encountered partial writers, and had to do several
write() calls, only the number of bytes written by the last one was
returned.

Luckily the actual return value of writeFIFO() is not used
anywhere. It is just tested for being negative.

Still there is the problem that if at first one or several write()
calls succeed but don't write the whole buffer, and then a write()
fails, the caller has no way to know that the buffer has been
partially written. But that is hopefully highly theoretical and there
is no sane way to handle such a situation anyway.
2016-03-01 17:15:40 +02:00
Tor Lillqvist
dc305b2b08 Don't confuse Poco::Util::Application::ExitCode and EXIT_SUCCESS/FAILURE
The getChildStatus() and getSignalStatus() functions returned the
latter, still the returned values were compared against
Poco::Util::Application::EXIT_OK. (Sure, both Poco's
Application::EXIT_SUCCESS and stdlib.h's EXIT_OK are zero, but that
doesn't mean one should mix them up.)

Also add two comments pondering the meaning of the code.
2016-03-01 16:49:12 +02:00
Tor Lillqvist
cdb0c08bb8 Let's be consistent 2016-03-01 15:27:36 +02:00
Tor Lillqvist
9d655cbcc0 Don't pretend this will work on anything except Linux 2016-02-29 14:25:12 +02:00
Tor Lillqvist
46b43602fd No colours in the log, thanks
The escape sequences just make the log harder to read in an editor.
2016-02-24 15:35:32 +02:00
Henry Castro
e9de068423 loolwsd: fixes coding style naming convention rules in Util files 2016-02-18 13:00:37 -04:00
Henry Castro
a607159a8a loolwsd: catch exception requestTermination 2016-02-16 17:25:51 -04:00
Henry Castro
45754cc36c loolwsd: remove unused TerminationState 2016-02-14 23:08:59 -04:00
Henry Castro
70ff592624 loolwsd: use strsignal 2016-02-03 18:08:16 -04:00
Henry Castro
1b6425913d loolwsd: add LO core exit codes 2016-02-01 22:23:58 -04:00
Henry Castro
b477f41636 loolwsd: add fatal signals handler 2016-02-01 21:26:19 -04:00
Ashod Nakashian
ef2ec0b2e2 loolwsd: fixes to broker threading and communication
Broker cache clean up is now done only during searching
as there we loop over processes and request status
from each child.

Internal helpers simplified and termination is done
in a single removeChild helper.

Change-Id: I31f7df5429f0737d352842d5c0f6a02b91b8078f
Reviewed-on: https://gerrit.libreoffice.org/21751
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-01-24 20:59:40 +00:00
Ashod Nakashian
d3fc5ac37b loolwsd: sockets are shutdown on disconnect
Change-Id: I1c00be4648cff94013ceab87fcb607b9bb921535
Reviewed-on: https://gerrit.libreoffice.org/21684
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-01-21 16:06:37 +00:00
Ashod Nakashian
11f7746640 loolwsd: avoid reentering Poco::Log and deadlocking while handling signal
Change-Id: I3ee16ac32a337a9e1ff798495d45fb1359f4f063
Reviewed-on: https://gerrit.libreoffice.org/21674
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-01-21 15:44:38 +00:00
Ashod Nakashian
5270383baa loolwsd: removed extra period in warn and error logs
Change-Id: Ie7a42451009cfe9ffc7c3a0f91ff550b66e9158d
Reviewed-on: https://gerrit.libreoffice.org/21671
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-01-21 15:42:47 +00:00
Ashod Nakashian
0632da5edb loolwsd: reworked child management and load balancing in broker
Change-Id: I92874d1aeb8fe46f3bbc1cb9d3b2b9d46632f4b9
Reviewed-on: https://gerrit.libreoffice.org/21473
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-01-14 13:56:40 +00:00
Ashod Nakashian
5d07c46065 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 <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-01-14 13:41:18 +00:00
Tomaž Vajngerl
9071f7c9bc encode PNG from buffer at arbitrary buffer position
This commit add 2 methods to encode a buffer to PNG: the "old"
method which encodes the whole buffer to a PNG, and a new method
to encode a part of a buffer (sub image) to PNG. The first method
is only added for convenience.
2016-01-14 12:34:01 +01:00
Ashod Nakashian
6f4336a1fc loolwsd: trap segv and bus when LOOL_DEBUG env is defined
Change-Id: I56b2c70cd910ff2628e020e494143b8f38c0bd36
Reviewed-on: https://gerrit.libreoffice.org/21332
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-01-11 04:11:07 +00:00
Ashod Nakashian
9b5a94b018 loolwsd: callbacks use shared_ptr to avoid race with destructors
Change-Id: I19e06850764c6dbd1cfcc15dcd9a64029ab4fc0c
Reviewed-on: https://gerrit.libreoffice.org/21326
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-01-11 04:07:30 +00:00
Ashod Nakashian
5bf75f56ca loolwsd: centralized signal handling and eased debugging
Change-Id: Ifdb3e2bca540bec3c6dea1ab24173c8ea0267706
Reviewed-on: https://gerrit.libreoffice.org/21325
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-01-11 04:06:56 +00:00
Ashod Nakashian
4b028e1506 loolwsd: localized lokit lock and other cleanups
Change-Id: I16453924d90ab22e57f8b6a3bbb937fef853ea2c
Reviewed-on: https://gerrit.libreoffice.org/21315
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-01-11 03:57:18 +00:00
Ashod Nakashian
0b5bc5f244 loolwsd: random jailId dir created by WSD and renamed childId -> jailId
Change-Id: Ib5ce65c578c0c7fd3dbf81628906cd17728fb3ff
Reviewed-on: https://gerrit.libreoffice.org/21182
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-01-07 05:56:01 +00:00
Ashod Nakashian
1746094fcd loolwsd: log the thread name where available
Change-Id: If40b2d3a72f3e00e8c3bf27fe60c6d63a71df267
Reviewed-on: https://gerrit.libreoffice.org/21062
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-01-03 15:19:12 +00:00
Ashod Nakashian
f48d61d25d loolwsd: dropCapability moved to Capabilities.hpp
Change-Id: Id84d485b446040df1d5398341af2b0e8f300ed63
Reviewed-on: https://gerrit.libreoffice.org/21060
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-01-03 15:17:05 +00:00
Ashod Nakashian
3811abb40a loolwsd: replaced threadId with globally unique sessionId
Change-Id: I55b16d4baa1753bc67dcd72de13e7a516da27abe
Reviewed-on: https://gerrit.libreoffice.org/20981
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2015-12-28 04:14:15 +00:00
Ashod Nakashian
1e24456121 loolwsd: logPrefix cleanup
Change-Id: I41465a06b17876c5d5fb7a6f9d8569d80571fcca
Reviewed-on: https://gerrit.libreoffice.org/20977
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2015-12-28 04:08:34 +00:00
Ashod Nakashian
3bd8361c89 loolwsd: more cleanups and logging
Change-Id: I23859849af2d7a3411bd4df57916b4166a17c3b5
Reviewed-on: https://gerrit.libreoffice.org/20946
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2015-12-26 03:57:47 +00:00
Ashod Nakashian
8464651655 loolwsd: Better logging
Color logging in console, tracing and streaming,
and converted cout to proper logging.

Change-Id: I515b8f8a40f8fa6763536b85c7632e3bb36673ee
Reviewed-on: https://gerrit.libreoffice.org/20931
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2015-12-25 03:32:33 +00:00
Ashod Nakashian
a06247fa5d 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 <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2015-12-25 03:30:03 +00:00
Ashod Nakashian
ea0ddcf738 loolwsd: Nominal logger and fixes
Nominal logging interface and a fix to using Poco
Application from LOOLKit, which is not a Poco App,
which caused core dump.

Logs now include process name.
Added logs to strategic places and some cleanups.

Change-Id: Ib7dcc4f1033dddf7c87cd2e786a91f5b482fb312
Reviewed-on: https://gerrit.libreoffice.org/20906
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2015-12-23 17:23:10 +00:00