Commit graph

1849 commits

Author SHA1 Message Date
Tor Lillqvist
636069430e Also add logging.min_level_settable_from_client
We don't want a client to be able to turn logging off completely
either.

Note, just to avoid potential confusion: This is about the LOG_INF(),
LOG_WRN(), LOG_TRC() etc logging here in Online. Not related to my
recent work on Trace Event format logging.

Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: I3de527cb9f69d9a5269b1db2e1d4602e7117f22e
2021-05-31 10:56:19 +03:00
Tor Lillqvist
4136e024f9 Add logging.max_level_settable_from_client setting
(Not used yet.)

The intent is that the JS code will be able send the server a message
that adjusts the logging level for the WSD thread(s) and Kit processes
handling that client.

Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: I88ac301f002b1f3a55a5d8c9e3650babdedc1e0d
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
496951d2c1 Add a ProfileZone for WopiStorage::getWOPIFileInfo
On request from mmeeks.

Change-Id: I2b0b6e290109b29cd84359b2c26aa30357e8450f
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
Miklos Vajna
bc0401fc49 Make sure that double fits into uint64_t
Signed-off-by: Miklos Vajna <vmiklos@collabora.com>
Change-Id: Ic521383f71c1865ae18fc880b79493c52285e29b
2021-05-31 08:54:06 +02:00
Tor Lillqvist
809c78480d The convention is to call the processes 'WSD', 'ForKit', and 'Kit'
I.e., not in upper case. I was misunderstanding.

Change-Id: I3275446cba0eb954b5ef398d3406d0543c2fb7e7
Signed-off-by: Tor Lillqvist <tml@collabora.com>
2021-05-25 10:41:11 +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
Tor Lillqvist
9b948da419 Add thread name and id to Trace Events coming in from a client loleaflet
Change-Id: If469fcfb39b94866e8d8a93a88587c33583b35d2
Signed-off-by: Tor Lillqvist <tml@collabora.com>
2021-05-19 13:33:26 +03:00
Tor Lillqvist
9c6b74ad08 Use a loolwsd.xml setting instead of --enable-trace-event-logging
That is our convention, and this also avoids a global variable in the
kit process.

Change-Id: I37d2d53aa7eb24f9848fa8ef98bc57d75db90d13
Signed-off-by: Tor Lillqvist <tml@collabora.com>
2021-05-19 13:33:26 +03:00
Tor Lillqvist
cadb005993 Add the possibiliy to include arbitrary arguments in the generated Trace Events in JS, too
For now, an argument object should have all keys and values as strings
not containing any spaces because of the trivial way in which it is
parsed.

This is a bit sad, yes, but necessary until we move to some more
structured syntax for the messages.

Also fix an incorrect comment.

Change-Id: I8a1408a4a1787b66a3cf7b26b3d92c07df244c47
Signed-off-by: Tor Lillqvist <tml@collabora.com>
2021-05-19 13:33:26 +03:00
Miklos Vajna
03f13aceb1 wsd: remove unused using declarations
Signed-off-by: Miklos Vajna <vmiklos@collabora.com>
Change-Id: I99aa27d70c7c1d90f3048009644ebf9a41e73724
2021-05-14 11:05:16 +02:00
Andras Timar
9a522cf0db documentation of default config values
Signed-off-by: Andras Timar <andras.timar@collabora.com>
Change-Id: Ie7022e0db125f85261f17cfa91933fe8d3b51104
2021-05-13 11:52:20 +02:00
Tor Lillqvist
a28ee1bac6 Fix syntax errors in generated Trace Event JSON
Colon, not equals. Comma missing.

Change-Id: Ife64fe7c57e0cff155926f9b17beb17ce530d848
Signed-off-by: Tor Lillqvist <tml@collabora.com>
2021-05-10 18:06:59 +03:00
Tor Lillqvist
4e0b03f651 Let the server tell loleaflet whether trace events can be collected or not
Instead of requiring that information in the query string of the loleaflet.html URL.

Change-Id: I8c41e87c7f561561adeb03ec34ce0c19fe9d7fa5
Signed-off-by: Tor Lillqvist <tml@collabora.com>
2021-05-10 16:44:07 +03:00
Tor Lillqvist
cdf374dc63 Clarify Trace Event file writing
Make it contain a proper empty JSON array if no trace objects have
been written to it.

Change-Id: Ided1992a822659561a909ac545536261b91adbac
Signed-off-by: Tor Lillqvist <tml@collabora.com>
2021-05-10 15:14:40 +03:00
Tor Lillqvist
9da0145280 Add an --enable-trace-event-logging option to loolwsd
It enables turning Trace Event recording on (and off again). The
option is passed down to the client through loleaflet.html, and to the
KIT processes. If the option is not used, the new JS functions that
send trace events to the server turn into no-ops to avoid wasting
bandwidth.

It is always on in a "make run".

