Commit Graph

930 Commits (master)

Author SHA1 Message Date
Michael Meeks 25f2581a30 Revert this for now while we think more deeply.
This reverts commit 80b4e6d4ae.
2023-06-09 09:19:36 +01:00
Shehr Bano 80b4e6d4ae Fix: Speed-up callbacks
Signed-off-by: Shehr Bano <shehr.bano@collabora.com>
Change-Id: I796d71e48ae7110fb8d88eda781e362faba75aa2
2023-06-05 13:56:41 +02:00
Ashod Nakashian 756560642f wsd: test: better polling in tests
Shorter waits to break the polling
loop when the test finishes and we
need to terminate.

Change-Id: I79d9d89675d0a37f25a03b265b3ae636a90e57d5
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-05-31 07:40:11 -04:00
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 685e2fb0b8 wsd: http: return const& from const response getter
Change-Id: I5dc5282938a472148148d1dd6d009261bc09c7d6
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-05-22 09:34:29 -04:00
Ashod Nakashian 7ce18c8a13 wsd: http: cosmetic and log
Change-Id: I984ad71601b92b8042dc7984e7339f0804c8083b
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-05-22 09:34:29 -04:00
Ashod Nakashian a6551462e2 wsd: http: improved http::Session::handleIncomingMessage
The normal path is now streamlined and error handling
is at the end. We also now always set the disposition
to closed and fire onDisconnect() when disconnected
or hit an error.

Change-Id: I984ad71601b92b8042dc7984e7339f0804c8083b
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-05-15 19:14:21 -04:00
Ashod Nakashian d4b27f6643 killpoco: replace HTTP status codes
We use our own status codes, which
are type-safe and use streaming
operators to serialize and log.

Change-Id: I0eba7b16694866b5a79476a7ef4b1b78f7f9c176
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-05-11 07:21:42 -04:00
Ashod Nakashian 72cff36195 wsd: move streaming operator overloads
This is needed to correct overload
resolution of these operators.

Change-Id: I02c0859674efe112102a8d3833bfb0a30b1a6574
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-05-10 08:46:11 -04:00
Ashod Nakashian 0182af7a4a wsd: http: native support for logging http::Header
Change-Id: I8c34531e6f2616d98a4ee75fe8490d4ad25c45a9
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-05-10 08:46:11 -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 b556381406 wsd: return SSL_do_handshake error-codes unmodified
For some reason we only checked for the closed
socket case as failure and returned 0 in that case,
for error cases, we returned 1. Likely the API
had been modified in the early days, but this
return code was left lopsided.

This meant that even when the handshake failed, we
still called readIncomingData or writeOutgoindData,
depending on whether we wanted to read or write,
causing a rare race-condition.

When a client (HTTP request) connects to a server,
it needs to send the request, right after the
SSL handshake. SSL_do_handshake could need data
from the socket to complete the handshake. In such
a case it returns WANT_READ. Unfortunately,
because we always called SSL_read, the missing data
could have arrived between the SSL_do_handshake call
and the SSL_read call (a rather short duration, to
be sure, but an open window all the same).
SSL_read would of course read said data from the
socket and, since it still needs to finish the
handshake, will buffer it. It then returns the very
same error that the SSL_do_handshake returned:
WANT_READ. Of course we will oblige by polling with
POLLIN, which will time out (there is no more data
to come, and the server is waiting for *our* request
and has nothing to send us).

The only way this deadlock could break if
SSL_do_handshake was called (which will consume
the buffered data, return 1 to indicate handshake
has completed). Since we wouldn't call it unless
and until we get POLLIN, per WANT_READ, which won't
happen in this case. And since SSL_read doesn't call
SSL_do_handshake either, the request times out and
that's the end of it.

The fix is to not call SSL_read when the handshake
isn't complete and needs more data, which we do now.

Fortunately, we have very few SSL clients, outside
of unit-tests. Most notably the WOPI client. But
even then it's not a heavily used connection and
might not even be SSL-enabled (for LAN servers).

Change-Id: I04fd3dae151904194f3d7579dbf8c671b2580ffb
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-04-15 23:07:38 +01:00
Ashod Nakashian 49843a6af9 wsd: handle read failure on closed socket better
A rare edge-case happens when we have a socket
that is closed (and we get POLLHUP or POLLERR)
but upon reading the socket we get EAGAIN.

This was observed when simulating EAGAIN,
and it is possible that this is quite impossible
in practice (since we read only when we get
POLLIN), but at least for the unit-tests
we need to handle this case, so we don't
get random failures.

Change-Id: I77af1726066507af5d5ada68fe11b479a4e579e5
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-04-15 23:07:38 +01: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 7547e15d79 wsd: move pollingThread to private
There is no use-case for calling the
thread function of the SocketPoll
from outside.

Change-Id: Id8e87369494817aaab749d03d1cd4cd3724c2da1
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-04-14 11:30: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 f41ba11bad wsd: test: socket context logging
Change-Id: Ib3675985cf0e2d8864ed544d5e7c615d5fde2331
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
Ashod Nakashian 9596d5a0ab wsd: http: set http::Request log context
Change-Id: Ic8b9c1e7526ebf2f7c69f47f1bd98fdb9fc471ce
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-03-14 15:46:48 +01: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 9c39ebad1f wsd: string::empty() is clearer than size() == 0
Change-Id: If2e25d344b5718c35cb9ae7b7519010ee88f0f60
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-03-10 07:45:12 -05: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 903bb76c36 wsd: fix DEBUG_HTTP in HttpRequest
Change-Id: Iebc61b6632d33528ad362c943cb44cea56418b16
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-03-06 08:43:37 -05:00
Ashod Nakashian e3deb96152 wsd: log the socket FD of http::Response
Change-Id: Ibd02ee6656f4db2e7b09e0b7702a6db55ec8269e
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-03-06 08:43:37 -05:00
Ashod Nakashian 8fac85b5c2 wsd: log the socket FD of http::Session
Change-Id: I9c0eb3fde6577185bce63277147a6a453311f1ec
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-03-06 08:43:37 -05:00
Ashod Nakashian 359017ef10 wsd: log the socket FD of PrisonerRequestDispatcher
Change-Id: I6a000e53d8baca231a2fb8f6df2251a4f57d9876
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-03-06 08:43:37 -05:00
Ashod Nakashian 547c97988a wsd: log the socket FD of WebSocketHandler
Change-Id: I5c06ae44437cac32fb726861a5bc49b149ecd0c4
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-03-06 08:43:37 -05:00
Ashod Nakashian 1dd2aba82d wsd: log the socket FD of ProtocolHandlerInterface
Change-Id: I362aca685f79868bdf685695d625a832eee02821
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-03-06 08:43:37 -05:00
Ashod Nakashian da29e2c45d wsd: log the socket number of http::Request
Change-Id: Ia0d52b38a1da73ae92765169d5e5064015dc7f40
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
Ashod Nakashian 44a27110e1 wsd: better logging
Change-Id: I98bc45d287c44beb10bfe6fbe02d208f37531515
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-01-27 08:44:53 -05:00
Ashod Nakashian b9eb4111ae wsd: http: define named HTTP status codes
This replaces the hard-coded status-code
numbers with named compile-time constants.

