Commit graph

639 commits

Author SHA1 Message Date
Tor Lillqvist
bd0c225c9f Revert "Make it possible to generate Trace Events already when loading the document"
Makes unit-rendering-options fail reliably.

This reverts commit 175c9c5b2a.

Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: Id05c911991baaae0dbc52678a192fc01639352e0
2021-07-07 12:38:11 +03:00
Tor Lillqvist
175c9c5b2a Make it possible to generate Trace Events already when loading the document
By passing a traceevent=yes query parameter in the URL. Note that if
Trace Event generation is not enabled in loolwsd.xml this will have no
effect.

It is a bit silly to notice this query parameter only in loleaflet and
then send the information back to the server. Would be better if the
server noticed it itself before sending the URL to loleaflet.

While at it, let's not bother ever enabling Trace Event generation in
the WSD process. That is not what we are interested in.

Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: I985bfd1e2dbd14aa5a55b386b4762fb64bcb4008
2021-07-07 09:28:02 +03:00
Tor Lillqvist
4f0f7d6123 Avoid assertion failure if toggling Trace Event generation back and forth
Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: Ie6b7144ecf16faa9d22e7d87801d9dbe9b97d3fc
2021-06-30 12:40:08 +03:00
Tor Lillqvist
64675d2926 Add ProfileZone to encodeSubBufferToPNG
Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: I7363ea929ba703ce34a5c2411687f120ac5ba59e
2021-06-22 16:43:40 +03:00
Tor Lillqvist
1a2b29d3d5 Add function to check if config has been initialized
Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: Ieadcb9ad6d34bb6cf789d29896889601baf88a33
2021-06-21 12:43:17 +03:00
Tor Lillqvist
4c68a97ce5 Re-factor Trace Event stuff for improved functionality and thread safety
Write to the Trace Event JSON file in just one place, protected by a
mutex.

Handle metadata events separately. We want them to propagate to the
output if Event Trace generation is just enabled, regardless whether
it has been turned on or not.

We can send the metadata for the Kit process only after we have opened
the docuemnt as sending a Trace Event to WSD uses the (singleton)
Document object in Kit.

Introduce some new functions for the above and adapt callers
appropriately.

Generate a Complete event for the handling of one image tile, from
setting the src attribute of the Image object to finishing the onload
function.

Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: I5978e0fb2495e0d2dc479bf861eb4ac7da03fa50
2021-06-21 12:43:17 +03:00
Tor Lillqvist
b2f4776781 No need to add the thread name to the args of Trace Events now
We automatically emit metadata events that identify threads.

Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: Icb25b5cfc29b28ba7112ca72de56dbb697c8dd5a
2021-06-21 12:43:17 +03:00
Tor Lillqvist
d6569159b7 Output a Trace Event metadata event identifying each named thread
Move the generic dummy implementation of
TraceEvent::emitOneRecording() to a source file of its own. (That is
the one which is used in test and tool executables.)

Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: I81cab07e5a6852b42d278a5446c13c3825cf546e
2021-06-21 12:43:17 +03:00
Ashod Nakashian
f2f713cdaf wsd: rename file after saving to support async uploading
To avoid writing (saving) while reading (uploading) or
any other undesirable racse on the document file,
we atomically rename the file after saving on disk
to pass ownership.

After saving in Core, we rename the document in the
jail to .upload (by appending it). DocumentBroker
looks for the file with that extension and atomically
renames it to .uploading (by appening the 'ing' suffix).
This way, the Kit only renames from the original to
.upload and DocBroker renames only .upload to .uploading.
This guarantees that we never rename the same file
concurrently.

Uploading decision is strictly based on the modified
timestamp of the .uploading file, compared to the
timestamp of the last file we uploaded successfully.

Change-Id: I03520cd8c87605f6dad417e7a978204f76fc0c38
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-06-19 17:44:59 -04:00
Ashod Nakashian
0fa12e8e76 wsd: add hexify-data utility
Using for fuzzing and integration testing.

With unit-tests.

Change-Id: I23f8c619e239310d92c74c4d5e4157afb52a5e56
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-06-13 21:57:43 -04:00
Tor Lillqvist
dcf9d9f12b Log also the average tile PNG size and the average compression ratio
Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: I77fb1ae0e9ef892b23212222b44dc3dc522c7ce3
2021-06-11 09:42:17 +03:00
Henry Castro
371c394d7c Revert "common: add tag string to extract backtrace logs"
It was a request an approved by @kendy despite the signal
handler limitations. After several tries, we were blind
when we introduce the commit using the heap.

