Commit graph

90 commits

Author SHA1 Message Date
Ashod Nakashian
3af0d69d22 loolwsd: isTileBeingRenderedIfSoSubscribe -> subscribeToTileRendering
Simpler yet descriptive function name and better logging.

Change-Id: Ic903197d5772b7994ffa8136cfae771deee3a24a
Reviewed-on: https://gerrit.libreoffice.org/28291
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-08-22 04:54:29 +00:00
Ashod Nakashian
c304cbc95b loolstress: trace session ID and child pid
Change-Id: Iac6b3dadedfcdec91db21a5e90eb3827705281d4
Reviewed-on: https://gerrit.libreoffice.org/27966
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-08-08 03:51:59 +00:00
Ashod Nakashian
177802154d loolwsd: trace notifications and response messages
Change-Id: I45f69386762d69e2b3960eeb96e591d7c5843b0b
Reviewed-on: https://gerrit.libreoffice.org/27955
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-08-08 03:47:54 +00:00
Michael Meeks
9a0c5d8571 Continue nocaps work to improve valgrindability. 2016-08-01 16:45:12 +01:00
Miklos Vajna
24624762df DocumentBroker: use std::move() instead of manual reset()/release() 2016-07-18 10:33:04 +02:00
Pranav Kant
da6af8b4ec loolwsd: Don't upload to storage if document is unmodified
If core says that document save operation failed because document
was in unmodified state, don't upload to storage (hence no
revision)

Change-Id: I47fbc8a7bc632bb7977d263d697d665161f3b076
2016-07-18 12:12:12 +05:30
Pranav Kant
4ecfb0da21 loolwsd: -Werror=shadow
Change-Id: Ic0bfead873ab7f0b9c177183c0f6d3179d097d96
2016-07-11 11:57:58 +05:30
Pranav Kant
a6187e6172 loolwsd: Reset document destroying states
These values are recalculated anyways now, when destroying the
document (See startDestroy())

Change-Id: Idfe4c48983556bb2b31ca0d6bf2ffcde84281a2d
2016-07-11 11:25:25 +05:30
Pranav Kant
06dc3fd1bc loolwsd: Give editlock correctly when adding a new session
This should be given to first editable(non-readonly) session.

Change-Id: I3b6e53df4b2450cc799c4b4e6a800f662d90a2c1
2016-07-11 11:25:20 +05:30
Pranav Kant
62814d29cf loolwsd: Introduce a readonly mode
Specified when websocket is initialized. Documents once
opened in readonly mode cannot edit throughout the life of the session.
This is very much like present view mode except the ability to
change to edit mode.

Change-Id: I176e3bbf210c3383268d1a5b50dc17f0cbfb26b8
2016-07-11 11:24:16 +05:30
Pranav Kant
37b9226030 loolwsd: unused variable
Change-Id: I60d10e4390b7c114273f517fb66786861f37db60
2016-07-11 10:23:29 +05:30
Ashod Nakashian
763eee7040 loolwsd: batch tiles by row
Change-Id: Ib5ca8e1457d4e23aa09968f90ccd3bf10d189815
Reviewed-on: https://gerrit.libreoffice.org/25661
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-05-30 11:28:24 +00:00
Ashod Nakashian
157386e3bc loolwsd: process tiles under the cursor with priority
Change-Id: I7993ee049c5c0835cae588ff54163f135c4f8b02
Reviewed-on: https://gerrit.libreoffice.org/25345
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-05-23 01:57:16 +00:00
Ashod Nakashian
6e54fd05f9 loolwsd: merge saveTile and notifyAndRemoveSubscribers
Change-Id: I8282604c02a9fd1a7a1e2a5df29e2f84fca151a6
Reviewed-on: https://gerrit.libreoffice.org/25344
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-05-23 01:54:55 +00:00
Ashod Nakashian
e5aaac7631 loolwsd: Tile versioning and fix to race conditions
Tile invalidation and painting can race with one another.

A race when the user types two characters in quick succession:
1. After the first key press, the tile is invalidated.
2. The client request the tile on receiving the invalidate.
3. TileCache doesn't find it, and adds subscription.
 A. Sometime before rendering, the second key press is received.
 B. This invalidates the very same tile.
 C. The client request the same tile.
 D. TileCache finds a subscription and ignores the new one.