Change-Id: Ibe678fb2c533b29efd696e4430f5377523eeb298
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-01-24 07:58:07 -05: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 629ff27992 wsd: minor log improvements
Change-Id: I6dba0540310bb9cafc31a63e92da306eeff8953d
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-12-22 10:10:08 +01:00
Ashod Nakashian b644904448 wsd: asyncRequest needs only wakeup its own poll thread
Apparently it woke up the world unnecessarily.

Change-Id: Iad65215da898b017860e7d7b803771f657a3e1ab
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-12-21 19:41:38 -05:00
Ashod Nakashian 53f8317e47 wsd: do not warn when waking up dead poll-thread at shutdown
When shutting down, SocketPoll threads asynchronously
stop and exit. This fundamental race means the warning
is useless and noisy.

Change-Id: I3ca9044c9a68689abb7e8f692fffd10509eadab6
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-12-21 19:41:38 -05:00
Ashod Nakashian 206de871fb wsd: send WS close frame only when we have a socket
sendCloseFrame does check for the socket to be
there, but it logs an error if it isn't because
it assumes we expect to have a socket.

Since we are shutting down, this code could
be triggered on destruction when we no
longer have the socket.

Change-Id: I622a24394632159aa71c1c21c33c0f8a2d5c6250
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-12-21 19:41:38 -05:00
Ashod Nakashian cd980c9ba6 wsd: wait InitialPingDelayMicroS before first ping
It seems we were always pinging immediately on a
newly created WebSocket, even before upgrading to
WS, which logged a warning. That was because we
create the WebSocketHandler instance with a
timed-out lastPingSentTime.

Here we correctly set lastPingSentTime such that
it times out *after* InitialPingDelayMicroS has
elapsed. This gives it time to upgrade the
socket to WS and avoid the warning.

Change-Id: I6004348b9b4bd29f614d9e010fb7649da2bca338
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-12-21 19:41:38 -05: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 8bbf7717db wsd: change message logging level to trace
Messages are high-frequency events and logging
them at debug level is too noisy. Increase the
level to trace.

Debug level should produce legible entries that
outline the main activities, rather than log
each message. That is best done at trace level.

Change-Id: I722ab8b58e0adcab6ecb2f8c571966af0d952051
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-12-07 17:33:11 +03:00
Ashod Nakashian a89ed3b535 wsd: test: correctly capture UnitBase in WebSocketHandler
The UnitBase reference must be a member of the class.

Change-Id: Ia0b10ccb7f0f3419470f014a23c7a48d3b390239
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-11-30 05:14:55 -05:00
Ashod Nakashian 1f0b5f5a16 wsd: avoid locking weak_ptr when possible
In WebSocketHandler, we often already have
locked the weak_ptr, so we can pass that
shared_ptr around.

Change-Id: Iaedceff0acbfd747bdf89771f9309ff6f6642b53
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-11-29 03:45:32 -05:00
Ashod Nakashian 6d8e9dc758 wsd: simplify WebSocketHandler construction
This merges the two constructors, since they
overlap and initialize most members identically.

Change-Id: Idd2af580606be92bb5733b1a0f1e1e63b84b6498
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-11-29 03:45:32 -05:00
Ashod Nakashian 7a74227164 wsd: http: improved logs
Change-Id: I075c1069b489b45283cfac75d8c8c90543a10644
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-11-28 12:50:36 +01:00
Ashod Nakashian c6365b8b18 wsd: log closed-socket state on read explicitly
Change-Id: I6a0c4c701f0ab726017d287528c761636ba91be0
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-11-28 12:50:36 +01:00
Michael Meeks ac1c386c37 Tag polls correctly as running synchronously in the client thread.
This avoids wakeup warning us that the thread is not started to wakeup.

Change-Id: Ifd5c483717024cb1c30521433d0d10acead01e2f
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2022-11-21 18:54:35 -05:00
Ashod Nakashian 7fa1cff0af wsd: improve various logs
Change-Id: Ib4c0792eeba4da76c800f6afe4737f91c4d319f7
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-11-21 08:45:34 -05:00
Ashod Nakashian 21069484ec wsd: ssl: log the operation context in errors
Change-Id: I8b2bd675d5341354f240476ea80450b2dbbe7b76
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-11-21 08:45:34 -05:00
Ashod Nakashian 7bf0e980bb wsd: http: correct written data-size reporting
Change-Id: I9268b0c8bd99c1f06d20916503f7df7cdbde0cc4
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-11-21 08:45:34 -05:00
Ashod Nakashian 571f80c260 wsd: test: capture the UnitBase instance in WebSocketHandler
With multi-tests, the instance of UnitBase may
change while an old test thread is still running.
Here we capture the instance of the test so we
do not publish events into a different (newer)
test.

Change-Id: I3ca2c058cbd81d4077b140f24f60f3f20f12b9b5
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-11-21 08:45:17 -05:00
Ashod Nakashian f3b42a9941 wsd: log more info on exception in WebSocketHandler
Change-Id: I73e5a0eb17b9a059aaad2e78c64242e3ed28a8c4
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-11-20 07:50:12 -05:00
Ashod Nakashian 76ac5d09c2 wsd: support embedded media
Change-Id: I28c1a813bad22c49ae759b89ad90e377890acddb
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-10-25 09:16:36 +02:00
Gabriel Masei 3aa81e8ba1 add 'Connection: close' header to http responses.
If the connection is closed right after the response was sent
then it's wise to add 'Connection: close' header to the response
so that the client optimizes its behaviour: e.g. does not reuse
the socket for further http requests. Normally  a client should
retry a request if the reuse of an old socket fails and that
should solve the problem but still this is an overhead.

