Commit Graph

917 Commits (1b6af5e28d50c3a1152981537a385dfbb9a049a9)

Author SHA1 Message Date
Michael Meeks 1b6af5e28d killpoco: remove lots of redundant JSON includes.
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
Change-Id: I976c5b8d6763cbbf0ee5cadfa2f7335ec719fe85
2024-04-25 09:06:13 +02:00
Michael Meeks 9085ff7580 Improve DocumentBroker state dumping.
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
Change-Id: I091c67d8b72bcaa3d82cd4de7be9d5ceb8d9720d
2024-04-24 09:24:34 +01:00
Michael Meeks 7f7d901726 bgsave: default to background save off on upgrade for now.
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
Change-Id: I7cfceb1288dc2e05438653f3cedc9b7d32bc5fb8
2024-04-18 20:18:07 +01:00
Ashod Nakashian 1e206ac001 wsd: allow for recovering from unloading document
When the last connection is closed, we flag the
document for unloading, until we save and
unload and have nothing further to do. However,
if during that time a new client joins the
document, we reset the unloading state and
recover.

A previously failing and disabled test is now
re-enabled and passes.

Change-Id: I425a9286ec5df56064132e5e4227227761c65830
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2024-04-18 10:05:06 -04:00
Ashod Nakashian e690a739da wsd: support synchronous CheckFileInfo
In certain scenarios, such as with Proxy.php,
we don't have CheckFileInfo in advance and
need to request it before proceeding further.

This adds a wrapper to wait for the
CheckFileInfo request to complete.

Change-Id: I8afa955f841899eb667c02168a29a68c1dffb21b
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2024-04-17 10:18:33 +02:00
Michael Meeks af749c2237 bgsave: rename parameter to background, and add setting.
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
Change-Id: Ic49ec5715682b71461b49741d022fc7149aa5a13
2024-04-16 16:43:52 +01:00
Caolán McNamara b88d518622 unwanted extra quote at end of true in json
Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I66d80d415ea8e19823ccb7e6b3e8b6af1df51fbc
2024-04-16 12:04:17 +02:00
Michael Meeks 0b3b27cb72 bgsave: switch to using a 'save' command to the kit.
Also pass 'autosave' status in a more conventional way.

Ideally we would split 'save' away from a ChildSession / ClientSession
and have this on DocumentBroker / Document - for the future.

Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
Change-Id: I39a6caf8b17fa2fc2d940ae0d11bdc2d4da20b6c
2024-04-15 11:06:22 +01:00
Aron Budea 246e87fea2 wsd: Unconditionally compile support-key-enabled code paths
Signed-off-by: Aron Budea <aron.budea@collabora.com>
Change-Id: Iec477c223f2dc75e0be8b472c8439ca9311d6aae
2024-04-14 01:23:00 +01:00
Ashod Nakashian 958f4b0f55 wsd: merge downloadAdvance with download
Change-Id: I0f9ad626c78e81896e42f5a431b0f209a77f563a
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2024-04-03 14:26:28 +01:00
Ashod Nakashian 64b4339e00 wsd: pass uriPublic explicitly to download()
Change-Id: I7c333c83598c2a4847efcd96cd59bc595cdae49f
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2024-04-03 14:26:28 +01:00
Ashod Nakashian 25d10bf490 wsd: simpler downloadAdvance interface
Change-Id: Ibd8ba73b2f4e926cc078e66f53766ee99478f9d4
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2024-04-03 14:26:28 +01:00
Ashod Nakashian 72c368ea0e wsd: refactor the download logic in DocumentBroker
Change-Id: Ic916a8373664f2b4de8d8649bf160effb1fe3dfa
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2024-04-03 14:26:28 +01:00
Ashod Nakashian b2c980a91a wsd: refactor setting wopiInfo into the session
Change-Id: Id2850c43843cbb418e7c188efcd6d2e6bf652165
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2024-04-03 14:26:28 +01:00
Ashod Nakashian deb60c095d wsd: simplify uriPublic in DocumentBroker::download()
Change-Id: I5ca31e08716db4c0a47a952b89e6529b330b6370
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2024-04-03 14:26:28 +01:00
Ashod Nakashian e9591cfa25 wsd: pass uriPublic explicitly to downloadAdvance
Change-Id: I0ac6f32894ada50be59e9801b68a1918affd6a9e
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2024-04-03 14:26:28 +01:00
Ashod Nakashian ac589f5563 wsd: formatting
Change-Id: I365121f2ccfc1bf1f73f4f8e41a8d84e920da1ce
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2024-04-03 14:26:28 +01:00
Ashod Nakashian 577c1fb0d3 wsd: refactor the plugin processing
This reduces code duplication and makes
the code more readable by extracting
the huge block that processes plugins.