4. The tile is rendered and sent back.
5. Subscription is found and the tile is forwarded to clients.
6. Subcription is removed as the request is fullfilled.
 E. The second tile is rendered and sent back.
 F. TileCache finds no subscription and the tile is dropped.

End result: Only the first character appears on the screen.

Versioning fixes the above situation by making sure that in
step 5 the subscription will show to belong to a different
(and newer version) and so the tile will be ignored.
Instead, at F the TileCache will find both subscription
and a matching version and the lastest version will always
be sent back to the client.

Change-Id: I7d7fe1407cda1908d794683c3ce4c2fd18609a2f
Reviewed-on: https://gerrit.libreoffice.org/25341
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-05-23 01:52:36 +00:00
Ashod Nakashian
114a6bc373 loolwsd: combined tile rendering
Tiles can be rendered in large batches and sent back
as combined payloads, all reduce latency and overhead
significantly.

Initial tests show a reduction in total latency by 2x.
This without sending tiles back to the client in combined
form, which will reduce latency further.

Change-Id: Iee06503f2a6c741fadb2c890266ea514c809c0dc
Reviewed-on: https://gerrit.libreoffice.org/25339
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-05-23 01:49:54 +00:00
Ashod Nakashian
fae850189d loolwsd: include cleanup and organization
A source file (.cpp) must include its own header first.
This insures that the header is self-contained and
doesn't depend on arbitrary (and accidental) includes
before it to compile.

Furthermore, system headers should go next, followed by
C then C++ headers, then libraries (Poco, etc) and, finally,
project headers come last.

This makes sure that headers and included in the same dependency
order to avoid side-effects. For example, Poco should never rely on
anything from our project in the same way that a C header should
never rely on anything in C++, Poco, or project headers.

Also, includes ought to be sorted where possible, to improve
readability and avoid accidental duplicates (of which there
were a few).

Change-Id: I62cc1343e4a091d69195e37ed659dba20cfcb1ef
Reviewed-on: https://gerrit.libreoffice.org/25262
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-05-21 15:52:54 +00:00
Ashod Nakashian
958f6ffcbd loolwsd: fix UnitPrefork deadlock/corruption
Reading from the socket in the test is not
thread-safe, and was causing all sorts of
problems.

The new code adds a test API and reads the
incoming data through it and not directly
from the socket. In addition, the read is
synchronized.

Change-Id: Id13821a40a59e32fd8a14f733a47306aee42ada8
Reviewed-on: https://gerrit.libreoffice.org/25244
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-05-21 03:43:15 +00:00
Ashod Nakashian
76991dd325 loolwsd: disable editlock in multiview
Change-Id: I4df2d8a321e160ce226c2e22aa754cd6e5b2c755
Reviewed-on: https://gerrit.libreoffice.org/25063
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-05-17 13:57:36 +00:00
Ashod Nakashian
b2881306f1 loolwsd: MasterProcessSession splitting: moved input queue
Change-Id: Id1c2b0f76a96ca48905d354c02a96b35ba29fadc
Reviewed-on: https://gerrit.libreoffice.org/25046
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-05-17 03:21:44 +00:00
Ashod Nakashian
7c76e4b6bc loolwsd: MasterProcessSession splitting: using ClientSession
Change-Id: I2ee089c04d2e5fbdae91cfc5cada437f5aae8e5b
Reviewed-on: https://gerrit.libreoffice.org/25038
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-05-17 03:13:07 +00:00
Ashod Nakashian
73f0e2a190 loolwsd: MasterProcessSession splitting into ClientSession and PrisonerSession
Change-Id: I29bcc5f791acf2313830e21d102e25f2232329d1
Reviewed-on: https://gerrit.libreoffice.org/25037
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-05-17 03:12:28 +00:00
Ashod Nakashian
d18bca992c loolwsd: use TileDesc instead of explicit values
Change-Id: I56ba6c4e63a495500093e7353477175d40152d11
Reviewed-on: https://gerrit.libreoffice.org/25020
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-05-15 23:00:43 +00:00
Ashod Nakashian
249b5350a4 loolwsd: removed editlock kludge in tile processing
Change-Id: If2a732fc3feb4e5cc600c98ab096a88beacf62d8
Reviewed-on: https://gerrit.libreoffice.org/25006
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-05-15 14:32:58 +00:00
Pranav Kant
a1b351d328 Use new DontTerminateEdit param in .uno:Save to be in edit mode
Change-Id: I781eba73af668be874ab91881bcb88494b43a2e9
2016-05-11 21:41:01 +05:30
Pranav Kant
7a96c2fff0 Revert "bccu#1776: Restore input mode if we are in one before saving"
This reverts commit 5500b09016.