Signed-off-by: Gabriel Masei <gabriel.masei@1and1.ro>
Change-Id: I29f1498610c567024def3beb1ad7014f2c15a232
2022-10-04 13:45:58 +02:00
Ashod Nakashian 3d7ee42c38 wsd: improve SSL error reporting
ERR_get_error cleared the returned error,
which meant the subsequent call to print
the error in string form, using
ERR_print_errors_cb, didn't find anything
to report.

Change-Id: If131a8cc0d2c1d8bbf705ed38f144b38abf6c8c6
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-09-13 08:31:42 -04: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
Aron Budea c4975d01e5 Split config.h into separate headers to avoid extensive rebuild
Eg. if only the version was changed, config.h was updated, and
everything was recompiled.

New structure, maintain these manually:
config.h.in - for configured variables that are stable if
              configuration parameters are unchanged
config_version.h.in - for version/hash related variables

----
config_unused.h.in - still generated by autoheader with all
                     variables, don't use it

Signed-off-by: Aron Budea <aron.budea@collabora.com>
Change-Id: Id9a50a9f1e798a3b3814778d8683b7d7cb57bb29
2022-09-05 12:32:49 +01:00
Michael Meeks ef09966978 mutex include cleanup.
Change-Id: I63d4184260d204a9d5f7658ad51fbe63dbb3c9e4
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2022-08-31 21:31:31 +01:00
Michael Meeks b475bb6018 UTF8 validation: print out offset of problem in hex to match the dump.
Change-Id: I72dfde708121f3893f934c1428d806e4c268a4cf
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2022-08-27 08:21:28 -04:00
Andras Timar cf6e22c22c Fix typos in comments
Signed-off-by: Andras Timar <andras.timar@collabora.com>
Change-Id: I813f652b516c79f350b46317e589b91e0ef39a1a
2022-08-23 18:37:44 +02:00
Ashod Nakashian 81399bff64 fuzzers: fixup HttpEcho
This improves the performance of fuzzing
and removes the checks that can't be guaranteed.

And fixes a test failure.

Change-Id: I987fe15b098c00d9a3d60077f0581d2ef35e306c
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-08-17 08:55:12 -04:00
Ashod Nakashian eca9b0bb4e wsd: http: check for timeout in sync requests
This should cap the loop either when we timeout
or when termination is flagged.

Change-Id: I78a6b05df99d6bac5286e4b1e4957829ea91c500
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-08-17 08:55:12 -04:00
Ashod Nakashian a87d1ae54f wsd: add HttpEcho fuzzer
This is a full round-trip http fuzzer.
It can achieve >1000 iterations per second
on a single 2 Ghz core, even while going
through the network loopback layer.
The advantage is that more networking code
is fuzzed this way, including not just
the http code, but also the sockets.

Change-Id: I75d21bd0e25221ee6621097a2605d62c4bb2ae4d
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-08-17 08:55:12 -04:00
Aron Budea d30b423c07 Replace #ifdef-s with #if-s, and enable -Wundef
...for variables coming from configure.ac.

Signed-off-by: Aron Budea <aron.budea@collabora.com>
Change-Id: I39ebd21c4cb56d2a3bd38fdc35dc59b5f1fd4b49
2022-08-03 11:07:38 +02:00
Ashod Nakashian 2986e1e9b5 wsd: test: send WS close-frame only once
Without this patch, we may end up repeatedly
sending close-frame. This impacts tests only.

Change-Id: I3c9a0cb14c9103d002508b1199647f6ff9761230
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-08-02 09:24:46 -04:00
Ashod Nakashian 5c874d1b9f wsd: test: correct shutdown UnitWebSocket
We cannot invoke the socket from outside the
SocketPoll and we must flag for async shutdown.

Change-Id: I223e24f5fe48a79a9d751c7cf5cdf9d720c22f7d
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-08-02 09:24:46 -04:00
Ashod Nakashian 78ab6136f7 wsd: test: correct shutdown of WebSocketSession
Change-Id: I7d1aad4c26c4144038b9ed782a0f27454bb02eeb
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-08-02 09:24:46 -04:00
Ashod Nakashian 3cbee21ec1 wsd: test: break WebSocketHandler polling when terminating
Change-Id: I0b177a031a8d1115823ad5161d5129aa9447c20f
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-08-02 09:24:46 -04:00
Ashod Nakashian 7fb9a0588f wsd: test: killpoco for UnitClose
We now use our http::Socket and SocketPoll
instead of Poco.

Change-Id: I728f9c975b67da76dbbc78e94f1fb5f224c9bc57
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-08-02 09:24:46 -04:00
Ashod Nakashian b972c7e0a1 wsd: test: clang-tidy some args
Change-Id: If9dcbfb2e3eab5617fee60b8f233e400e3d38916
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-08-02 09:24:46 -04:00
Ashod Nakashian 60e64ec8c9 wsd: test: remove COOLWebSocket from WopiTestServer
Change-Id: Ia56c2a7f34503907fb1257b966125e4d94a61645
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-08-02 09:24:46 -04:00
Ashod Nakashian a1553144fa wsd: http: improved logging
Change-Id: I6576e184aa23f722a01223119ce29b509c063231
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-08-02 07:51:52 -04: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 068907c7dd wsd: http: do not assert on net::connect returning nullptr
Apparently this is an issue for proxy.php.

Change-Id: I18090f17f22fe3145e7fa2364992a34a7e722f1b
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-07-03 18:03:35 -04:00
Henry Castro 92b2d9f6aa net: add "response" getter function
non constant.