Change-Id: I2dc243173a4122ae1d5fc5b3fa2b40daff9664e4
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2024-04-03 14:26:28 +01:00
Ashod Nakashian 04526159df wsd: minor formatting
Change-Id: Ibe9d9d946fc9aba1b2ac754ef952dc6adda47961
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2024-04-03 14:26:28 +01:00
Ashod Nakashian de985834e2 wsd: simplify DocumentBroker construction
Change-Id: I5e908f0f5aed9146e14175eb79335fe9c80db2f2
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2024-04-03 14:26:28 +01:00
Ashod Nakashian 8e14087ef1 wsd: Support ahead-of-time document loading
Change-Id: Ia1cc7e42f7eea530097a37cce723b8833b998357
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2024-04-03 14:26:28 +01:00
Michael Meeks fd77301ebb polls: switch compiled in delays to 60 seconds.
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
2024-03-25 08:18:35 +00:00
Michael Meeks 005ba1567e PrisonerPoll - leave unused Kit sockets in the poll.
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>
2024-03-25 08:18:35 +00:00
Jaume Pujantell 8921e19d84 reduce uses of MOBILEAPP on some files
Reduce the uses of MOBILEAPP conditionals by using the isMobileApp
function.

Signed-off-by: Jaume Pujantell <jaume.pujantell@collabora.com>
Change-Id: If541307fbc457b342674cc560b6c53454f3904cf
2024-03-20 09:13:00 +01:00
Michael Meeks 5105e4202a unipoll cleanup - remove obsolete DocumentBroker mutex.
This should not have been necessary for a long time; but add
some assertions to help check.

Change-Id: Iedbc0bb57839209d1f1caeaab7094e335c881e57
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2024-03-19 20:44:59 -04:00
Rashesh Padia 464358ca70 fix: data loss when shutting down while using typer
- Docbroker only uploads the document when the document is already saved and
  there are no further modifications.
- But when using typer once dockerbroker saves the document and tries to upload
  there are already new changes to the document. Therefore, docbroker keeps on
  saving this new changes and keeps on skiping the upload as there are new
  changes to the document; until it times out

Signed-off-by: Rashesh Padia <rashesh.padia@collabora.com>
Change-Id: I427d37a6228299006530daddebdf4365af63588b
2024-03-19 19:42:20 +05:30
Gökay Şatır ea7c9c9fe6 Check session->isReadOnly along with getUserCanWrite.
This allows permission=readonly URL parameter.

Signed-off-by: Gökay Şatır <gokaysatir@gmail.com>
Change-Id: I02df9723cf90c961be2e8ce579304355420d0d11
2024-03-16 07:28:30 +03:00
Ashod Nakashian c121488a67 wsd: WopiStorage cleanup
Remove MOBILEAPP directives and create
stub WopiStorage and WOPIFileInfo.

Change-Id: I57cd5a008d625ac53ef23c4bb3872381af35560c
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2024-03-09 12:37:19 -05:00
Ashod Nakashian af29ad28b0 wsd: log the previous upload attempt result
Change-Id: I11a338024e18b72983c205f6afe02883b5d69398
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2024-03-05 07:10:34 -05:00
Ashod Nakashian 7570dd299c wsd: use RequestVettingStation for async loading
This replaces the synchronous loading logic
with the new asynchronous one.

Change-Id: I20fd7903cffbbd7c524d8051295113439ef75d5b
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2024-02-24 14:09:22 -05:00
Aron Budea 3b8f3d07f6 Replace Util::startsWith/endsWith w/ C++20 equivalent
Replace a few cases of Util::toString(...), too.

Signed-off-by: Aron Budea <aron.budea@collabora.com>
Change-Id: I53c5dbbdf2f60710e94add9dd137aa9becb7bd3e
2024-02-22 08:08:32 +01:00
Michael Meeks 7031c3b0ce cool#8328 - config header fixup.
config.h should be included as the 1st line in each source file.
It should not be included in headers.