Change-Id: I54b385dc823d8fc4e5ef9f6d8291c5cb8ca85417
2016-05-11 21:41:01 +05:30
Pranav Kant
58123086b8 Revert "bccu#1776: Fake double click after auto-saving"
This reverts commit 55a85ddb33.
2016-05-11 21:41:01 +05:30
Pranav Kant
55a85ddb33 bccu#1776: Fake double click after auto-saving
... just so that if we have the cursor before auto-saving, we
have it after save too (calc).

Change-Id: I3e6b1e41006c8fd9105d370b62ead4f45e50848c
2016-05-10 19:24:38 +05:30
Ashod Nakashian
e2f5f45140 loolwsd: remove mark-to-destory when we no longer have a sole client
Change-Id: Ic82176c458165faa1f719d313cc7fe0b4e6eacbb
Reviewed-on: https://gerrit.libreoffice.org/24812
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-05-10 03:45:38 +00:00
Ashod Nakashian
ca22a79034 loolwsd: simplify detection of file modification
To avoid persisting the same document many times over
we check the jailed file timestamp. This logic
doesn't need to be more complex than simply invalidating
the last timestamp upon issuing .uno:Save and setting
it to the file's actual timestamp upon persisting.

Change-Id: I4afdf8da93fed438d4cbcd6de8dc14d52172ac9c
Reviewed-on: https://gerrit.libreoffice.org/24811
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-05-10 03:44:33 +00:00
Pranav Kant
5500b09016 bccu#1776: Restore input mode if we are in one before saving
Change-Id: I46d57dce69777fdfe6afb95f9534b170972fe390
2016-05-09 21:59:13 +05:30
Ashod Nakashian
b06a07f6bc loolwsd: auto-save checks modified state and logs decision
Change-Id: I69d32e8c5ceabd46b635aa6c5bb30ade21101fd0
Reviewed-on: https://gerrit.libreoffice.org/24785
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-05-09 05:29:58 +00:00
Ashod Nakashian
8f5f0ffdb1 loolwsd: don't persist documents again within 10 seconds
Change-Id: Ic11ef0bb4cdb85481a504729f2dfe26f5c80ee9c
Reviewed-on: https://gerrit.libreoffice.org/24784
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-05-09 05:26:38 +00:00
Ashod Nakashian
702dd48f1f loolwsd: safer document saving
Relying on the filesystem to tell us when the document
was last modified (to decide whether to upload to storage or not,)
proved unreliable.

Now we always upload to storage if there is only one client.
This both minimizes the risk and also avoids the file timestamp
check as a workaround to the problem of re-uploading documents
as many time as there were clients. Since with one client we
can only upload no more than once per save, which is reasonable.

Furthermore, when a client disconnects we auto-save automatically
as a matter of precaution. However, when there are other clients
still connected, we don't wait for the save to complete, rather
we let that job to the very last one.

Change-Id: I94a2e4bddaed30a6c9c0e69f8006667d33c5b8ee
Reviewed-on: https://gerrit.libreoffice.org/24767
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-05-08 15:49:41 +00:00
Ashod Nakashian
6f39c0f282 loolwsd: state the child PID which has no DocumentBroker
Change-Id: Ifa679ac67cc0a1d12bba4a44f24831e7a291d97d
Reviewed-on: https://gerrit.libreoffice.org/24739
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-05-08 04:21:41 +00:00
Ashod Nakashian
1643938a8e loolwsd: support the tile id param when broadcasting tiles to subscribers
Obviously this is dangerous, since the id is not part of the
subscription key (the filename) so different clients could
have different ids on the same part, but in practice I
expect this not to happen. Though that clearly depends on
how clients use the id.

Change-Id: I52a0b043c9b5e5ad1111b692e4216cc9ffec5b2b
Reviewed-on: https://gerrit.libreoffice.org/24680
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-05-05 14:23:22 +00:00
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