Change-Id: I08c74100003f294ea5a513273507cfea548807eb
Signed-off-by: Henry Castro <hcastro@collabora.com>
2022-06-27 16:04:32 +01:00
Henry Castro 342a42997a net: add getter funtion "getUrl"
Change-Id: I23dd49f8f6dac784961395c6bb38e56d215b8387
Signed-off-by: Henry Castro <hcastro@collabora.com>
2022-06-27 16:04:32 +01:00
Ashod Nakashian ae71f8be82 wsd: test: filterSendMessage -> filterSendWebSocketMessage
Change-Id: I0254c05e12cde676de8fde99e16f7eface09dceb
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-06-27 14:07:08 +01:00
Ashod Nakashian 67c3b9548d wsd: http: support shutting down the socket
Change-Id: I9559a126048abd79db37579b5a9ca7282b0485e5
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-06-24 07:08:55 +01:00
Ashod Nakashian 48b510d4f4 wsd: test: fix heap-use-after-free
In HttpRequestTests::test500GetStatuses, since we reused
the http::Session without removing from SocketPoll,
it is possible for the poll thread to access the
Session object while we create a new request, where
we replace its Response and Socket members.

To avoid that, we can try to remove the http::Session
instance from the SocketPoll. Alternatively, we
can create a new one for each request, which is
what we do here.

Below is the results of ASan, for the record.

==949494==ERROR: AddressSanitizer: heap-use-after-free on address 0x61700005afe0 at pc 0x55dc0c092c75 bp 0x7f8b539e5a10 sp 0x7f8b539e5a08
READ of size 4 at 0x61700005afe0 thread T10 (HttpAsyncReqPol)
    #0 0x55dc0c092c74 in http::Response::logPrefix(std::ostream&) const /home/ash/prj/lo/online/test/../net/HttpRequest.hpp:835:66
    #1 0x55dc0c08f499 in http::Response::readData(char const*, long) /home/ash/prj/lo/online/test/../net/HttpRequest.cpp:641:5
    #2 0x55dc0c0998c9 in http::Session::handleIncomingMessage(SocketDisposition&) /home/ash/prj/lo/online/test/../net/HttpRequest.hpp:1248:41
    #3 0x55dc0c0f0c3b in StreamSocket::handlePoll(SocketDisposition&, std::chrono::time_point<std::chrono::_V2::steady_clock, std::chrono::duration<long, std::ratio<1l, 1000000000l> > >, int) /home/ash/prj/lo/online/test/../net/Socket.hpp:1339:33
    #4 0x55dc0c0b092d in SocketPoll::poll(long) /home/ash/prj/lo/online/test/../net/Socket.cpp:444:34
    #5 0x55dc0c10407c in SocketPoll::poll(std::chrono::duration<long, std::ratio<1l, 1000000l> >) /home/ash/prj/lo/online/test/../net/Socket.hpp:691:61
    #6 0x55dc0c10407c in SocketPoll::pollingThread() /home/ash/prj/lo/online/test/../net/Socket.hpp:648:13
    #7 0x55dc0c0ac445 in SocketPoll::pollingThreadEntry() /home/ash/prj/lo/online/test/../net/Socket.cpp:299:9
    #8 0x55dc0c12b6b9 in void std::__invoke_impl<void, void (SocketPoll::*)(), SocketPoll*>(std::__invoke_memfun_deref, void (SocketPoll::*&&)(), SocketPoll*&&) /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/invoke.h:73:14
    #9 0x55dc0c12b590 in std::__invoke_result<void (SocketPoll::*)(), SocketPoll*>::type std::__invoke<void (SocketPoll::*)(), SocketPoll*>(void (SocketPoll::*&&)(), SocketPoll*&&) /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/invoke.h:95:14
    #10 0x55dc0c12b574 in void std:🧵:_Invoker<std::tuple<void (SocketPoll::*)(), SocketPoll*> >::_M_invoke<0ul, 1ul>(std::_Index_tuple<0ul, 1ul>) /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/thread:264:13
    #11 0x55dc0c12b463 in std:🧵:_Invoker<std::tuple<void (SocketPoll::*)(), SocketPoll*> >::operator()() /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/thread:271:11
    #12 0x55dc0c12b463 in std:🧵:_State_impl<std:🧵:_Invoker<std::tuple<void (SocketPoll::*)(), SocketPoll*> > >::_M_run() /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/thread:215:13
    #13 0x7f8b5a08cde3  (/usr/lib/x86_64-linux-gnu/libstdc++.so.6+0xd6de3) (BuildId: c90e6603c7cdf84713cd445700a575d3ea446d9b)
    #14 0x7f8b59e4c608 in start_thread /build/glibc-SzIz7B/glibc-2.31/nptl/pthread_create.c:477:8
    #15 0x7f8b59d44132 in __clone /build/glibc-SzIz7B/glibc-2.31/misc/../sysdeps/unix/sysv/linux/x86_64/clone.S:95

