Commit graph

190 commits

Author SHA1 Message Date
Ashod Nakashian
155bc06e24 wsd: de-duplicate assertCorrectThread
This merges multiple implementations of
assertCorrectThread and simplifies its
usage.

Change-Id: I7be5dea62c6046fb0412d7f885fcbcc4b66e3fd9
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-05-22 09:34:29 -04:00
Ashod Nakashian
ff1657934a wsd: simplify log streaming
Change-Id: Id22de0bc06680f957e7475f142bcaf1131fdbdb9
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-05-10 08:46:11 -04:00
Ashod Nakashian
2ea14b5221 wsd: reduce SocketPoll lock contention
We don't have to read the wakeup pipe
under a lock. So we no longer do.

Change-Id: I6bd724b9748add3022b4f9aa2268094b9818f3e5
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-04-15 23:07:38 +01:00
Ashod Nakashian
bbabcf52dc wsd: more tracing of socket and poll activity
Change-Id: Ia5cb6cfaf8108a9266b0a1daa55b0fbe1349177c
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-04-15 23:07:38 +01:00
Ashod Nakashian
896673c857 wsd: correct log argument order
Change-Id: I00cb3ccd740e8540341e45965cbe8460490acb8c
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-04-15 23:07:38 +01:00
Ashod Nakashian
587ba85aea wsd: always handle socket polls without skipping
We now always handle socket polls without skipping
when the number of sockets change. We verify the
socket FD of each socket before handlingPoll to
catch any violations of the preconditions.

This should avoid missing any events and also
handles timeouts better (which are checked
in handlePoll). It also protects against
unexpected modifications of the sockets, with
proper logging and assertion.

Change-Id: I5659eb57231a490e6c813e7a0222443b534713c6
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-04-14 18:02:14 +01:00
Ashod Nakashian
8facb429c2 wsd: make removeSockets private
Change-Id: I7171c67bbbe4682cf10e015e600fb25f03d4e5bb
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-04-14 18:02:14 +01:00
Ashod Nakashian
4968982a3d wsd: better merge new sockets into poll sockets
Change-Id: I4249ba4d35d8dfb2ff17c63af201276c77e2549b
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-04-14 18:02:14 +01:00
Ashod Nakashian
b82519400f wsd: update the poll round-robin index right before usage
Change-Id: I27f19c914449b689a530495681423a2906281698
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-04-14 18:02:14 +01:00
Ashod Nakashian
ec85f78458 wsd: drain the wakeup pipe on each read
Reading larger blocks should avoid having
the pipe back up when we accidentally
attempt more wakes than actual ones.

Change-Id: I7766230f60dbf069668ee7919f766e9093df7017
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-04-14 18:02:14 +01:00
Ashod Nakashian
75dbe7af53 wsd: better scope locality
Change-Id: I49156505dfb855ce00815c6afabc762951fcc4c8
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-04-14 11:30:14 +01:00
Ashod Nakashian
4089302362 wsd: better socket logging
Change-Id: I31b64ce1f174896a3bcfa5cd620e0babd7f425d1
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-04-14 11:30:14 +01:00
Ashod Nakashian
3dbfce54d3 wsd: helper to dump the state of an object as a string
Change-Id: Ib49a47be2dc37663ef06ac80be981c9f3c029814
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-04-11 08:03:01 -04:00
Ashod Nakashian
bca82f50ee wsd: better logging of the current socket being handled
Change-Id: Ieca96a685f5cfea24fde7251806746408e0bfbf8
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-04-11 08:03:01 -04:00
FedericoHeichou
985f284c89 Fix isLocal failing check with IPv4
Signed-off-by: FedericoHeichou <34757141+FedericoHeichou@users.noreply.github.com>
Change-Id: If6fa382102252908dac1fb80199bb332ce400aeb
2023-03-14 10:48:20 +01:00
Ashod Nakashian
29193de7cd wsd: improved socket creation/destruction logging
Change-Id: I3f2919b646aad4c7c8b2b464155066008fbe25ae
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-03-06 08:43:37 -05:00
Ashod Nakashian
0b4e9e071c wsd: minor improvements to socket logs
Change-Id: I4a07124e8adada4c7dbcf0a3b7b07ffa566c57d2
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-03-06 08:43:37 -05:00
Tor Lillqvist
31135177e4 Fix compiler warnings when building for WASM.
Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: I0fd4fe36cece9caaeb076a0e91894890186706d0
2023-02-12 15:55:24 +01:00
Tor Lillqvist
49660dbb94 Fix error in conversion from microseconds to whole milliseconds
I had added some extra debugging output to the !MOBILEAPP branch to
log values of timeoutMaxMicroS and timeoutMaxMS and was wondering why
I saw things like:

    timeoutMaxMicroS=5000000 timeoutMaxMS=5009

