Commit graph

55 commits

Author SHA1 Message Date
Pranav Kant
ce1084b74f wsd: Send readonly info to clients
With this every other client would be able to know about other client's
permission i.e whether they have opened the document as readonly. This
could be important eg: to hide the cursor overlay of readonly users in
the UI or to mark these users as readonly in the userlist.

Change-Id: I5dcb1b4e5a22c9b546d16b69b9216cc7653cff04
2017-03-31 12:20:09 +05:30
Ashod Nakashian
7d3f5c0d2b wsd: terminate DocBrokers asynchronously
Remove locks and replace with isCorrectThread
assertions instead.

Crash recovery still needs some work, but
otherwise tests are clean (91/94 pass).

Change-Id: I9ac3e21854447d19a8e6106487dfd8be00fcf5ef
2017-03-30 02:19:24 -04:00
Ashod Nakashian
48ad9a2472 wsd: ClientSession::isLoaded -> isAttached
Since this doesn't necessary mean the document
was loaded completely (as the similarly named
flag in DocumentBroker signifies) rather that
the session was added to DocumentBroker.

Change-Id: Ibfc702bbd111ade2715dcb28ac3aa4e9e8e025dd
2017-03-29 23:55:19 -04:00
Ashod Nakashian
30d58f96a4 wsd: avoid unnecessary temp string construction
...when sending text messages over socket and
make return value indicative of success/failure.

Change-Id: Ie4d99103b0d49d238152f7da3155ebcb6ccd4e22
2017-03-29 23:55:19 -04:00
Ashod Nakashian
d77ede8954 wsd: consistent naming sendFrame -> sendMessage
Change-Id: I06c6bb42392a8982a8bb232eee33ece4c8dfc451
2017-03-29 20:03:01 -04:00
Ashod Nakashian
1c5896f302 wsd: count connections symmetrically
ClientSession::onDisconnect might not always be
called. The disymmetry between incrementing in
the ctor and decrementing in onDisconnect always
ran the risk of mismatch and leaking connection
counts, eventually blocking new clients.

Change-Id: I39ec65016984c0cddd0e16cfbf201049ced53713
Reviewed-on: https://gerrit.libreoffice.org/35713
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-03-26 05:12:12 +00:00
Ashod Nakashian
d3a8106cda wsd: remove NewSessions
Sessions are now added to the DocBroker
_sessions map and loaded from the poll
thread first before processing their
messages.

Since messages are not read from the
sockets outside of the poll thread,
there is no reason to queue them
at all. The only exception is when
messages are passed directly
to ClientSession during convert-to
requests. That will be handled
separately (for now convert-to test
fails).

Change-Id: I798166b9e45b5707a33d31137e01a32ce63630b1
Reviewed-on: https://gerrit.libreoffice.org/35705
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-03-26 05:06:22 +00:00
Jan Holesovsky
9f17050a7d Pass the locale settings from loleaflet to wsd/kit.
Change-Id: Ie530db73cfbdb62787f16eae0f4b07fbf8b8acb4
2017-03-24 12:34:32 +01:00
Ashod Nakashian
2ba2e213bb wsd: support rude termination of documents
Termination should normally be initiated by the
DocumentBroker in question, so sending of termination
message on the sockets come from the correct thread.

When termination happens from elsewhere
(f.e. cleanupDocBrokers) we cannot send socket
messages, and have to resort to rude termination.

Change-Id: I94acb7b314f5dbdc45c57049fc1ac8527ba72fb9
2017-03-20 00:41:53 -04:00
Ashod Nakashian
14779f5cd4 wsd: return moved socket state to stop any IO processing
Once a socket has changed ownership to a new
poll it will assert thread affinity with said
new poll. So we cannot do any IO on the old
poll's thread at that point and on.

Change-Id: I662f188dea7c377a18f3e546839ec43f2875dc7b
2017-03-20 00:41:53 -04:00
Ashod Nakashian
b1609a0087 wsd: cleanup session and docBroker after convert-to
Change-Id: I7d9c8eeef61c23cc3f4f902b15953abd5ec6851a
2017-03-20 00:41:53 -04:00
Michael Meeks
50661924b7 Dump much more ClientSession state, and also websocket latency. 2017-03-18 15:03:04 +00:00
Michael Meeks
9381d4134f Unify and simplify timeout and poll events setup.
Both happen at the same time, and need support from the
SocketHandlerInterface.