0x61700005afe0 is located 736 bytes inside of 744-byte region [0x61700005ad00,0x61700005afe8)
freed by thread T0 here:
LLVMSymbolizer: error reading file: No such file or directory
    #0 0x55dc0bfe43dd in operator delete(void*) (/home/ash/prj/lo/online/test/unithttplib+0x20d3dd) (BuildId: 7954f6bea5efa6c39ca02e7033c014e826b9f5fd)
    #1 0x55dc0c1fe168 in std::_Sp_counted_ptr<http::Response*, (__gnu_cxx::_Lock_policy)2>::_M_dispose() /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/shared_ptr_base.h:380:9
    #2 0x55dc0c033768 in std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_release() /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/shared_ptr_base.h:158:6
    #3 0x55dc0c0335d5 in std::__shared_count<(__gnu_cxx::_Lock_policy)2>::~__shared_count() /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/shared_ptr_base.h:733:11
    #4 0x55dc0c1f972c in std::__shared_ptr<http::Response, (__gnu_cxx::_Lock_policy)2>::~__shared_ptr() /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/shared_ptr_base.h:1183:31
    #5 0x55dc0c1f972c in std::enable_if<__sp_is_constructible<http::Response, http::Response>::value, void>::type std::__shared_ptr<http::Response, (__gnu_cxx::_Lock_policy)2>::reset<http::Response>(http::Response*) /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/shared_ptr_base.h:1309:4
    #6 0x55dc0c1f972c in http::Session::newRequest(http::Request) /home/ash/prj/lo/online/test/../net/HttpRequest.hpp:1174:19
    #7 0x55dc0c1ee08b in http::Session::asyncRequest(http::Request const&, SocketPoll&) /home/ash/prj/lo/online/test/../net/HttpRequest.hpp:1079:9
    #8 0x55dc0c1b718f in HttpRequestTests::test500GetStatuses() /home/ash/prj/lo/online/test/HttpRequestTests.cpp:515:9
    #9 0x55dc0c219ec9 in void std::__invoke_impl<void, void (HttpRequestTests::*&)(), HttpRequestTests*&>(std::__invoke_memfun_deref, void (HttpRequestTests::*&)(), HttpRequestTests*&) /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/invoke.h:73:14
    #10 0x55dc0c219de0 in std::__invoke_result<void (HttpRequestTests::*&)(), HttpRequestTests*&>::type std::__invoke<void (HttpRequestTests::*&)(), HttpRequestTests*&>(void (HttpRequestTests::*&)(), HttpRequestTests*&) /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/invoke.h:95:14
    #11 0x55dc0c219dbc in void std::_Bind<void (HttpRequestTests::* (HttpRequestTests*))()>::__call<void, 0ul>(std::tuple<>&&, std::_Index_tuple<0ul>) /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/functional:416:11
    #12 0x55dc0c219d47 in void std::_Bind<void (HttpRequestTests::* (HttpRequestTests*))()>::operator()<void>() /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/functional:499:17
    #13 0x55dc0c219d47 in void std::__invoke_impl<void, std::_Bind<void (HttpRequestTests::* (HttpRequestTests*))()>&>(std::__invoke_other, std::_Bind<void (HttpRequestTests::* (HttpRequestTests*))()>&) /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/invoke.h:60:14
    #14 0x55dc0c219d47 in std::enable_if<is_invocable_r_v<void, std::_Bind<void (HttpRequestTests::* (HttpRequestTests*))()>&>, void>::type std::__invoke_r<void, std::_Bind<void (HttpRequestTests::* (HttpRequestTests*))()>&>(std::_Bind<void (HttpRequestTests::* (HttpRequestTests*))()>&) /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/invoke.h:110:2
    #15 0x55dc0c219a72 in std::_Function_handler<void (), std::_Bind<void (HttpRequestTests::* (HttpRequestTests*))()> >::_M_invoke(std::_Any_data const&) /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/std_function.h:291:9
    #16 0x55dc0c09776b in std::function<void ()>::operator()() const /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/std_function.h:622:14
    #17 0x55dc0c219713 in CppUnit::TestCaller<HttpRequestTests>::runTest() /usr/include/cppunit/TestCaller.h:175:7
    #18 0x7f8b5ab23614 in CppUnit::TestCaseMethodFunctor::operator()() const (/usr/lib/x86_64-linux-gnu/libcppunit-1.15.so.1+0x24614) (BuildId: 4329d55843a6cf32b3e88d4d9aec95035315b163)
    #19 0x7ffdc354a41f  ([stack]+0x2b41f)

previously allocated by thread T0 here:
    #0 0x55dc0bfe3b7d in operator new(unsigned long) (/home/ash/prj/lo/online/test/unithttplib+0x20cb7d) (BuildId: 7954f6bea5efa6c39ca02e7033c014e826b9f5fd)
    #1 0x55dc0c1f969c in http::Session::newRequest(http::Request) /home/ash/prj/lo/online/test/../net/HttpRequest.hpp:1174:25
    #2 0x55dc0c1ee08b in http::Session::asyncRequest(http::Request const&, SocketPoll&) /home/ash/prj/lo/online/test/../net/HttpRequest.hpp:1079:9
    #3 0x55dc0c1b718f in HttpRequestTests::test500GetStatuses() /home/ash/prj/lo/online/test/HttpRequestTests.cpp:515:9
    #4 0x55dc0c219ec9 in void std::__invoke_impl<void, void (HttpRequestTests::*&)(), HttpRequestTests*&>(std::__invoke_memfun_deref, void (HttpRequestTests::*&)(), HttpRequestTests*&) /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/invoke.h:73:14
    #5 0x55dc0c219de0 in std::__invoke_result<void (HttpRequestTests::*&)(), HttpRequestTests*&>::type std::__invoke<void (HttpRequestTests::*&)(), HttpRequestTests*&>(void (HttpRequestTests::*&)(), HttpRequestTests*&) /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/invoke.h:95:14
    #6 0x55dc0c219dbc in void std::_Bind<void (HttpRequestTests::* (HttpRequestTests*))()>::__call<void, 0ul>(std::tuple<>&&, std::_Index_tuple<0ul>) /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/functional:416:11
    #7 0x55dc0c219d47 in void std::_Bind<void (HttpRequestTests::* (HttpRequestTests*))()>::operator()<void>() /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/functional:499:17
    #8 0x55dc0c219d47 in void std::__invoke_impl<void, std::_Bind<void (HttpRequestTests::* (HttpRequestTests*))()>&>(std::__invoke_other, std::_Bind<void (HttpRequestTests::* (HttpRequestTests*))()>&) /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/invoke.h:60:14
    #9 0x55dc0c219d47 in std::enable_if<is_invocable_r_v<void, std::_Bind<void (HttpRequestTests::* (HttpRequestTests*))()>&>, void>::type std::__invoke_r<void, std::_Bind<void (HttpRequestTests::* (HttpRequestTests*))()>&>(std::_Bind<void (HttpRequestTests::* (HttpRequestTests*))()>&) /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/invoke.h:110:2
    #10 0x55dc0c219a72 in std::_Function_handler<void (), std::_Bind<void (HttpRequestTests::* (HttpRequestTests*))()> >::_M_invoke(std::_Any_data const&) /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/std_function.h:291:9
    #11 0x55dc0c09776b in std::function<void ()>::operator()() const /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/std_function.h:622:14
    #12 0x55dc0c219713 in CppUnit::TestCaller<HttpRequestTests>::runTest() /usr/include/cppunit/TestCaller.h:175:7
    #13 0x7f8b5ab23614 in CppUnit::TestCaseMethodFunctor::operator()() const (/usr/lib/x86_64-linux-gnu/libcppunit-1.15.so.1+0x24614) (BuildId: 4329d55843a6cf32b3e88d4d9aec95035315b163)
    #14 0x7ffdc354a41f  ([stack]+0x2b41f)