and

    timeoutMaxMicroS=0 timeoutMaxMS=9

Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: Iac8599ce5b00ef90d62eabc29c5d92858e276bb6
2023-01-03 11:54:17 +00:00
Ashod Nakashian
1b059bca0f wsd: better log levels
We no longer emit a fatal (FTL) log when
forced-exiting successfully.

Also, improved are some other logs to
better reflect the severity of the issue.

Change-Id: I22e79f685825f7ecd47cec76c9be9683deff2d55
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-12-21 19:41:38 -05:00
Ashod Nakashian
0c6413bf87 wsd: fix multi-part logging
This was a regression introduced in
14d96957cd.

The result was that multi-part logs were
not flushed and therefore not written to
the output.

Change-Id: Ib22a1da83209b00872d91ca05a940226cbb4552d
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-09-13 09:45:43 +02:00
Ashod Nakashian
e4bdd10b11 wsd: minor log improvements
Change-Id: Id75de0548383cc0f6e983a7b226dff6c7ade56eb
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-07-25 14:04:13 +01:00
Ashod Nakashian
ed3b1902b7 wsd: invoke handlePoll on all sockets
Before ed5569da30
we invoked handlePoll on all sockets in
each poll. But that's not true anymore.

Since i = _pollStartIndex; (line 432),
when we assigned previ = i; (line 451)
we made previ == _pollStartIndex, which
immediately broke the loop
while (previ != _pollStartIndex)
at line 438, causing handlePoll to be
called on one socket at a time (and
likely *not* the socket that had an event).

It's inefficient to poll and ignore the
result.

Now we do handle revents on multiple
sockets correctly and efficiently for
each ppoll() by going through all sockets
and handling based on whatever revents
gave us. We need to invoke the handler
of each socket to handle timeouts (i.e.
if we don't call the handler until
the socket gets an revent, we wouldn't
be able to support timeouts properly).