Rename hasQueuedWrites to getPollEvents and merge updateTimeout.
2017-03-17 22:00:28 +00:00
Ashod Nakashian
5aedff2422 wsd: convert-to functional again
Change-Id: Ibfdec5e898ccb7f851a09fb3fb5eae85ca20f482
Reviewed-on: https://gerrit.libreoffice.org/35307
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-03-17 04:05:19 +00:00
Ashod Nakashian
f9664bb369 wsd: send recylcing message to clients on shutdown
Change-Id: Ibeb37b801e388fa33671a3c7df564c8ed86d9b71
Reviewed-on: https://gerrit.libreoffice.org/35306
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-03-17 04:04:46 +00:00
Michael Meeks
8749f4f2e3 Cleanup unit test hooks. 2017-03-16 18:32:12 +00:00
Jan Holesovsky
b384867b3f Fix limiting of the connections.
Change-Id: I9ff0aec168fd971599248fee177bf51b134e3e58
2017-03-16 11:33:35 +01:00
Michael Meeks
44ec90343e SenderQueue - remove condition, and waiting. 2017-03-15 10:20:43 +00:00
Ashod Nakashian
6c8f3633de wsd: ClientSession becomes SocketHandler for WS sockets
Change-Id: I02706ccac186e4934b8ccdab5cdebdba7170fd46
2017-03-15 00:04:55 -04:00
Michael Meeks
842b261d9f Move auto-save of document into the DocumentBroker poll more convincingly. 2017-03-10 10:47:44 +01:00
Michael Meeks
0eaef6c896 config.h - get includes right: must always be the first include. 2017-03-10 10:47:43 +01:00
Jan Holesovsky
bffa8e5532 nb: We have to provide the jailed document path to the queued load message.
The document / path does not exist until after we actually load the document.

Change-Id: I9162d7975a53bb25a2c6da3fa3b3afacc7539e99
2017-03-10 10:47:43 +01:00
Michael Meeks
d4cc2e899c ClientSession: kill the writing thread. 2017-03-10 10:47:42 +01:00
Michael Meeks
4f883e9fc4 Setup a poll per DocumentBroker with thread to go with that.
Also dung out a chunk of older code.

FIXME: websocket / ClientSession needs to associate itself with the
DocumentBroker poll loop in place of the original loop.
2017-03-10 10:47:42 +01:00
Jan Holesovsky
a1a46c240e nb: Use the non-blocking socket in the loolwsd.
This so far only builds, but I did not even try to run it yet.

Change-Id: Iceacb5fc5c8994726508e8ea00bd495d758391a8
2017-03-10 10:47:39 +01:00
Ashod Nakashian
404111877a wsd: broadcast client messages from WSD not from the Kit
Change-Id: I9c179a2f41a0aaeef35b84208be8ab91af9ee53a
Reviewed-on: https://gerrit.libreoffice.org/34051
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-02-09 04:27:27 +00:00
Ashod Nakashian
5dad626b6d wsd: remove handling of depricated partpagerectangles command
Change-Id: I13285e83179ab7654b6fd21a6548730e74d67425
2017-02-05 21:59:22 -05:00
Ashod Nakashian
6fe933b466 wsd: take lock to forward messages to clients
Change-Id: I15888e4a5c35511c21f1e2d2bdd25ecbb16e80b9
Reviewed-on: https://gerrit.libreoffice.org/33568
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-26 02:13:23 +00:00
Ashod Nakashian
b8edc135a7 wsd: use Message object to handle responses back to clients
Change-Id: I5ddb32bbd7290c27308199f40f0ed286a869eafd
Reviewed-on: https://gerrit.libreoffice.org/33441
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-26 02:12:39 +00:00
Ashod Nakashian
acc029a411 wsd: autodetect message type
Change-Id: I0f3ab61867ea067f24050acb15660fa93fc7bbb5
Reviewed-on: https://gerrit.libreoffice.org/33437
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-26 02:08:23 +00:00
Ashod Nakashian
664f602555 wsd: cleanup ClientSession
Change-Id: Ia5d138ed7baf4c26982e93157d82e332cd049a60
Reviewed-on: https://gerrit.libreoffice.org/33435
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-23 05:57:28 +00:00
Ashod Nakashian
c789fe901b wsd: kill PrisonerSession
Change-Id: I7041f79038c377b107b46285278b70236b87f6ac
Reviewed-on: https://gerrit.libreoffice.org/33434
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-23 05:55:33 +00:00
Ashod Nakashian
e584a51443 wsd: merge PrisonerSession into ClientSession
Change-Id: I8ae924a7afae61b9c6e25e15ace187918d1e006b
Reviewed-on: https://gerrit.libreoffice.org/33433
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-23 05:54:28 +00:00
Ashod Nakashian
1f3d9ee457 wsd: ClientSession now encapsulates PrisonerSession
No need to expose PrisonerSession via ClientSession
when the marshalling of messages can be done by
ClientSession directly.

PrisonerSession can now be removed altogether.

Change-Id: I131e41f5d9ae50be7244fb92a6f391a757502111
Reviewed-on: https://gerrit.libreoffice.org/33431
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-23 05:53:36 +00:00
Ashod Nakashian
f1de0d0481 wsd: MessagePayload -> Message
Change-Id: Ie65f7c707785dbbf85a2f98abf082fbc3ee7a64b
Reviewed-on: https://gerrit.libreoffice.org/33428
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-23 05:47:03 +00:00
Ashod Nakashian
f3a85a7bf0 wsd: MessageQueueBase support no empty items
Throw when empty payload is enqueued
and return empty payload on get timeout
(instead of throwing).