Change-Id: Iafe1919ccba7c376137d3e0568b857e20780bbc8
Signed-off-by: Tor Lillqvist <tml@collabora.com>
2021-05-10 12:39:07 +03:00
Miklos Vajna
7b89ce2961 ClientSession::_handleInput: avoid pointing to a temporary
Signed-off-by: Miklos Vajna <vmiklos@collabora.com>
Change-Id: I048ce322111029847d78f917f071b1c0854dc116
2021-05-10 12:38:32 +03:00
Miklos Vajna
d6c41de084 ClientSession: fix -Wdangling-gsl
wsd/ClientSession.cpp:411:31: error: object backing the pointer will be destroyed at the end of the full-expression [-Werror,-Wdangling-gsl]
            const char* str = tokens[2].data();
                              ^~~~~~~~~

Signed-off-by: Miklos Vajna <vmiklos@collabora.com>
Change-Id: I67e4aa5f61e049ad13663dc1e11ae2bd67399bea
2021-05-07 13:42:54 +02:00
Ashod Nakashian
effa9b942f wsd: log if we skip updating the modified flag
Change-Id: Iadde822ce720ff81abd38fd7c8991352ac57953f
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-05-06 22:14:51 -04:00
Tor Lillqvist
9c57b8a435 Introduce a TRACEEVENT message from client to server
Add a function emitInstantTraceEvent() to leaflet that sends an
"Instant" Trace Event to the server for logging.

Add a function createAsyncTraceEvent() that creates an object that
records the timestamp of its creation and sends the 'b' event to the
server for logging, and when you call finish() on the object, sends
the corresponding 'e' event.

Finally, add a function createCompleteTraceEvent() that creates an
object for a "Complete" Trace Event that includes the end timestamp
*and* the duration. The event is sent to the server when you call
finish() on the object.

Loleaflet sends timestamps in the above messages from
performance.now(). To enable the server to turn those into absolute
timestamps, the loolclient message is amended to include the current
Date.now() and performance.now() values.

Note that the intent is that when generating Trace Event logs, the
server and the web browser run on the same machine, so there is no
wall-clock synchronisation issues between server and client.

Change-Id: Ie9e68b093b769cc942e1e1d17083febeb07ccf5e
Signed-off-by: Tor Lillqvist <tml@collabora.com>
2021-05-06 11:24:20 +03: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
Tor Lillqvist
686f1ba1cb Make WebSocketHandler::_isClient const and drop default values for bool parms
Avoiding default values for parameters makes the code easier to read.
Especially true for bool parameters. But sure, just a question of
taste.

Change-Id: I473f70bdfafe3a9ccfb325def8760d78fee7e9a6
Signed-off-by: Tor Lillqvist <tml@collabora.com>
2021-05-05 09:03:29 +03:00
Henry Castro
4e7fadb2b5 wsd: revisit log messages LOOLWSD.cpp
LOG_FTL = abnormal, crash, denied service
LOG_ERR = load, save, session, connection, wrong parameters
other cases LOG_WRN, LOG_INF

Change-Id: I80e8ee0de2b6858ec8e1c27276eb2058acdb2970
Signed-off-by: Henry Castro <hcastro@collabora.com>
2021-05-04 10:44:01 -04:00
Tor Lillqvist
fd1910c727 The Chrome format is called Trace Events, not Event Trace
Change-Id: I2515182d9369c3a25727dce0d3790e79de891bff
Signed-off-by: Tor Lillqvist <tml@collabora.com>
2021-05-04 15:12:14 +03:00
Tor Lillqvist
eb9c580c36 Introduce ways to toggle and tweak core Trace Event recording and logging
When toggling tile debugging in the Help>About, toggle Trace Event
recordning, too. Add a comment with an example of how to turn on
SAL_LOG overriding at the same place.

The following new messages from client to server are introduced:

traceeventrecording <start/stop>

    Starts or stops comphelper::TraceEvent recording.