Thread T10 (HttpAsyncReqPol) created by T0 here:
    #0 0x55dc0bf922bc in __interceptor_pthread_create (/home/ash/prj/lo/online/test/unithttplib+0x1bb2bc) (BuildId: 7954f6bea5efa6c39ca02e7033c014e826b9f5fd)
    #1 0x7f8b5a08d0a8 in std:🧵:_M_start_thread(std::unique_ptr<std:🧵:_State, std::default_delete<std:🧵:_State> >, void (*)()) (/usr/lib/x86_64-linux-gnu/libstdc++.so.6+0xd70a8) (BuildId: c90e6603c7cdf84713cd445700a575d3ea446d9b)
    #2 0x55dc0c0aa467 in SocketPoll::startThread() /home/ash/prj/lo/online/test/../net/Socket.cpp:238:23
    #3 0x55dc0c1b57b3 in HttpRequestTests::test500GetStatuses() /home/ash/prj/lo/online/test/HttpRequestTests.cpp:482:16
    #4 0x55dc0c219ec9 in void std::__invoke_impl<void, void (HttpRequestTests::*&)(), HttpRequestTests*&>(std::__invoke_memfun_deref, void (HttpRequestTests::*&)(), HttpRequestTests*&) /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/invoke.h:73:14
    #5 0x55dc0c219de0 in std::__invoke_result<void (HttpRequestTests::*&)(), HttpRequestTests*&>::type std::__invoke<void (HttpRequestTests::*&)(), HttpRequestTests*&>(void (HttpRequestTests::*&)(), HttpRequestTests*&) /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/invoke.h:95:14
    #6 0x55dc0c219dbc in void std::_Bind<void (HttpRequestTests::* (HttpRequestTests*))()>::__call<void, 0ul>(std::tuple<>&&, std::_Index_tuple<0ul>) /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/functional:416:11
    #7 0x55dc0c219d47 in void std::_Bind<void (HttpRequestTests::* (HttpRequestTests*))()>::operator()<void>() /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/functional:499:17
    #8 0x55dc0c219d47 in void std::__invoke_impl<void, std::_Bind<void (HttpRequestTests::* (HttpRequestTests*))()>&>(std::__invoke_other, std::_Bind<void (HttpRequestTests::* (HttpRequestTests*))()>&) /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/invoke.h:60:14
    #9 0x55dc0c219d47 in std::enable_if<is_invocable_r_v<void, std::_Bind<void (HttpRequestTests::* (HttpRequestTests*))()>&>, void>::type std::__invoke_r<void, std::_Bind<void (HttpRequestTests::* (HttpRequestTests*))()>&>(std::_Bind<void (HttpRequestTests::* (HttpRequestTests*))()>&) /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/invoke.h:110:2
    #10 0x55dc0c219a72 in std::_Function_handler<void (), std::_Bind<void (HttpRequestTests::* (HttpRequestTests*))()> >::_M_invoke(std::_Any_data const&) /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/std_function.h:291:9
    #11 0x55dc0c09776b in std::function<void ()>::operator()() const /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/std_function.h:622:14
    #12 0x55dc0c219713 in CppUnit::TestCaller<HttpRequestTests>::runTest() /usr/include/cppunit/TestCaller.h:175:7
    #13 0x7f8b5ab23614 in CppUnit::TestCaseMethodFunctor::operator()() const (/usr/lib/x86_64-linux-gnu/libcppunit-1.15.so.1+0x24614) (BuildId: 4329d55843a6cf32b3e88d4d9aec95035315b163)
    #14 0x7ffdc354a41f  ([stack]+0x2b41f)

SUMMARY: AddressSanitizer: heap-use-after-free /home/ash/prj/lo/online/test/../net/HttpRequest.hpp:835:66 in http::Response::logPrefix(std::ostream&) const
Shadow bytes around the buggy address:
  0x0c2e800035a0: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x0c2e800035b0: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x0c2e800035c0: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x0c2e800035d0: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x0c2e800035e0: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
=>0x0c2e800035f0: fd fd fd fd fd fd fd fd fd fd fd fd[fd]fa fa fa
  0x0c2e80003600: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c2e80003610: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x0c2e80003620: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x0c2e80003630: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x0c2e80003640: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07
  Heap left redzone:       fa
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
==949494==ABORTING

Change-Id: I5e1539c3adbab9b5027d84cc1dbab4b90271c458
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-06-24 07:08:55 +01:00
Ashod Nakashian 562cfcae01 wsd: cosmetics and assertion
Change-Id: Ib89d1cb684250e0ebc3455423cbd991d8eecef56
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-06-07 09:09:00 +01: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 5bdd977410 wsd: simplify socket read logging
Change-Id: I083b86d6c8e6e2b3dc7b14836409281792d7b0bf
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 98ae362e91 wsd: handle socket closed on read better
A corner case where read doesn't return 0
on a closed socket can result in a stuck
state where we attempt to read when we
do get ECONNRESET (which we didn't check
on reads).

This makes the interface of readIncomingData
the same as writeOutgoingData by returning
the actual return value of the read syscall.

So now we handle both return 0 as well as
error codes returned on failed calls.

The logic hasn't changed, just that now
we handle errors better and similar to the
write case.

Change-Id: I0b38a63da4e6c92a482948478d5d8d446e0b8b58
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-06-03 20:16:59 -04:00
Michael Meeks 6de4eb865e socket: only wakeup the mainloop on addCallback for the 1st callback.
Change-Id: I96d9f0d46a5557ba464664456ec82605780f7de1
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2022-05-26 19:53:11 -04:00
Ashod Nakashian dccdf9fafa wds: enable experimental blocks unconditionally
This enables code that was protected with
EnableExperimental in the socket logic (and one
case in DocBroker). These changes are now deemed
safe to enable permanently.

Change-Id: Ie62f5d7bd281ade90f38d654b51b104b8d1f14bc
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-05-23 17:00:31 +01:00
Ashod Nakashian 6458e00bc4 wsd: return status from writeOutgoingData
Without knowing whether the write succeeded
or failed, we cannot trust errno has our
error or some earlier and unrelated error.

This was caught when there were two sockets,
one of which disconnected. The write to the
disconnected one returned -1 and set errno
to ECONNRESET. We subsequently wrote to the
second socket, which succeeded. However,
because errno wasn't reset, and since
writeOutgoingData didn't return anything
to indicate the success, errno's ECONNRESET
value meant the second socket was also
disconnected, which was incorrect.

writeOutgoingData now returns the last return
value from writeData so we can make informed
decision as to whether to check errno or not.

Also, to avoid incorrecly propagating errno,
we now capture errno only when readData and
writeData return -1. This has the nice
side-effect that we reset errno to 0 when
no errors occur during our call.