Change-Id: Iab5df775caa46d5c212d0850645cda6cca16f20b
Reviewed-on: https://gerrit.libreoffice.org/33421
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-23 04:39:28 +00:00
Ashod Nakashian
25be7f0ab6 wsd: use own tokenizer
Change-Id: Ia6e58767e3a138d086d4e0ae287782d3ed558076
Reviewed-on: https://gerrit.libreoffice.org/33418
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-23 04:37:21 +00:00
Jan Holesovsky
91bf720ba3 Fix error handling in reading of the cached values.
Change-Id: I9f56f09786feb11326707d19cc0367a027ebefff
2017-01-17 16:55:20 +01:00
Ashod Nakashian
05620be4c5 wsd: autosave on disconnecting based on loaded sessions only
When a client disconnects, we autosave only when there
are no other sessions. The idea being that it'd be
wasteful to save on every client disconnect, so long
that we have a later chance of saving.

This doesn't hold, however, when the only other
remaining session is one that had just connected
and hasn't loaded a view yet. WSD wouldn't
know about this, but when unloading the
disconnecting session, Kit will exit the process
as the last view is gone, losing all unsaved changes.

This patch tracks the sessions in WSD that have
loaded a view and takes that into account when
deciding to autosave on disconnect or not, thereby
fixing this corner case that may result in data loss.

Change-Id: I699721f2d710128ed4db65943b9357dff54380f5
Reviewed-on: https://gerrit.libreoffice.org/33126
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-16 01:58:54 +00:00
Ashod Nakashian
ba90ea304c wsd: ClientSession logs updated
Change-Id: I4ec664ebd7eadbe3763ee18eb511662de6453ebb
Reviewed-on: https://gerrit.libreoffice.org/32552
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-01 03:56:19 +00:00
Ashod Nakashian
3a5be2926b wsd: log WS incoming messages only once
Change-Id: Iee31bc649ae2d194b6418367f0e9ab8561099b17
Reviewed-on: https://gerrit.libreoffice.org/32551
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-01 03:55:19 +00:00
Ashod Nakashian
ba9ffb4775 wsd: include cleanup
Change-Id: Id481cfbab6be12a095918bdc7318fb3584345307
Reviewed-on: https://gerrit.libreoffice.org/32548
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-12-31 23:22:15 +00:00
Ashod Nakashian
5a987bea90 loolwsd: better to poll less frequently
Change-Id: I8ad44d132f11d32247f48583151c650e98856f82
Reviewed-on: https://gerrit.libreoffice.org/32153
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-12-19 05:42:20 +00:00
Ashod Nakashian
fe38e0e1e6 loolwsd: per-socket dedicated sending thread
To avoid degrading performance for everyone
because of a single slow/bad connection, we
send data to clients each in its own thread.

Change-Id: I6f980c25a404c4d05bcdb1979849ea3d2776c7b9
Reviewed-on: https://gerrit.libreoffice.org/31984
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-12-14 04:21:20 +00:00
Pranav Kant
3ce8c3158a wsd: Allow disabling copy/paste to/from the document to browser
Change-Id: I73c70f46f1db11d69ebff582f72127d304689aa2
2016-12-13 17:45:16 +05:30
Pranav Kant
6affbb307c wsd: Allow hosts to disable print, export
using these WOPI protocol extensions: DisablePrint,
DisableExport, DisableCopy. All assumed to be false if not
provided.

Change-Id: I415597d710107f9d8cbb8757f361365cc2a88eb1
2016-12-13 17:45:16 +05:30
Pranav Kant
348653a73c wsd: Use EnableOwnerTermination property for ownertermination
We want document owners (sessions with their WOPI UserId =
OwnerId) close the document (for all sessions) only if
EnableOwnerTermination property is specified. Note that
EnableOwnerTermination is an extension to WOPI, and not part of
original WOPI standard.

Change-Id: I7237d172c4c54477572bc132336910250af075a3
2016-12-13 17:45:16 +05:30
Ashod Nakashian
477ca6f414 loolwsd: cleanup the Sessions
Change-Id: I3cd065ab84e17f943fa7de7e094db574ff6fde07
Reviewed-on: https://gerrit.libreoffice.org/31931
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-12-13 04:35:00 +00:00
Ashod Nakashian
e60bc28a00 loolwsd: LOOLSession -> Session
Change-Id: I94369480fb0a6789375dfe5610ada300e94b80eb
Reviewed-on: https://gerrit.libreoffice.org/31930
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-12-13 04:34:19 +00:00
Tor Lillqvist
e221388c79 Add an 'Idle time' column to the Admin console
Use a new protocol message, 'resetidle' to inform Admin clients
whenever a user has done anything in a document view. This is a
message that Admin clients need to subscribe to.

Also add the current idle time for each document to the 'documents'
message.

To reduce protocol chatter, the idle time is updated at most once per
10 s.

Change-Id: I418e82b05048a3628f21dcd240ccd974b3a01356
Reviewed-on: https://gerrit.libreoffice.org/31653
Reviewed-by: Tor Lillqvist <tml@collabora.com>
Tested-by: Tor Lillqvist <tml@collabora.com>
2016-12-08 08:39:11 +00:00