config_version.h which changes on every commit should not be
included widely - so remove it from the HttpRequest heeader to
save tinderbox's ccache.

Fetch version info from helper methods rather than in-lining via
defines, to better encapsulate.

Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
Change-Id: If449a36f1ac61940f04d70d5f4180db389d9b4c4
2024-02-21 09:35:25 +00:00
Caolán McNamara 71a427c465 cid#344351 COPY_INSTEAD_OF_MOVE
and

cid#336280 COPY_INSTEAD_OF_MOVE
cid#318848 COPY_INSTEAD_OF_MOVE
cid#318964 COPY_INSTEAD_OF_MOVE
cid#344354 COPY_INSTEAD_OF_MOVE

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I60a904be4b5edf61cfd5b2efab81e5c1a089b661
2024-02-12 11:12:33 +01:00
Caolán McNamara 95c98805a0 cid#336284 COPY_INSTEAD_OF_MOVE
and

cid#336290 COPY_INSTEAD_OF_MOVE
cid#336288 COPY_INSTEAD_OF_MOVE
cid#336282 COPY_INSTEAD_OF_MOVE
cid#318980 COPY_INSTEAD_OF_MOVE
cid#318853 COPY_INSTEAD_OF_MOVE

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: Icf6447b8298432359ec37242427ce595f8de4160
2024-02-08 08:49:26 +01:00
Caolán McNamara d8041e9516 use a path name unrelated to the parent dir name
Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I622bc1569c775c57d7f268a063195706bb12be7b
2024-02-07 20:34:51 +00:00
Ashod Nakashian 6174fc3098 wsd: rescue the clipboard before autosaving on unload
This moves the clipboard resque logic earlier to
make sure it is cached before the Kit process
exits.

By putting the clipboard-fetching command before
the save-before-exit, we should get the clipboard
in most-all cases. There are still edge-cases
that can slip through, but they should be much
less frequent, and they will require much more
involved logic (tbd).

Change-Id: I0eff95c28524002a6131fa0a57ef8e09ae21ca59
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2024-02-05 11:52:02 +01:00
Ashod Nakashian d1ac610b50 wsd: new setupTransfer into DocBroker
Will be used for parallel loading, when we
transfer thread ownership to DocBroker.

Change-Id: I99dea58afc6c86d7937e32c8b3313676cc46d3b7
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2024-01-18 18:59:18 +00:00
Ashod Nakashian 8afdc40aca wsd: pass WopiFileInfo optionally to addSession
This is to allow for having gotten the WopiFileInfo
before creating DocBroker at all.

Change-Id: I0f21442860e09385e504b9a98049af286cc5b404
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2024-01-18 18:59:18 +00:00
Miklos Vajna 28665d45d2 wsd, DocumentBroker: check for missing child process
wsd/DocumentBroker.cpp:2861:32: runtime error: member call on null pointer of type 'WSProcess'
    #0 0x55cbce63d7d9 in DocumentBroker::disconnectSessionInternal(std::shared_ptr<ClientSession> const&) /home/vmiklos/git/collaboraonline/online-fuzz/wsd/DocumentBroker.cpp:2861:32
    #1 0x55cbce66c74d in DocumentBroker::removeSession(std::shared_ptr<ClientSession> const&) /home/vmiklos/git/collaboraonline/online-fuzz/wsd/DocumentBroker.cpp:2764:13
    #2 0x55cbce944614 in ClientSession::_handleInput(char const*, int) /home/vmiklos/git/collaboraonline/online-fuzz/wsd/ClientSession.cpp:886:24
    #3 0x55cbced66255 in Session::handleMessage(std::vector<char, std::allocator<char>> const&) /home/vmiklos/git/collaboraonline/online-fuzz/common/Session.cpp:271:13

Signed-off-by: Miklos Vajna <vmiklos@collabora.com>
Change-Id: I2a6f830de82ec8189312e57e6554a57909a0aaaa
2024-01-08 09:13:27 -05:00
Ashod Nakashian 61cf7b9601 wsd: clean up unused header includes
Clang-tidy recommendation driven header
include clean-up.