Change-Id: I911b31390f37cc71938bc4a6ae75393dbf24bb9d
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-04-30 20:41:26 +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 e9b26cdf53 wsd: use the default DH parameters in SSL
OpenSSL 3 deprecated the manual DH parameter
functions. Instead, it encourages the use
of the built-in parameters. Since this
API also works on the 1.1 version, we only
need the manual parameters for older versions.

Change-Id: I900cc11c3ca09f1d85b7d88cfbf537d802f69846
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-04-22 09:47:19 +02: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 4c1a168757 wsd: remove argument default-value
Single-use default argument.

Change-Id: I1085465c0dbdf6cbda934277feca61781b67f45c
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-04-20 08:34:59 -04:00
Ashod Nakashian f6ca40b4fd wsd: do not close the socket while have data to read
The last burst of data arrives with POLLHUP.
If during the read we hit any errors, including
EAGAIN, for whatever reason, we may lose the
data if we don't attempt reading again later.

The only way to guarantee that we do not have
any more data to read, when we get POLLHUP,
is to poll until we either get no POLLIN or
read returns 0 indicating the socket is closed,

Oddly, read(2) sometimes returns 0 without
POLLHUP ever being set, and sometimes we
do get POLLHUP while POLLIN still set. This
implies that poll and read aren't consistent
in how they detect and report the close
condition. Luckily, with this patch we can
handle all cases without any complications.

This was caught through simulateSocketError,
which when it injects EAGAIN on the very
last read, when the socket is closed, causes
error as the response is partially or
completely lost (because we never read it).

The behavioral change should only be
observable with EnableExperimental.

Change-Id: I77260f98d5dd5050c5f9b202b9effd501191336b
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-04-14 10:48:45 +01:00
Ashod Nakashian 806cb5676b wsd: detect ECONNRESET and EPIPE after writes
This extends the detection of connection termination
for writes via ECONNRESET and EPIPE.
For some reason ECONNRESET was not detected.

This patch avoids extra polling to detect connection
termination and makes the cleanup faster.

The changes are guarded by EnableExperimental to avoid
any unexpected change of behavior.

Change-Id: I2ae3803f025d3cf756f86460e47aedc984249509
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-04-14 10:48:45 +01:00
Ashod Nakashian 1da8d6dd24 wsd: use STATE_ENUM for http
Change-Id: Iaacf03856b9a07286f4fdf1f1eac34f2b75d2244
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-04-06 18:33:45 -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
Michael Meeks db63703d0c Validate as utf-8 all Websocket text messages in debug mode.
Ensure that rendersearchresult: is terminated, and identified as binary.

Change-Id: I84e83c63351cd0aac0923bf7c833b14c1be2c051
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2022-04-04 20:46:11 +01:00
Ashod Nakashian 11f31b0ba4 wsd: test SSL hostname
Change-Id: I0895d90d2c9be8a76afd209446ae39cd33fa5d2e
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-04-01 10:33:55 +01:00
Ashod Nakashian 71e1e54eb5 wsd: hostname is needed for SSL SNI
Since the hostname argument is passed
to both the base class of SslStreamSocket
and SSL_set_tlsext_host_name, and since
the base class's getter, also called
hostname(), is hidden by the argument,
we cannot move it.

An empty hostname can result in 403 Forbidden
from the server due to missing Server Name
Indication (SNI).

Change-Id: I27990f64f17ec3c81a4dd543a078807629cd0c20
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-03-27 22:32:38 +02:00
Ashod Nakashian 4d2351e37f wsd: reduce logging noise in socket reads
Change-Id: I4305baf828ccb1ae71d3b3b12fa90a7aeb5e0928
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-03-23 13:31:58 +01:00
Ashod Nakashian e164cb4a4d wsd: trace poll events and revents flags arround ppoll
Change-Id: If6aedff69a6421a16eec9f86fed6d0ea381ecc0c
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-03-21 08:57:41 +00: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 1bb21868b2 wsd: reduce polling when blocked on ssl handshake
While SSL is handshaking, there can be no general
application data communication. During that early
stage of connecting we have data to send (the
request, headers, etc.) and so we poll on POLLOUT.
Naturally, we also always want to poll on POLLIN,
because we can never know when there is data to
read (especially true for web-sockets).

The problem is when SSL will not send data just
yet because it is handshaking. It is typically
waiting for handshake negotiation data to read,
so when we POLLOUT, poll immediately returns, but
writing (via SSL_write) fails with WANTS_READ
error. This goes on in a busy-loop until the
negotiation data is available for read and the
handshake is completed. Very inefficient.

The solution is to poll on whatever SSL needs
during the handshake, exclusively. Once the
handshake is complete, we poll on whatever we
need. However, SSL can renegotiate at any time,
so we also merge with what it needs.

In addition, we avoid the unnecessary read when
poll doesn't give us POLLIN in revents, since the
read will more likely than not fail (except in
the rare case when data becomes available in the
interim). Notice that SSL_read will return
SSL_WANTS_READ when there is no data, which
is misleading (since SSL isn't in need of data to
read at all, nor are we, for that matter).
Best not to do noisy reads unnecessarily.

These changes are disabled by default and can
be enabled via the experimental_features option.

Change-Id: I6a7ed7d871ed257b30062cc720a8b8c7acbab3b7
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-03-17 18:46:46 -04: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
Ashod Nakashian c9082aea86 wsd: enforce TLSv1.2 as the minimum acceptable version
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
(cherry picked from commit dad7ed85e97afe0e4f5229b1de125aada9a8c2e8)

Change-Id: I5683f835f37f67ee353a0b629a4662c7c78787a6
2022-01-10 21:26:38 +01:00
Szymon Kłos c155b9569b Handle exceptions in Socket messages processing
Don't stop processing all messages when one caused an exception.
Try/catch where messages are processed in the loop so we don't
ignore other messages:
* handleTCPStream
* handleIncomingMessage

Signed-off-by: Szymon Kłos <szymon.klos@collabora.com>
Change-Id: Idb8c9cf72a7912e7e508e429821b4ee32c9b122b
2022-01-09 13:15:36 -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
Michael Meeks 5da4116731 Buffer: remove _size member and calculate it from _offset as needed.
Change-Id: I96bd949f1e9c460fbaf69967072e85cf45141acd
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2021-11-30 09:32:45 +00:00
Michael Meeks a958b30d56 Buffer: erase fully when we wrote everything that is left.
This avoids memory hanging around, _buffer.size() is not data
left as seen in pkill -USR1 output:

coolwsd[25677]:  Buffer size: 0 offset: 421811

Change-Id: I0c2eef9435230cf864854cbc95cd587e39d240ac
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2021-11-30 09:32:45 +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
Luboš Luňák 897c5df270 make Socket use Buffer for input buffer too
SteamSocket::eraseFirstInputBytes() removes from the beginning
of std::vector, which is generally slow. If the buffer becomes
too big, which it may under a load, then the function will get
slow, which in turn will likely lead to the buffer getting even
bigger because of accumulated backlog.

The Buffer class is optimized for removal at the beginning,
so use it instead of std::vector, including some API additions
for it to be an in-place replacement where it's used.

Signed-off-by: Luboš Luňák <l.lunak@collabora.com>
Change-Id: I4cf7ec56c908c7d3df391dc3f8e230ad32abb162
2021-10-26 12:11:58 +02:00
Michael Meeks 72f8f5d30e stress: store and dump some statistics.
Change-Id: Ied5eb12888b1466c155ecfd291785a95ea897db9
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2021-10-02 21:24:15 +01:00
Ashod Nakashian 347fd43f7c wsd: chunked transfer and tests
Change-Id: I07f7f126891f4d6b5137b45bf91cbcaa11796cda
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
(cherry picked from commit 866cb8f2f2)
2021-09-26 17:02:01 -04:00
Ashod Nakashian 9e5043db47 wsd: http: reason phrase is optional
Change-Id: I1bd402b26081a8ff35178c836a5eaa22fd47d033
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
(cherry picked from commit 0134e3329c)
2021-09-26 17:02:01 -04:00
Szymon Kłos e457aa8b4e Don't try to set empty hostname for SNI
to reduce logging warnings

Signed-off-by: Szymon Kłos <szymon.klos@collabora.com>
Change-Id: I9e1dcb16489f4cec692028b86d377ae776ac44e4
2021-09-15 09:34:56 +02:00
Ashod Nakashian 24acdaf89b wsd: throw when an invalid URL is used to create an http session
Change-Id: I2d2eb90badf4f02ec4f2e4c4071fc76b23a92928
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
(cherry picked from commit c16ad44470)
2021-09-13 09:40:09 -04: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
Michael Meeks e0d7337877 Host: header don't append port for standard ports.
HA Proxy doesn't tolerate this very happily cf.

https: //serverfault.com/questions/502443/ignore-port-numbers-in-haproxy-host-header-matches/502630
Change-Id: Id285f8acd0e168a734cabd9eccc4a01fe323ab84
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2021-08-13 09:36:27 +05:30
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
Gleb Popov 0dd30ba28f Remove unused private class member.
Signed-off-by: Gleb Popov <6yearold@gmail.com>
Change-Id: I38b29c06220d2493dc9d47a0ac9b077e3bafd512
2021-07-30 16:43:29 +03:00
Szymon Kłos 541f6a76d3 ssl: setup hostname for SNI
For some servers we receive failure with HTTP 403 Forbidden in WOPI::CheckFileInfo

"Reason: The client software did not provide a hostname using Server
Name Indication (SNI), which is required to access this server"

fixes #2771 : https://github.com/CollaboraOnline/online/issues/2771

Signed-off-by: Szymon Kłos <szymon.klos@collabora.com>
Change-Id: I761b179580481f8882a4526c1d8be4f1c14ad929
2021-07-22 12:40:05 +02: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
Tor Lillqvist 8b6ee5b8bf No need for the template class MessageQueueBase
Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: Ie007344f9a0ffe7fdf767cb9e9069db99aa224b9
2021-07-21 09:54:28 +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
Miklos Vajna 18d4c58442 http response: if the result doesn't fit, then consider that a fatal error
This is really a garbage in -> garbage out situation.

Signed-off-by: Miklos Vajna <vmiklos@collabora.com>
Change-Id: Ic1c33f44081f259e5cf5994ad901e1593fe8dfcf
2021-07-19 13:38:00 +02:00
Miklos Vajna 32a654eecb http response: simplify the condition if the result would fit
Given that "digit" is always less than 16, we can avoid the "- digit"
in the condition (because the division turns that into 0 anyway), making
it effectively constexpr.

Signed-off-by: Miklos Vajna <vmiklos@collabora.com>
Change-Id: Iaf9e53d3543f2237c00768f214114a02a4746020
2021-07-19 12:42:38 +02: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
Ashod Nakashian 0690f23ee4 wsd: move isLocalhost to a common area
Change-Id: I2a7986863138a254a6d74644112f5cd60bb898cd
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-07-18 21:14:48 -04:00
Miklos Vajna 57d3d0f391 http response: check if result would fit into chunkLen
Signed-off-by: Miklos Vajna <vmiklos@collabora.com>
Change-Id: I6e3b73461653d2ab3cedaa3f6ca7fbfd2a826edb
2021-07-08 14:51:11 +02:00
Dennis Francis 7e9b038ded net: show call-site file/line for assertCorrect...
...Thread.

Conflicts:
	net/Socket.hpp
	net/SslSocket.hpp

Signed-off-by: Dennis Francis <dennis.francis@collabora.com>
Change-Id: I92b8f4b52e7bd60b69305c1916eed8a14a4c1560
2021-07-02 16:48:46 +05:30
Michael Meeks e289597315 Add a processtoidle event implementation.
This can be used to accelerate unit tests by allowing us to ensure
that all pending work is done between a 'processtoidle' message being
sent and an 'idle' being returned. This can be much faster than waiting
a defined length of time.

Change-Id: I6d96de205d1fd34a22e0ddbd2709bf806a97b33c
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2021-06-29 17:12:01 +01:00
Ashod Nakashian 5a310a2232 wsd: separate client SSL context from the server
Change-Id: I4d86f733a16e6c76340b18ff836831ebe6acfd4d
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-06-23 23:39:34 -04:00
Ashod Nakashian a9e650a8db wsd: separate the SSL locks from the context
Change-Id: I2b1742054d5cec16ae3cf90e2098de40eeade4a8
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-06-23 23:39:34 -04:00