Commit graph

54 commits

Author SHA1 Message Date
Ashod Nakashian
346a063d0a loolwsd: fix regression to handling tile command
Change-Id: Idedf25f3756ea1e04daf17540b1a57e1e7af8448
Reviewed-on: https://gerrit.libreoffice.org/24679
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-05-05 14:22:53 +00:00
Pranav Kant
7734f2557a loolwsd: Do not allow viewing sessions to change parts
bccu#1433, bccu#1757 related.

Piggyback editlock information to tile messages so that kit can
use that information to allow changing parts only for messages
with editlock.

... and decline tile render request for tile messages without editlock
information

Change-Id: I9cedb870cd977741375665cb258d04c818481a14
2016-05-05 14:28:03 +05:30
Ashod Nakashian
909c996a6d bccu#1774: poor API never fails to frustrate
The tile and tilecombine messages apparently have optional
appendages at their rear ends. Not one, but two (at least).

While the first (timestamp) seems to be truely optional
(in the sense that leaving it out doesn't break anything,)
the same can't be said of the second (id).

For Impress slides this id is used to identify the slide
to which the tile belongs. Or rather the slide being
rendered, as it seems meaningful only for the slide
thumbnails.

Previously the complete arguments of tile were copied
verbatim from the input to the output (i.e. back to the
client) and so any extra payload was also echoed back.

But when id is missing (when expected) loleaflet not
only fails to show these tiles (understandably,) but
it also fails to show the scrollbar for said slide
thumbnails altogether!

With the new logic to move the tile communication to
the child socket instead of the clients, the arguments
are parsed and then serialized back in the response.
So all fields must be explicitly known in advance.

This change is necessary because tilecombine is broken
to tile commands and so both share common code. This
means that echoing back the request verbatim will
break loleaflet since tilecombine arguments (which
is a list) is not a valid response (which has the
format of tile). So the internal representation
has to be something neutral/common.

The fix is to parse the timestamp and id only when
provided and to echo back the id only in that case.

Change-Id: Ic97cf0de4083d412a4b3543e8b9a8713ac27a27c
Reviewed-on: https://gerrit.libreoffice.org/24669
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-05-05 02:41:59 +00:00
Ashod Nakashian
cd8d48e6bb loolwsd: tile logs
Change-Id: Id5c8b688c36038dc6f02ad95ad1c43412dcd2c31
Reviewed-on: https://gerrit.libreoffice.org/24668
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-05-05 02:34:13 +00:00
Ashod Nakashian
fedb3f520a loolwsd: factored out common tile message
Change-Id: I39600821e3c9c40f3a63343b167cddb3e42b7072
Reviewed-on: https://gerrit.libreoffice.org/24667
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-05-05 02:33:52 +00:00
Ashod Nakashian
df67c4a31c loolwsd: move tilecombine handling into lokit
Change-Id: I32854769c5260444b0e97c112a141028f1cda179
Reviewed-on: https://gerrit.libreoffice.org/24641
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-05-04 10:36:38 +00:00
Ashod Nakashian
a240f2666f loolwsd: tile traffic is now completely centralized
WSD's DocumentBroker and Kit's Document now handle
the communication of tiles as well as all aspects
of rendering, caching, unifying requests and
distributing results etc.

Change-Id: Ie22fbaaae26b91185ee348ec7077f30430eec0f6
Reviewed-on: https://gerrit.libreoffice.org/24640
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-05-04 10:36:01 +00:00
Ashod Nakashian
ff0d4a3a91 Revert "Revert "loolwsd: establish communication with...
...child from DocumentBroker""

Restore the communication with child from DocumentBroker.

This reverts commit 20ab6e8ae7.

Change-Id: I248bededff7074d8fb482b2cdd172048f80c02b2
Reviewed-on: https://gerrit.libreoffice.org/24639
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-05-04 10:33:48 +00:00
Ashod Nakashian
431bab2824 loolwsd: fix autosave regression
Autosave should only save when the user has been idle
for a certain time, or the periodic autosave time elapses.

The document is considered for autosave only when it's modified.

Change-Id: Ia239173ff6636e52c1a2b7e1f6bf9bd6860175ed
Reviewed-on: https://gerrit.libreoffice.org/24602
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-05-03 03:05:44 +00:00
Ashod Nakashian
6c57e9be4d loolwsd: helper to assert a lock is already taken
Change-Id: Id28f7a39a4d45ea6ad391015364467dc8ded3e66
Reviewed-on: https://gerrit.libreoffice.org/24599
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-05-03 00:00:13 +00:00
Jan Holesovsky
20ab6e8ae7 Revert "loolwsd: establish communication with child from DocumentBroker"
Unfortunately this causes a deadlock in the unit tests.

This reverts commit 10417c9447.
2016-05-02 11:49:58 +02:00
Ashod Nakashian
10417c9447 loolwsd: establish communication with child from DocumentBroker
The WebSocket that each child created with WSD is not used
except to request the child to load the document a client
requests. Beyond this point, it was not utilized for anything.

In fact, there are no handlers in WSD for messages coming
from the child; it is a one-way communication.

That is until now. With the move to unify communication
between WSD and each child, DocumentBroker can now
receive and handle messages from its ChildProcess.

Change-Id: Ie7f030a92db8303cd7087fff2325f136a49bc7fc
Reviewed-on: https://gerrit.libreoffice.org/24581
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-05-02 02:55:53 +00:00
Ashod Nakashian
bdfda58386 loolwsd: don't autosave when document not loaded
Change-Id: I44e9c2ad234ee05348b47415add3933c81fce968
Reviewed-on: https://gerrit.libreoffice.org/24525
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-04-30 14:36:28 +00:00
Jan Holesovsky
d906bba7d1 Added a FIXME explanatory comment. 2016-04-29 15:16:59 +02:00
Ashod Nakashian
2efaa6e06b loolwsd: save documents when timestamp is within 10 seconds
Due to filesystem timestamp precision and other factors
we assume a timestamp match within 10 seconds to mean
the document has been recently saved and store it.

A document has to have an older than 10 seconds
modified timestamp compared to our last timestamp
to be deemed unchanged in the interim and skipped
from storing again.

Change-Id: I39b4bf64b221ba30dc7b818a330e779a2d0ecbd4
Reviewed-on: https://gerrit.libreoffice.org/24472
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-04-29 01:06:57 +00:00
Ashod Nakashian
e6a6b296ea loolwsd: avoid communicating with clients under shared lock
DocumentBroker is a central document management object.
Using it to communicate with clients leaves it open
to the whims of slow connections. When its lock
is help for a long time, all clients stall, giving
users a very poor experience.

The culprit in this case was takeEditLock, which
sent to all clients the new edit lock state.
To avoid this, DocumentBroker now sends this
state to the children (via a loopback socket,)
which process messages in a separate process and
each on its own queue thread. The children then
in turn echo this edit lock state back to the
clients. This communication back is done on the
prisoner socket thread, which doesn't lock or
stall any shared objects or threads.

Change-Id: I475f6b3ecac9ae2a689bd30f43d416871aa0e384
Reviewed-on: https://gerrit.libreoffice.org/24420
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-04-27 03:50:22 +00:00
Ashod Nakashian
d07a582469 loolwsd: merged autoSave and waitSave
This makes for amore compact API and avoids
a race between issuing the save and waiting for it.

Also added force flag and autoSave now checks the
modified state of the document. If a document is
not modified, nor save forced, autoSave checks
the last activity on the document and only
if there is any since last save does it issue
a save command.

Change-Id: I962e36df18d7edf5f658992e97b5def5f6247dc3
Reviewed-on: https://gerrit.libreoffice.org/24382
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-04-26 10:40:35 +00:00
Ashod Nakashian
d4aa547d3c loolwsd: avoid persisting excessively
When multiple users have a document open,
save notficiations are broadcast to all.
Each session then tries to store the document
to the Storage when only the first should suffice.

A new file modified-time member tracks the file's
timestamp and only persists when it changes,
thereby avoid excessive stores.

Change-Id: I138f1aa812963a2120a1fcac763dfacccc542c1a
Reviewed-on: https://gerrit.libreoffice.org/24381
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-04-26 10:40:07 +00:00
Ashod Nakashian
4f7b911066 loolwsd: simplified the bridging between client and prisoner sessions
Change-Id: I1335060963eda3356312f42060da229f43d239d8
Reviewed-on: https://gerrit.libreoffice.org/24358
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-04-25 02:16:16 +00:00
Ashod Nakashian
6b1a3115b2 loolwsd: request new session from child before storing session
Change-Id: Iadf8a4d30aaab276c55b3bb28c684df0004f8f3c
Reviewed-on: https://gerrit.libreoffice.org/24339
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-04-24 17:10:50 +00:00
Ashod Nakashian
08222c791f loolwsd: cosmetics
Change-Id: Ic5398c2ccacad24bef898ba502e5bd1bb0f26c00
Reviewed-on: https://gerrit.libreoffice.org/24334
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-04-24 16:57:10 +00:00
Ashod Nakashian
48bdc1e97a loolwsd: silence unused-result gcc error
Change-Id: Ide71b0b585a2b822cedc93e0b4aae11ab4aa1b34
Reviewed-on: https://gerrit.libreoffice.org/24333
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-04-24 16:55:29 +00:00
Tor Lillqvist
bff5748cd9 No need to have separate "editing" and "persistent" tile caches
All changes are supposed to be persistent. This simplifies the tile
caching code quite a lot.

The TileCache object no longer needs to keep any state whether the
document is being edited or whether it has been modified without
saving etc.

Update the modtime.txt file after saving the document. Otherwise the
tile cache would wrongly be considered invalid next time.

As a sanity check, we put a flag file 'unsaved.txt' into the cache
directory whenever we get a callback that indicates the document has
been modified, and remove it when the document is saved. If the flag
file is present when we take an existing tile cache into use, we can't
trust it.

Even after these changes, we still don't use an existing tile cache as
much (or at all?) as we could, though. The INVALIDATE_TILES EMPTY
callback that LO does early on in a conection causes us to remove all
cached tiles...
2016-04-22 17:49:39 +03:00
Ashod Nakashian
bde67c9934 loolwsd: track document modified state to avoid unnecessary auto-saving
This also avoids the feedback loop that results from the kit
thinking the previously inactive client is now active and
sending commands (.uno:Save).

Change-Id: I47074b35a922da15592d550032d494ba1efab83e
Reviewed-on: https://gerrit.libreoffice.org/24287
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-04-22 04:36:02 +00:00
Miklos Vajna
17de53981e Storage: fix missing underscore for non-static members
Change-Id: Ibde55358c9640344e8bb4e6e24b287b1e7d8c6b5
2016-04-19 09:10:28 +02:00
Ashod Nakashian
b933988a59 loolwsd: flag and wait if document is unloading before relaoding
When a new view is created on a document that is
in the process of unloading, all sorts of things
can go wrong. This is especially problematic when
the document needs to be saved before unloading,
which takes significantly longer than otherwise.

Change-Id: Ib33a18cafa9d5a3a17f6bd8c6145f9331ae54044
Reviewed-on: https://gerrit.libreoffice.org/24184
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-04-18 03:36:45 +00:00
Ashod Nakashian
ea223f14d2 loolwsd: storage validation should throw BadRequest on failure
Change-Id: I8e9eca96e3e9cef7391a74d72db806e6d1085b01
Reviewed-on: https://gerrit.libreoffice.org/24161
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-04-17 15:26:38 +00:00
Ashod Nakashian
372baaf427 loolwsd: cleanup of DocumentBroker session management
Improved session add/remove API.
Reduced mutex count.
Renamed members and variables.
Added documentation.

Change-Id: If15991971484d4d508714c9436a51b291f42079f
Reviewed-on: https://gerrit.libreoffice.org/24158
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-04-17 15:23:53 +00:00
Pranav Kant
7bf5e84a90 loolwsd: Make admin console work (again)
Change-Id: Ib51f33c60b5e42e154795357a7a787cb8691ad51
2016-04-15 13:28:42 +05:30
Miklos Vajna
4fac6c0126 DocumentBroker: can pass these by reference
Change-Id: I327e515e39671239b8699cfadcf61e088af68b13
2016-04-13 10:05:10 +02:00
Pranav Kant
9ea4624839 loolwsd: Handle socket exceptions while trying to send frame
In case of abnormal termination of session from client-side,
we might still have data being processed in the kit process, for
example, during auto-save. Trying to send such data over an
expired socket towards the client would throw exceptions which
need to be handled, otherwise the auto-save process would not be
successful. Further, the unhandled exception can bring the document
broker in an unstable state with dockey still present in the
object.

Also do not send 'editlock: 0' to a websocket session which is
going to be removed because the session might have been
forcefully terminated from the client-side, in which case sending
data would go nowhere.

Change-Id: I10eb9c818bc81d4db26d5a19dc8bd44f6fbdf32c
2016-04-13 09:56:32 +05:30
Pranav Kant
9efed29c1d loolwsd: Save using session holding the edit-lock
If the first session used to save does not hold the edit-lock,
all the .uno:Save commands will get converted to dummy messages
and never reach the kit process.

Change-Id: I36cbee778f8c2c5866dcf276cf156fdf9ed8388e
2016-04-12 16:12:23 +05:30
Tor Lillqvist
eb5fcdba93 Consistenly put a colon after the "editlock" in the message sent to the client 2016-04-11 13:31:03 +03:00
Tor Lillqvist
bde585a879 Make the time log messages make more sense semantically 2016-04-11 09:25:32 +03:00
Tor Lillqvist
9d4aeb86d1 I doubt we need nanosecond precision here in the logging
(As in "Most recent inactivity was 8096.000000 ms ago".)
2016-04-11 09:15:12 +03:00
Ashod Nakashian
280669c253 loolwsd: save on disconnection
Last client disconnection now correctly issues a save
and waits for the confirmation before tearing down
the sockets, queues and threads.

Change-Id: I28c28d79a17d359e9aa1fe67b983ca9fb592b847
Reviewed-on: https://gerrit.libreoffice.org/23978
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-04-11 03:11:38 +00:00
Ashod Nakashian
1c0f608a59 loolwsd: broker sets edit lock on first session automatically
Change-Id: Icad57130ffb1953cf8c71d4675c116036684569a
Reviewed-on: https://gerrit.libreoffice.org/23977
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-04-11 03:10:13 +00:00
Ashod Nakashian
4cab42b20f loolwsd: logging improvements
Change-Id: Idba11b0ae18337d78ea504a455ddc9494cff7ef0
Reviewed-on: https://gerrit.libreoffice.org/23967
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-04-10 17:21:32 +00:00
Ashod Nakashian
85641d934e loolwsd: for consistency always remove edit lock before taking it
Change-Id: Id24d6737fc3af77097058b28a77d6ca2d757cb9e
Reviewed-on: https://gerrit.libreoffice.org/23965
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-04-10 17:18:49 +00:00
Ashod Nakashian
60531e7def loolwsd: removed redundant session count in DocumentBroker
The sessions container already has the number of sessions.
No need for separate counters to track them.

Change-Id: I838865e2b8a843e87e81a6cc1226bcacd774b032
Reviewed-on: https://gerrit.libreoffice.org/23964
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-04-10 17:18:25 +00:00
Ashod Nakashian
e85d726c6c loolwsd: use the first valid session for auto-saving
Change-Id: I3d860c9f91de56f84ae93dc93688cd4898128107
Reviewed-on: https://gerrit.libreoffice.org/23963
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-04-10 17:15:18 +00:00
Ashod Nakashian
e6d0882791 loolwsd: moved autosave to DocumentBroker
Autosaving is done by DocumentBroker, which
tracks the last save time.

There are two triggers: idle and auto save.
The first triggers when sufficient time passes
after the last interaction the user had with
the UI (currently 30 seconds).
The second triggers when it's been more than
5 minutes since the last save.
Both triggers are conditional on the user
being active after the last save.

The new code auto-saves doesn't issue
a save command per session, but only
one per doc.

Change-Id: Iada15c16002e70710d2c13a3dcfdab036d8935c6
Reviewed-on: https://gerrit.libreoffice.org/23951
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-04-10 03:37:06 +00:00
Pranav Kant
9469021f74 consistency, server -> client messages ends with a colon
Change-Id: Ia2154603bf0b9432beeaae970f68daa1ea7f7ebd
2016-04-09 01:46:03 +05:30
Michael Meeks
7d62c74b83 Fix segv on failure to create a storage, and add unit test infra. 2016-04-07 22:21:14 +01:00
Ashod Nakashian
9485b4fe63 loolwsd: disable loading of local docs by default
Loading documents from the local filesystem
opens the door to security issues.

By default filesystem storage is disabled,
even if enabled in the config file. The
only way to enable it is to set the
allowlocalstorage command-line argument.

Change-Id: Ib8f57377260817436d101a16757aab38276cbdcd
Reviewed-on: https://gerrit.libreoffice.org/23881
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-04-07 04:45:31 +00:00
Ashod Nakashian
d5e2f64790 loolwsd: WSD <-> Child direct communication
WSD now communicates on a WebSocket directly
with kit processes. ChildProcess encapsulates
kit processes and the control WS, which itself
is owned by DocumentBroker.

Change-Id: Ica209aaa07974739b8e51a14e11325d084e193f6
Reviewed-on: https://gerrit.libreoffice.org/23789
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-04-04 04:08:01 +00:00
Pranav Kant
b8e9075f23 bccu#1621: Introduce an edit lock
... which can be taken only one at a time. Others can only view,
not edit. When a session with edit lock exits, the edit lock is
handed over to the next alive session.

Change-Id: I712a4e70369f1d07c1d83af416a0f5c288b05c7d
2016-03-31 19:24:14 +05:30
Pranav Kant
f1ede0c4ba loolwsd: Split Storage, Auth classes into header/impl files
Change-Id: I5d8990db8f8f4aa7a88bbb0cc84b97149cf4f8c0
2016-03-31 12:57:44 +05:30
Tor Lillqvist
a219819ebf Avoid defining constant strings in multiple places
It is not a good idea to have the same string somewhat arbitrarily
both as a static const members of the LOOLWSD class and then as a
file-local static const in another file. Or defined as a separate
local const static in each compilation unit that includes
Common.hpp. Use constexpr instead, in Common.hpp.
2016-03-28 14:17:30 +03:00
Ashod Nakashian
b4a4c45a36 loolwsd: Storage gets last modified time and simplified TileCache construction
Change-Id: I4a7e7b941c136b59ffd7d935310d37d73ac4ec63
Reviewed-on: https://gerrit.libreoffice.org/23540
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-03-26 17:10:25 +00:00