sallogoverride <string>

    Overrides the SAL_LOG value, or stops overriding if no parameter
    or parameter is "default".

Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: I8b56c28cd99d39115cd796c44e5051d934d21a1f
Signed-off-by: Tor Lillqvist <tml@collabora.com>
2021-05-03 16:09:35 +03:00
Tor Lillqvist
be476d23b3 Produce a Chrome Event Trace file
It is (for now) produced (by the ProfileZone things in core) whenever
logging level is "trace". The Event Trace file pathname can be given
in the loolesd.xml file or on the loolwsd command line.

Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: I6d5829121e71460a4600ee94d2ebf51043c8893f
2021-05-03 16:09:35 +03:00
Ashod Nakashian
0dbecddb3a wsd: http: simplify sending response and shutting down the socket
Change-Id: Id4e32c8eb79458d060767a7a5ac26476e2f84331
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-05-02 22:35:39 -04:00
Ashod Nakashian
a21120412e wsd: explanation comment
Change-Id: I5104db5d20049132f88ca15a713bb3c17fb2d32d
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-05-02 22:35:39 -04:00
Ashod Nakashian
e0b5cddffc wsd: shared_ptr can dereference directly
Change-Id: Ie958c2c79da0b3ffa19de0c633e486a390240409
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-05-02 22:35:39 -04:00
Ashod Nakashian
4e7b0b10fe wsd: simplify assertion
Change-Id: I2cac7543fa20a39deba447e67e9c9cdb08cd3572
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
(cherry picked from commit 7188d4013a8bf00379610ec1b0a610c555674a2d)
2021-05-02 22:35:39 -04:00
Ashod Nakashian
c5490f628e wsd: enable fat writes in WebSocket
This enables writing multiple WS frames
at a time, up to the capacity (rounded
to the next full-frame's size).

Change-Id: I30d25f9ba1e405156d1e44886b2f3ac8017f0f3c
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-04-27 17:48:23 -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
ade93f5f57 wsd: more informative initialization failure log
In some rare cases Poco throws "Exists" exception.

It's not clear what causes it, so this should
log more of the original exception, hoping that
it would shed some light.

Change-Id: I51723f35c9e062c56608e8f7b80c9a65d3f0488f
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-04-27 08:09:49 -04:00
Ashod Nakashian
6444c35d21 wsd: mobileapp: fix a warning
Change-Id: Ie710a76f3cd5d96056648815ffe393ab2e58ac78
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
9742f91527 wsd: log the reason for terminating DocumentBroker
Change-Id: Ieef1d30bd4abc18e27cc057ac2374f730b8992c2
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-04-27 08:09:49 -04:00
Henry Castro
21c66b2352 wsd: revisit log messages DocumentBroker.cpp
LOG_FTL = abnormal, crash, denied service
LOG_ERR = load, save, session, connection, wrong parameters
other cases LOG_WRN, LOG_INF

Change-Id: I174a86f48e6b4107d0f846fd9af28a7ab1f62afc
Signed-off-by: Henry Castro <hcastro@collabora.com>
2021-04-15 10:53:00 -04:00
Michael Meeks
92af50e4b9 Initialize SSL un-conditionally.
Even if we use http:// locally via a tunnel the new outgoing socket
code needs SSL initialized to connect securely to remote servers.

Change-Id: If64a3838267182757591a8026097bf08d9ba732f
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2021-04-15 16:39:45 +02:00
Ashod Nakashian
0a73175764 wsd: reduce string copies
Change-Id: Ib38d7ebf1e66680779720cc1ce4d9bd07f9cab0a
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-04-11 01:05:20 -04:00
Ashod Nakashian
b12a4105fb wsd: WebSocketHandler fully supports http::Request
Change-Id: Ia5ff17e9aa8cbaded4e304be8c673b8f1575b6ce
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-04-11 01:05:20 -04:00
Ashod Nakashian
d6d4fe0ea5 wsd: use setbody in LOOLWSD and avoid manual plumbing
Change-Id: I32ce4eba855a0996eff3ae2d85245e167d23abd0
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-04-11 01:05:20 -04:00
Ashod Nakashian
64c494c2ee wsd: use http::Response in LOOLWSD
Change-Id: I70db5293e7c0a8dd6602cf015420b6070c0f956f
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-04-11 01:05:20 -04:00
Ashod Nakashian
a8b50f5801 wsd: use http::Response in LOOLWSD file serving
Change-Id: Ia2d592e8b279f69f257d5b216e05de2437fa3d60
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-04-11 01:05:20 -04:00
Ashod Nakashian
12c57cb1a0 wsd: use http::Response for LOOLWSD 400 errors
Change-Id: I22f9b78f1ed6500111697b6017b0e654f7b97def
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-04-11 01:05:20 -04:00
Ashod Nakashian
e1c1927cc6 wsd: use http::Response for LOOLWSD 401 and 404 errors
Change-Id: I1500939d68db3f68954fcf522d20080420b37e14
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-04-11 01:05:20 -04:00
Tor Lillqvist
75a3ab02ca Add an iOS setting for the user's name or nickname
Used for comments added to documents by the user.

The setting, like templateListURL, can be set through a mobile device
management system.

There is no trivial way on iOS for an app to programmatically find out
the name of the user, and that is good from a privacy point of view.

Fixes https://github.com/CollaboraOnline/online/issues/1843

Change-Id: Ie68fcbacf886ec8f1c74021a71879b38d4180c15
Signed-off-by: Tor Lillqvist <tml@collabora.com>
2021-04-08 00:37:05 +03:00
Ashod Nakashian
e6579d39ea wsd: set http 'Connection: close' header before disconnecting
Per the RFC, the server must set the 'Connection'
header to 'close' to signify that the current
request is the last.

With this patch, we now properly notify all the
clients when we do not intend on resuming communication.
Although, technically, there is no reason why we
shouldn't allow the client to reuse the connection,
we may consider that in the future.

See https://tools.ietf.org/html/rfc7230#section-6.3

Change-Id: Ic6250c0afe8124314a9122452040f6a75728a525
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-04-07 11:36:10 -04:00