so we can use the platform ca-bundle
Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I7324a5c8414b234a0fb2e085e3915e71eff89182
Possibly the combination of "gzip" and us being unhelpful about
lengths could lead to browser hangs; who can say.
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
Change-Id: I632dfc46afde3883544292d687bdff023bccc8ac
net/NetUtil.cpp:65:23: error: no matching constructor for initialization of 'net::DNSCacheEntry'
queries.push_back(DNSCacheEntry(addressToCheck, hostEntry, now));
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Went wrong in commit 5be3ccc871 (cache DNS
results for 20 seconds, 2024-05-14), the rest of the code builds with
this toolchain.
Signed-off-by: Miklos Vajna <vmiklos@collabora.com>
Change-Id: Idc8ed4d88a7f955cf2cdc1e10ac9931823950126
Significantly calmer and less frenzied logging output.
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
Change-Id: I0f1782c0b8f10ac3427bac479ded2862f2b40b7a
Now we always send callbacks as soon as possible back to wsd from the
kit. This has several implications:
1. even when InputProcessing is disabled we will send outbound
progress updates.
2. we should send callbacks much more quickly without waiting for
other queue events to be processed eg. tilecombine:
We also drastically simplify storage of callbacks, avoiding lots of
re-parsing of the same strings, and allow much more efficient
comparison and merging at a small space cost in queue size.
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
Change-Id: Ia1ede5406767f895616a52775316ee6ab1c5db09
We need to get more helpful structure into this message, and add a
type=bg flag to handle background progress messages.
Add unit test for merging progress: setvalue commands.
Simplify ProtocolHandler sendTextMessage with a std::string wrapper.
Android code needs manual testing.
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
Change-Id: I54ce807e2fc5de80118905e68557a95e637fbd18
Somehow this state can get confused in a bgsave process:
Kit Document:
...
inputProcessingEnabled: false
...
SocketPoll:
Poll [kit] with 1 socket - wakeup rfd: 39 wfd: 45
fd events rbuffered wbuffered rtotal wtotal
52 0x1 process 0 0 r: 825
'process' should read 'ignore' for disabled input.
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
Change-Id: I787eebe6fda3ae1b527d7605b8813fa764e81890
Hard closing without shutdown is necessary, but we continued to poll
and read on an fd that would be re-used to open eg. a ZIP file:
[ kitbgsv_007_001 ] TRC #19: Incoming WebSocket data of 13522 bytes: 50 4B 03 04 14 00 00 08 00 00 29 9C 90 58 33 26 AC A8 2F 00 00 00 2F 00 00 00 08 00 00 00 6D 69 | PK........)..X3&../.../.......m"
...
[ kitbgsv_007_001 ] ERR #19: An unfragmented message or the first fragment of a fragmented message must have the opcode different than 0| net/WebSocketHandler.hpp:452
which would then close the file unhelpfully.
Not removing the socketHandler when cleaning up means that
we trigger the ForKit's ServerWSHandler::onDisconnect which
SigUtil::setTerminationFlag() causing all 2nd kit processes
to expire on start.
We also want to ensure that we update the thread-id of the last
forkit process before we start removing sockets and checking
thread-ids.
We want to get rid of the parent process' sockets we inherited
but don't need very cleanly post fork.
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
Change-Id: I82966f4421fc96df552fd50cf81c8b0bc92b9bbb
which is more efficient than repeatedly erasing in a vector.
Signed-off-by: Noel Grandin <noel.grandin@collabora.co.uk>
Change-Id: Iebd41130b37a67ffd74fa2d692b83220b1cab3f4
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
we picked something obscure, and clearly aarch64 took advantage of
not adding something obscure unnecessary for backwards compatibility
on that arch
Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I097ef24c98e23931a3997c743d17d52c0afd52b7
Remove toErase list; instead null socket pointers earlier
to make things more deterministic.
Simplify toErase path, by just removing null sockets.
Check _socketPoll array bounds to cope with a re-entrant
mutation - imperfect; but the fd comparison will help.
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
Change-Id: I27d81358a7d80b939b50ce4ccb1b2178a091a360
Don't wait for the other end to acknowledge closing the socket.
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
Change-Id: If5e4bb6d9c5148c0e0c61d59c233f6cf5594c577
Before spawning a child thread we want to close wakeups and
remove them from our global list to avoid the child waking the
parent.
However - if we are re-using a SocketPoll in a forked child,
we need to be able to create new wakeup sockets, so factor
out for re-use.
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
Change-Id: I06b088e02127482a65cd9666114ca9a93fd5ca7b
shutdown closes a socket in both the parent and the child process,
which is not what we want when forking a bgsave process - and
certainly not for the socketpair we communicate down.
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
Change-Id: I10418e9c7f5edca60f257a60f11ba396984d39b2
This will enable thread joining before fork for bgsave.
Change-Id: I68c7c53f892f5edef861137c48759c7ccb8532ab
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
By tracking the thread-id, we can deliver a SIGUSR2 to the right
thread at the right time; this avoids perf polling our uninteresting
watchdog thread.
In that thread use Caolan's suitably obscure futimestat system-call,
so that we can record based on that to see only slow things:
perf record -e syscalls:sys_enter_futimesat -ag --call-graph dwarf,65528
Change-Id: Iad05d8589fdc9541a7d0599f63625d2cde5fdf89
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
Forkit forking children is done in response to socket messages,
and parent process death should kill us too.
In general if we are relying on a poll to spin to achieve
something, we have a performance bug; this should exacerbate them
to flush them out.
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
Change-Id: I60d1c3b3c2532bbd686a3d3cfdea10f2a541a19a
This lets us detect when Kit processes die without waiting for
the poll() timeout and feebly spinning the PrisonerPoll loop.
Instead we get notified immediately; but to do this we then need
to be able to safely transfer the socket between SocketPolls.
SocketPoll's should own Sockets - so by switching ChildProcess to
use a weak_ptr and also the NewChildren list - we can have standard
ownership and a sensible transfer between SocketPolls. A Socket is
owned either by PrisonerPoll or a DocumentBroker in the normal way.
Clean the NewChildren list as/when children are unexpectedly killed
apparently there are still some ownership issues probably around
the strong ChildProcess _ws pointer.
Change-Id: Ie541a9d03e36aee53fd57c45953e0de21ebe1828
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
WebSocketSession is used exclusively for tests,
so it's best that it is located in the test
directory.
Change-Id: I88333d619902df7991c3f26b94ed309246446ae0
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
Reduce the uses of MOBILEAPP conditionals by using the isMobileApp
function.
Signed-off-by: Jaume Pujantell <jaume.pujantell@collabora.com>
Change-Id: If541307fbc457b342674cc560b6c53454f3904cf
The explicit header entries were needed
with Poco, but since we always set them
in our http::Response constructor, these
are redundant.
Change-Id: Ifde48fd3048018747dae3e84560b31960e511a25
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
We always create http::Response instances
with these headers. These explicit entries
are vestiges from Poco sockets.
Change-Id: I65c263e95b253e22e4e6deae57fffc5616311c84
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
This may not look hyper-elegant, but using ~Socket to do this
calls 'shutdown' first on the sockets, which closes the parent's
duplicate of the socket very unhelpfully. So close instead.
Don't touch and thus COW memory. We will leave the Socket Poll
around un-used, and un-polling from eg. the ForKit in the Kit
process.
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
Change-Id: I1328dee0278ce39350194c617acffa114887d523
<timar> net/clientnb.cpp:117:10: error: ‘shared_ptr’ in namespace ‘std’ does not name a template type
<timar> 117 | std::shared_ptr<WebSocket> getWebSocket()
<timar> | ^~~~~~~~~~
<timar> net/clientnb.cpp:38:1: note: ‘std::shared_ptr’ is defined in header ‘<memory>’; did you forget to ‘#include <memory>’?
IWYU agrees it's a missing include even if this builds for me by
accident.
Signed-off-by: Miklos Vajna <vmiklos@collabora.com>
Change-Id: I367ef3efcf2bdaf1b69c4bf21ef168e03807365c
Useful to have a Unix socket-pair to communicate with
a forked process.
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
Change-Id: Ic4ad1eee62b6d3b40a03bc8e59bce6e0e16efc28
Seems browsers start to ping servers on their websockets, so don't
warn about that.
We trim memory left and right in clients, that doesn't deserve a
warning either.
Change-Id: I7bdcc99d167a8df3c847a1893dee8cd9123250f2
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
We use [[maybe_unused]] to reduce explicit supression
especially under compile-time directives.
Change-Id: Ic5f3f3227a80efe52097cb35520d05b9cdaacb42
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>