This reverts commit 9720eb0f81.
2021-06-03 11:10:08 -04:00
Tor Lillqvist
0f156aefec Include the thread name in the Trace Events emitted from the C++ code, too
Make sure to avoid most of the code path through createArgsString() if
Trace Event generation is not turned on.

Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: Id86b2c9b4ded9d402647b7a12b9290d0122ba2aa
2021-06-02 10:18:24 +03:00
Tor Lillqvist
8cef48a0fa Introduce a generic TraceEvent class and instant events here, too
Modelled on how it is done in core. ProfileZone is derived from
NamedEvent which is derived from TraceEvent. Here we don't keep any
separate ProfileZone.hpp, though.

This was needed to introduce generation of "instant" events here, too.

Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: I6583134e96001641c50339deb4197fca6ab7d5d5
2021-06-02 09:04:21 +03:00
Tor Lillqvist
b7ca93a41a Add the possibilty to set a thread-local logging level
Add a way to set it from the client.

For now, in the Help > About dialog, the L key toggges the logging
level between the default (whatever is set in loolwsd.xml or on the
loolwsd command line) and the maximum a client is allowed to set
(which also can be set in loolwsd.xml or on the loolwsd command line).

Also while at it, uncouple the toggling of the Trace Event generation
from the triple-click tha toggles tile debugging. It is now on the T
key.

Also swap the meaning of "min" and "max" for the logging levels. Even
if the Poco::Message::Priority values are such that the less urgent
priorities have a numerbcally higher value, conceptually it is more
clear to say the more urgent priorities (levels) are "higher".

Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: I5383b16ead7d2d378901525eb0d16513d88f045e
2021-05-31 10:56:19 +03:00
Tor Lillqvist
dec5d7f127 Slight renaming to make names match functionality
The "StaticNameHelper" was more than just related to a "name", so call
it StaticHelper instead. And why call the variable of that type
"Source"?

Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: I099b326cc731e7fb4c96ead9ec19143257090cb1
2021-05-31 10:56:19 +03:00
Tor Lillqvist
2398c792cb No Hungarian notation please
I had accidentally used core naming conventions for ProfileZone.

Change-Id: If10eceb7a5a29d26662d5b21a9289681d814a12e
Signed-off-by: Tor Lillqvist <tml@collabora.com>
2021-05-31 10:56:19 +03:00
Tor Lillqvist
929e466c91 Re-work the ProfileZone implementation here
Don't bother collecting them into a vector, like in core. Instead,
just call a static member function ProfileZone::addOneRecording() for
each Event Trace object (string) to be emitted. That function then
needs to be implemented separately in each executable. In WSD it logs
the object to the Event Trace file. In Kit it sends it to WSD for
logging. In Unit tests we use a dummy implementation.

(If Event Trace logging is not enabled at all in loolwsd.xml (the
default), nothing is done, of course.)

When receiving the "traceeventrecording start" or "traceeventrecording
stop" message from the client, turn ProfileZone recoring on or off in
the WSD and Kit process. (Probably in WSD the flag should be
per-client.)

Change-Id: Ie1127d65dd44ed77e7eeab4b0f0a90cce95dc4a2
Signed-off-by: Tor Lillqvist <tml@collabora.com>
2021-05-31 10:56:19 +03:00
Tor Lillqvist
b265586dda Add the possibility to have arbitrary "arguments" in a ProfileZone object
Note that the C++ ProfileZone class here in Online is totally separate
from the comphelper::ProfileZone in core (which is now derived from
the more generic comphelper::TraceEvent class there).

Also note that this is work in progress and I know that there isn't
any code yet to write out the collected information from this C++
ProfileZone stuff here in Online. Which is why we don't actually have
any ProfileZone variables yet sprinkled through the code. That is
upcoming.

And finally, note that the Trace Event stuff in loleaflet also is
unrelated.

Change-Id: I8765d6dbc1d5108d9d1042781644cbee2419cd9d
Signed-off-by: Tor Lillqvist <tml@collabora.com>
2021-05-24 16:49:46 +03:00
Tor Lillqvist
73943230d2 Fix build for iOS
Change-Id: I774e8802d959eefecd9863edd693f26f0fd1d863
Signed-off-by: Tor Lillqvist <tml@collabora.com>
2021-05-19 13:33:26 +03:00
Tor Lillqvist
d5ded73b11 Fix FreeBSD compilation error
Change-Id: I0201c8213c9593f225c0aab7c4e95b06bd6a22ec
Signed-off-by: Tor Lillqvist <tml@collabora.com>
2021-05-19 13:33:26 +03:00
Gökhan Karabulut
7f736a9bc4 Improve state dump
Add `dumpState` methods to `TileQueue`, `PngCache`, `ThreadPool` classes
and call them from Document::dumpState method within kit.Kit.cpp.
Because `dumpState` method of `_websocketHandler` is protected,
currently we can't dump its internals.

Also dump the other members of the `Document` class. Note that as
`_lastMemStatsTime` is never used, we don't dump it. It seems we could
simply delete it.