Change-Id: I30c32866b7798e70df0463ee6bc7a0bcc3de5049
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2024-01-08 08:38:48 +01:00
Michael Meeks 4dc2cd4e16 logging: reduce excessive logging noise re: tiles-on-fly.
Also better explain that we dump sessions twice.

Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
Change-Id: Iec3ad5b9f78f0572d43cfba1191bcec3584c0092
2024-01-08 08:32:12 +01:00
Ashod Nakashian b1f0834ac4 wsd: do not upload unmodified document
When always_save_on_exit=true we should
still not upload the document when it
isn't modified.

In this case, because we now always
save the document (forced) when
always_save_on_exit=true, and because
saving always generates a new file on
disk, with a new timestamp, we couldn't
detect that there are no modifications.

We now still force save, but ask Core
to skip it if the document is unmodified.

This is safe since we now always issue
the save, but rely on Core to do the
right thing. When the document is saved,
we do the normal upload as in that case
we know we have a new version of the
document, which must be uploaded.

Worth noting that the closedocument
command doesn't trigger the same path.
To reproduce the issue, we need a new
test that disconnects, instead of the
graceful closedocument command.

Change-Id: Iaa4e0363ed2eca124f2d1943393e65c0c187aa18
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2024-01-04 05:29:32 -05:00
Ashod Nakashian 7f2f946aec wsd: logging and cosmetics
Change-Id: I777db7d1879e84f341f11a90fce7abf8241f5ced
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2024-01-04 05:29:32 -05:00
Ashod Nakashian 7a327c337b wsd: force autoSave on always_save_on_exit
This forces autoSave when always_save_on_exit
is true. This is needed so we can guarantee
that we don't have modification and that
we upload if there has every been one.
The latter case is checked in
DocumentBroker::needToUploadToStorage(),
which is called from
DocumentBroker::checkAndUploadToStorage().

A new test reproduces the issue and defends
the fix.

Change-Id: I0b2105a57cfd7049ba7b1f63e62a700fdc3744c2
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2024-01-02 08:17:01 -05:00
Ashod Nakashian fb067faae4 wsd: quarantine: isQuarantineEnabled -> isEnabled and log it
As this is a member of the Quarantine class,
there is no need to have "Quarantine" in the
name. This was a hang-up from the time when
it was a static.

Now we can log the enabled-state.

Change-Id: Iab1cec4d90671cda175c1d320e4f3318dd7b89a1
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2024-01-02 10:57:20 +01:00
Ashod Nakashian c4470a9687 wsd: do not remove quarantine files explicitly
Let clearOldQuarantineVersions() remove quarantined
files only when necessary and per the config settings.

Change-Id: Ie1fb18c02d61a710546e9b5962ab8b7973c2066e
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-12-27 06:10:17 -05:00
Gökay Şatır ba536c3051 Make sure to set the correct normalized view id for the tiles.
When user switches to dark theme, previously requested tiles' normalizedViewIds may need to be updated.

Issue:
Users sometimes were getting tiles from the wrong theme.

Signed-off-by: Gökay Şatır <gokaysatir@gmail.com>
Change-Id: Ie3324eb3f4879da5bfd0738513409e190422a9c0
2023-12-13 14:05:22 +00:00
Michael Meeks eeea000242 Re-use the current time for a small efficiency win.
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
Change-Id: I1183a02c5b41554a059cc222f9de82b592ac6322
2023-12-09 21:56:01 +00:00
Michael Meeks 7382a56591 latency: switch tileprocessed to track wire-ids per-connection.
To manage latency, we need to keep the amount of data-in-flight
manageable, this was previously done per-tile - however this is
less useful in the era of small deltas, and seems over-complicated.

Instead track processed tiles by their wire-id to save time,
space & bandwidth.

Change-Id: I1039d8d4ca96fb172278a824fe1ffd55d9fff23e
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2023-12-09 21:56:01 +00:00
Michael Meeks 0e1972faba latency: don't throttle wsd -> kit rendering on render queue size.
Instead throttle rendering only based on the number of tiles on
the fly down the coolwsd <-> browser socket.

It is almost certainly better to let the Kit process sort and
prioritize rendering with a more holistic view of all rendering
requests, and to elide duplicates - rather than to stack-up some
requests in coolwsd.

Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
Change-Id: I566959306815ddc2742a0fe2694df6a1371c6852
2023-12-09 21:56:01 +00:00