Notice that we still start at
a different socket each time (although
it's not entirely clear what advantage
that has, it's maintained all the same)
as the aforementioned patch does.

Change-Id: I9c0a482792aee7df5d44f4b63f173e574db36f97
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-07-19 18:31:50 +03:00
Ashod Nakashian
6259be6fbe wsd: better logging of unix socket binding
No need to complain when bind() didn't fail.

And assert when/if we are going to overflow.

Change-Id: I66f5ff1963c0afc6652afb5a7d017e197d945736
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-06-07 09:09:00 +01:00
Ashod Nakashian
3b9cc13b7a wsd: improved socket logging
More consistent logging of the socket FD.

Change-Id: Iee24ad4eb067969abfc06f78a768563351d264c7
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-06-07 09:09:00 +01:00
Ashod Nakashian
f43adb76ae wsd: make socket FD log prefix implicit and cleanup logs
Change-Id: I873d19b8d4149b85f2116d363301afea1aa0b2fd
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-06-07 09:09:00 +01:00
Ashod Nakashian
14d96957cd wsd: log macro cleanup
* Simplify log macros.
* Reduce expanded lines (faster compilation).
* Avoid flushing (since we always use ostringstream).

Change-Id: Id10c1a75b5af5d8cdba62d768192ab0a6a9e0aca
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-04-26 11:13:44 +03:00
Ashod Nakashian
b7b7801d8a wsd: remove identical simulateSocketError override
Since both implementations are identical, there
really is no benefit to having two version.

Change-Id: I4a5288243291c0d5706df8e8870b918fab425317
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-04-20 08:34:59 -04:00
Ashod Nakashian
d8745f288d wsd: logging and minor cosmetics
Change-Id: Ia6ba5b333c8caf742de27be46faf7265a1a777a5
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-04-06 18:33:45 -04:00
Ashod Nakashian
f74192d9ac wsd: always include the BIO errors in SSL logs
And improved socket logging in general while
making them more consistent.

Change-Id: I1ed7f2561476ca5370af91079d5d616804396f8e
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-03-21 08:57:41 +00:00
Ashod Nakashian
6c28ddb07c wsd: exit the kit when we fail to connect to wsd
This prevents the kit from becoming a zombie
when it has an early failure to connect to WSD.

Change-Id: I4e8203b2cc3d80822308236e5b47be0c0c96e9ae
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-02-24 07:38:13 -05:00
Ashod Nakashian
b53d353779 wsd: reduce debug and generally redundant logs
In 'debug' log-level we expect a detailed, but
still readable output. Having one area with
disproportionately large number of logs reduces
the overall utility of the log output.

This patch reduces a number of redundant log
entries, including errors that are already
logged. It also reduces the level of some
others from 'information' to 'debug' and
from 'debug' to 'trace'.

The goal is to make 'debug' level as useful as
possible to read the progress and be able to
understand what was going on, such that one is
able to decide which area to dig deeper into.
Then, trace level could be used to get more
insight into that area, if necessary. For
example, when investigating a test failure,
one first enables 'debug' logs and reads through.
Once a section between two debug entries is
identified as being of interest, enabling 'trace'
level logs becomes more productive as it's
now possible to easily reach the first DBG
entry and read through until the second one.

It's unfortunate that we don't have per-area
control for enabling/disabling logs, so it
is common to see more and more 'debug' log
entries added all around, making logs
less and less readable.

It is also a limitation of the levels we have
that we really only have 3 usable levels:
one, two, many. That is, 'information' for
the most important events, 'debug' for
technical details needed to investigate issues,
and 'trace' for everything else. ('warning'
and 'error' aren't really 'levels'; they have
semantics that makes them special-cases.)
So we have to avoid degrading one into the
other, or have differences without distinction.

If any of these entries are needed to be
displayed more frequently, changing them
back to 'debug' or even 'information' should
be done. Though for me they seem special
cases that don't benefit most log readings.

Change-Id: Id2c6a9dc027483b81a066b0b4b50a298c5eff449
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-02-24 07:38:13 -05:00
Ashod Nakashian
bef9c3ff65 wsd: dump all the state managers in DocBroker
This adds dumpState to DocumentState, SaveManager,
and StorageManager classes, and dumps all the
missing members.

Also, normalize the format and make it symmetric
and consistent.

Change-Id: Ie0cc8e07d13de60c33d64cd621abf4e815a4ef94
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-02-24 07:38:13 -05:00
Ashod Nakashian
52f2600cf9 wsd: test: embue all tests with a name and unify logs
Now the remaining tests that didn't have a name
get one and the logs are unified between old-
and new-style tests. Mostly.

This makes sure that all logs and assertions
properly log the test name and make test
failures easier to debug and fix.

Change-Id: Id159ffacc81642a6ec594c5143498408adab67cf
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-02-17 18:52:48 -05:00
Ashod Nakashian
2444e28059 wsd: reduce noisy logs
This reduces some logs from debug to trace,
especially in Socket where the amount of
activity is high, but the logs in question
don't add value in debug level.

Also supressed an error when superfluous.

This makes debug-level logs much more readable
and relevant to the main events.

Change-Id: Ie2698b56f320d15a09060cf2877477d9da0e1582
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-02-04 10:26:49 -05:00
Gleb Popov
4d64f2b466 Create a link to the master UDS file inside the jail when we aren't using abstract sockets.
Signed-off-by: Gleb Popov <6yearold@gmail.com>
Change-Id: I021b906ef545f4d3238f4c61650ced8da15b6374
2022-01-08 10:41:02 +00:00
Andras Timar
f07ff8c7e0 rename: remaining lool->cool changes
Signed-off-by: Andras Timar <andras.timar@collabora.com>
Change-Id: Ib7d4e804bebe52dead8d53b0e0bbaed0f08bf3d0
2021-11-18 14:14:11 +01:00
Tor Lillqvist
ed5569da30 Handle poll results in SocketPoll in a round-robin order
We don't want to always start with the most recently added socket.

Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: Ic4b4bf6c19c5d119e6e6f9b398789a4c77b47a10
2021-08-21 15:30:18 +01:00
Gleb Popov
20c2ab5663 Remove non-abstract unix socket files on shutdown.
Signed-off-by: Gleb Popov <6yearold@gmail.com>
Change-Id: I54773de6d4f777f9188921d5aa99c052f0f79b34
2021-07-31 07:43:45 +03:00
Gleb Popov
950a5c4d1a Use more sensible value for #ifdef when checking for abstract unix sockets.
Signed-off-by: Gleb Popov <6yearold@gmail.com>
Change-Id: Icfd849424659c8949f8f3554aa75a8a7ceaf7ac2
2021-07-31 07:43:45 +03:00
Gopi Krishna Menon
b3d5a2563c Add profilezone around kitPoll function and SocketPoll constructor
Add profile zone around kitPoll function and SocketPoll constructor to
improve trace event generation

Signed-off-by: Gopi Krishna Menon <krishnagopi487.github@outlook.com>
Change-Id: Ia46e9add59a57935997649fe39861a8d851e1ff0
2021-07-21 15:00:31 +03:00
Ashod Nakashian
4c87cc36ff wsd: Close socket hard when necessary
Also clear its input buffer explicitly.

Change-Id: I8badbb96d98eaf10433a65fcfd13b0d6d5893594
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>

Ignore input in a somewhat gentler way.

Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
Change-Id: I758302dc3bb1aa87f9fbfa726f73f4b9339e08c2
2021-07-19 17:31:55 +01:00
Ashod Nakashian
0d59630b48 wsd: killpoco: cert verification
Change-Id: Ie9bc96183d1e416ef4b9b455eefb1f9249b2f695
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-07-18 21:14:48 -04:00
Ashod Nakashian
f63d077916 wsd: ssl certificate verification requirements
Change-Id: I72ffa586310296f1986276c3007672c41146c92b
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-07-18 21:14:48 -04:00
Ashod Nakashian
f702c4efab wsd: support certificate verification
Change-Id: I912595f104e24dc66da9cf06bc211cb0c50c9ff0
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-07-18 21:14:48 -04:00
Michael Meeks
7ed4b4f7e7 Use larger write buffer size for UDS from kit -> wsd.
We send lots of large tile data this way, this should help
accelerate tile data transfer marginally.

Change-Id: I1deab7845c09dc65b1f44e9f9fc762f70ce94cc3
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2021-06-04 14:58:36 +01: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
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
Gleb Popov
742cda8b46 Don't try use abstract unix sockets on !Linux platforms.
Signed-off-by: Gleb Popov <6yearold@gmail.com>
Change-Id: Iaad2159ef2c5a45c52f0c7224d58a8160bb5f260
2021-04-30 20:30:56 +01:00
Gleb Popov
f11ca121a4 Use SOL_LOCAL value instead of 0 in getsockopt() calls.
Signed-off-by: Gleb Popov <6yearold@gmail.com>
Change-Id: I5a58a73541de2a32c5a03ebef5618b1541209d8d
2021-04-30 20:30:56 +01:00