Signed-off-by: Gökhan Karabulut <gokhanettin@gmail.com>
Change-Id: Ia89b7fff41eaf475c7a09a644c0eb523b72cf97d
2021-05-13 09:29:35 +01:00
Ashod Nakashian
f6da8d664c wsd: create the unittest SocketPoll thread only when testing
Change-Id: I901ef4722182dd44406c35528c7642414f680814
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-05-06 22:14:51 -04:00
Henry Castro
ae76450398 common: revisit log messages misc files
LOG_FTL = abnormal, crash, denied service
LOG_ERR = load, save, session, connection, wrong parameters
other cases LOG_WRN, LOG_INF

Change-Id: I15bc840f5a6eaf9a74a1ee1caa57d447baa2afce
Signed-off-by: Henry Castro <hcastro@collabora.com>
2021-05-05 13:50:41 -04:00
Michael Meeks
d387700914 Message: don't generate and allocate abbreviations just for trace logging.
Also avoid generating abbreviations in various message handling loops
unless debugging is enabled.

Change-Id: I22f4929b0bfd4da36917db6882bb2f5f5be02780
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2021-05-05 09:40:10 +01:00
Michael Meeks
5c345a1d14 Message: cleanup message parsing of payloads.
Change-Id: Id11a702590539ff4f20fa56272beeb6d91b9e7bd
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2021-05-05 02:51:54 +01:00
Gleb Popov
53e1c0250b Use Util::getThreadId() instead of Linux system call.
Signed-off-by: Gleb Popov <6yearold@gmail.com>
Change-Id: I5cab82f0d869cc9f2ea97ac9320d8f4bbf466c37
2021-05-04 15:40:50 +01:00
Tor Lillqvist
9ef32a3e38 Similar improvements to the ProfileZone here as to that in core
Perhaps we should use the exact same code in both core and online? But
that would be a bit tedious as core needs to be cross-platform (and
thus we use things like osl_getSystemTime and osl_getProcessInfo in
its version) while online is Linux-only.

Also imporve the test for it.

Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: I0bc9dca71dc4489bd1671e0dae1e582990a8f8b4
2021-05-03 16:09:35 +03:00
Tor Lillqvist
e7ed4e11cf Add a ProfileZone implementation here, too
Compiled but not yet used.

Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: I3b85696ca6076e42d16e710b49bfd37bac342ec8
Signed-off-by: Tor Lillqvist <tml@collabora.com>
2021-05-03 16:09:35 +03:00
merttumer
5742acd87c android: Fix build fail and crash on doc load
Signed-off-by: merttumer <mert.tumer@collabora.com>
Change-Id: Id998e2bdf7051d54784543015c7d34c0bdd64543
2021-05-02 21:47:37 -07:00
Ashod Nakashian
5c84542c7d wsd: test: log poco exceptions
While Poco::Exception inherits from std::exception,
it's what() member returns simply the name of the
exception, which is hardly useful without the message.
Therefore, we are forced to log it's displayText()
member for the full error message.

Change-Id: I650614a9b4b3bb1b2e31841c37250a2a069e6b77
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-05-02 22:35:39 -04:00
Ashod Nakashian
eabdd43d37 wsd: fix signed/unsigned mismatch
Change-Id: Id72f1b3a01a8690e2a8a89c0dc12dd823cb7096c
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-05-02 22:35:39 -04:00
Ashod Nakashian
858a4aa398 wsd: test: UnitBase takes the test name from derived classes
Change-Id: Id3c7b35ee03cbade44effffeedfbdd65c015612d
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
(cherry picked from commit 714ae5d0314a60a498d5d4800882ed704988dfb8)
2021-05-02 22:35:39 -04:00
Ashod Nakashian
3decba7eec wsd: specify the minimum bytes we can write to the socket
When writing to the socket, it's always more efficient
to fill the buffer up to the hardware limit for each
write. This is doubly important for efficiency with
SSL, due to the overhead of encrypting multiple
small buffers instead of one large one.

Currently we don't write more than one message
at a time, primarily due to limitations in
the Poco sockets in the unit-tests, which
have a hard time consuming multiple WS frames
with a single poll (subsequent calls to poll
doesn't enter signalled state until new data
arrives, possibly because the data is read and
buffered internally, making the whole scheme
of using poll unreliable and meaningless).

Change-Id: Ic2e2cf1babfb5ab4116efd93f392977ba234d92b
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-04-27 17:48:23 -04:00
Miklos Vajna
d3c9e07ff3 StringVector: add a way to get a string-number pair out of this ...
... without copying the token.

And use it in TileDesc::parse(), which is known to be a hot path.

Signed-off-by: Miklos Vajna <vmiklos@collabora.com>
Change-Id: I0dcf2eb26c93254cdc6a1c11f9708daf213a825d
2021-04-27 15:31:21 +02:00
Miklos Vajna
c11f0e5708 StringVector: add a way to get a number out of this without copying the token
And use it in TileDesc::parse(), which is known to be a hot path.

Signed-off-by: Miklos Vajna <vmiklos@collabora.com>
Change-Id: I20375d7a1c31f61662446979e4d6799fd45b49d3
2021-04-27 15:31:21 +02:00
Ashod Nakashian
b47c81e7a8 wsd: improved WebSocketSession interface
SocketPoll is captured as weak_ptr into
WebSocketSession and a much better shutdown
support is now available. The new logic
can do async-shutdown after flushing and
will do sync-shutdown if SocketPoll is
no longer around.

Change-Id: Ia206cab58a13f20f7aeb3a6d8c57afee731c8231
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-04-27 08:09:49 -04:00
Ashod Nakashian
c50af5b94c wsd: better and consistent logging of ShutdownRequestFlag setting
Change-Id: Ic9e41d193b6a6a678170ec5ca30bd80bcee04c80
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-04-27 08:09:49 -04:00
Ashod Nakashian
04640009f4 wsd: test: move SocketPoll to UnitBase
This is the SocketPoll used by async
WebSocket clients.

Change-Id: I2ec3c0ff9984a6a0c457fd3189a3d7833061147e
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-04-27 08:09:49 -04:00
Ashod Nakashian
a7b2f14074 wsd: test: single UnitBase ctor with default name
We always want to have some default name so
we can log something relevant. Having
two constructors isn't very helpful,
especially because we must initialize all
members in only one initialization list
(since we call the default-ctor from the
overloaded one).

Having a single constructor with a default
parameter is one of few cases where default
parameters are justified.

Change-Id: Ia2d390be46ea7ad5486248d7ede7a7c95c4352e3
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-04-27 08:09:49 -04:00
Ashod Nakashian
5b96d59747 wsd: test: log the testname in the test setup and result
Change-Id: I0e0277afc3956783ad26ca57e6e2604d60f75a66
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-04-27 08:09:49 -04:00
Ashod Nakashian
0f94eb261c wsd: test: killpoco in UnitCopyPaste
Change-Id: I2657a095e0a9d79b678c826db46b9c69d9aac056
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-04-27 08:09:49 -04:00
Miklos Vajna
a5566baa03 Add version of std::atoi() that needs no extra allocation
std::atoi() assumes a null-terminated string and our strings are not
always null-terminated. So add a version that takes a length parameter,
this way we don't have to copy strings around.

Also switch to this in http::StatusLine::parse().

Signed-off-by: Miklos Vajna <vmiklos@collabora.com>
Change-Id: I449b356c1b9948c562434618596e8e3b38656088
2021-04-26 16:22:27 +02:00
Michael Meeks
2fcc5451d7 Avoid errno == ERANGE poisoning numerical conversions.
Change-Id: I0156310257caf7c578fb273393566a0970b3bb1f
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2021-04-16 22:43:17 +01:00
Michael Meeks
f732e00918 Allow easy configuation of the user-id that is accepted.
So if you're debugging the product build you can use:

 --with-user-id=`whoami`

Change-Id: I3f753b83c0806729d36d45293bc2b6a38d50fdbb
2021-04-16 15:40:28 +01:00
Ashod Nakashian
04c15755b0 wsd: create the temp directory root recursively
Without this, the conversion test in UnitHTTP
fails because the root of the temp directory
hasn't yet been created (mkdir actually fails,
since the root is missing).

This failure occures when UnitHTTP is executed
before other tests.

Change-Id: I9b5d9a48c8ab9735978ecfa2d29944e037cf794d
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-04-11 01:05:20 -04:00
Ayhan Yalçınsoy
49bf424031 added stdexcept include to fix build error
Signed-off-by: Ayhan Yalçınsoy <ayhanyalcinsoy@pisilinux.org>
Change-Id: Idc3f58e6c8f04efcbe636ab9aac940eee2f0affd
2021-04-03 17:47:56 +01:00
Ashod Nakashian
0118ed6459 wsd: include cleanup
Change-Id: I9fc3b1156c8716722b9615e8f178185a4cad8fa1
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-04-02 13:18:41 -04:00
Ashod Nakashian
6bffc7cf53 wsd: case-insensitive string equality utility added
With unit-tests.

Change-Id: I89b3589d53d117fbd1f25fbdc5d9e0fc61df4b74
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-04-02 13:18:41 -04:00
Ashod Nakashian
fd1f78cfb0 wsd: dump blank in hex dump for out of data
To differentiate between non-printable data
and no-data, we use '.' for non-printables
and print nothing visible (i.e. whitespace)
when we run out of data. This makes the hex
dumps more readable.

Change-Id: I8eeb78ab72d63ed613b7c330949063c0cb8cbfca
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-04-02 13:18:41 -04:00