Commit graph

103 commits

Author SHA1 Message Date
Henry Castro
c29944a386 loolwsd: fix close after close
The closing handshake.
Either peer can send a control frame with data containing
a specified control sequence to begin the closing handshake.

Upon receiving such a frame, the other peer sends a
Close frame in response, if it hasn't already sent one.
2016-04-18 20:27:27 -04:00
Tor Lillqvist
f769474d25 The "unload" message is not implemented and likely won't be 2016-04-18 15:39:51 +03:00
Tor Lillqvist
5782e0b04c TileCache::lookupTile() already returns non-null only if the stream is open
No need to test at call sites. We can assert() as a sanity check
though.
2016-04-15 14:12:35 +03:00
Ashod Nakashian
e5595509fd loolwsd: cosmetic cleanup
Change-Id: I02f3ab1778db462376b7563e7e8b0abeebd2e8a1
Reviewed-on: https://gerrit.libreoffice.org/24098
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-04-15 01:04:47 +00:00
Pranav Kant
5d8e627ca4 loolwsd: Allow 'downloadas' for all kinds of views
... irrespective of whether the editlock is taken or not.

Change-Id: I159f78fb4c58c973458ae2c5bc53e844de689e14
2016-04-14 15:08:01 +05:30
Miklos Vajna
63d9112977 MasterProcessSession: const auto -> const auto& where it would create a tmp copy
Change-Id: I5bbffb9be562b52f868bfca3f825e8d81dae4eef
2016-04-14 08:36:56 +02:00
Tor Lillqvist
4087ac8089 With "disconnect" messages gone, no need for a 'reason' to disconnect()
YAGNI.
2016-04-13 15:56:23 +03:00
Pranav Kant
68b3a2c81e Always save irrespective of nature of socket close
Do not distinguish between normal shutdown or abnormal shutdown.
Also remove 'disconnect' frame to indicate normal shutdown.

Change-Id: I98fd9f5a219feb1097c57302dba14e08ad9bf143
2016-04-13 17:35:10 +05:30
Tor Lillqvist
8bd0cb7543 These member variables are not used any more 2016-04-10 09:33:03 +03:00
Henry Castro
9ae7fa5b9b loolwsd: wait until bridge is completed 2016-04-10 00:18:48 -04: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
Ashod Nakashian
8c1e5057fd loolwsd: last activity time updates ignores non-interactive commands
Change-Id: I763c2945f6acb30bea9d04d91982e9fb0c8ca6ca
Reviewed-on: https://gerrit.libreoffice.org/23950
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-04-10 03:35:09 +00:00
Ashod Nakashian
b6d2edb0e3 loolwsd: moved activity tracking into LOOLSession
Change-Id: I87d5afc43bea29ede2ad6e2871c594c4746bc3d5
Reviewed-on: https://gerrit.libreoffice.org/23948
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-04-10 03:32:58 +00:00
Pranav Kant
9469021f74 consistency, server -> client messages ends with a colon
Change-Id: Ia2154603bf0b9432beeaae970f68daa1ea7f7ebd
2016-04-09 01:46:03 +05:30
Tor Lillqvist
84cd6bbceb Try to be more consistent in terminology
The "Broker" process is called "ForKit" now. The only things called
"broker" now are the DocumentBroker objects in the WSD process.
2016-04-07 11:53:44 +03:00
Tor Lillqvist
d4ede7136c bccu#1399: Restrict the meaning of the 'last message' timestamp and rename
It should keep track only of messages that indicate explicit editing
actions by the user. For now, treat anything except 'tile' messages as
such.
2016-04-06 12:50:42 +03:00
Pranav Kant
dc28273dcf Fixed a regression in opening password protected docs
Change-Id: Ife378538c98f091e271e0c474fb271c513887774
2016-04-05 00:15:30 +05:30
Ashod Nakashian
ceaefabc91 Revert "loolwsd: replace fifo for socket WSD -> Broker"
This reverts commit 97c8f35ddf.

Since the Broker design has been extremely simplified,
all communication between Broker <-> Kit are gone.
Only a pipe between WSD and Broker remain.

Temporarily reverting this to apply the Broker redesign,
after which this patch can be reviewed and merged.
This will be easier than trying to merge the redesigned
Broker on top of this.

Change-Id: Ia901fad604008654c01841df62e88918adad45e1
Reviewed-on: https://gerrit.libreoffice.org/23769
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-04-04 04:00:45 +00:00
Henry Castro
97c8f35ddf loolwsd: replace fifo for socket WSD -> Broker 2016-04-03 08:12:10 -04:00
Tor Lillqvist
593d5d7e08 Actually propagate idle/auto save requests to the kit processes
Had to add a shared pointer to the BasicTileQueue for the session to
the MasterProcessSession object, and restructure the coe a a bit to
allocate BasicTileQueue objects dynamically. Possibly just passing a
reference to a BasicTileQueue in the stack would have worked, but why
risk it?

The actual logic when to do auto / idle save is not quite right still,
did not change that in this commit.
2016-04-01 18:57:07 +03: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
Ashod Nakashian
fe69c4d5b6 loolwsd: pipe plumbing cleanup
Change-Id: I5519235a4601e1e38cedc3f06ffe9386434a292d
Reviewed-on: https://gerrit.libreoffice.org/23645
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-03-30 02:02:53 +00:00
Ashod Nakashian
c966a804f8 loolwsd: throw when we fail to connect to lokit
Change-Id: I52f5c923cfc8fa4c28309066d8457418154e6b20
Reviewed-on: https://gerrit.libreoffice.org/23643
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-03-30 01:57:21 +00:00
Ashod Nakashian
9150d560c0 loolwsd: thread -> session
Change-Id: I7d9f84a2c9afea5f541f5815929745d2de93c8fa
Reviewed-on: https://gerrit.libreoffice.org/23642
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-03-30 01:56:45 +00:00
Ashod Nakashian
ce2fabb733 loolwsd: moved IO utilities into IoUtil file
Change-Id: I1e8d5562787134cbb490c38b19d83b7514ec9baa
Reviewed-on: https://gerrit.libreoffice.org/23586
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-03-29 14:09:04 +00:00
Ashod Nakashian
3217b4592a loolwsd: queue payload changed to vector<char>
All messages now pass through the queue.
This resolves a race between single-line
messages and multi-line ones.

Previously, single-line messages were
processed on the queue (on a background
thread) while multi-line ones were handled
immediatly. This resulted in order-inversion
due to a race between the queue thread and the
next multi-line message, which caused stability
issues every so often.

Change-Id: Ia220791d1d75c4f3e3e0965dd0c6f81bae63a296
Reviewed-on: https://gerrit.libreoffice.org/23583
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-03-29 02:47:27 +00:00
Ashod Nakashian
87e7dddec0 loolwsd: tile persisting done on successful save only
Change-Id: I1399556e809e1ee0ba194d04e93a81f786084029
Reviewed-on: https://gerrit.libreoffice.org/23537
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-03-26 17:07:18 +00:00
Ashod Nakashian
48dfce13de loolwsd: moved TileCache into DocumentBroker
Change-Id: If44a2d3158801e0910cf0f991c75b5ef845a5a30
Reviewed-on: https://gerrit.libreoffice.org/23532
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-03-26 16:58:55 +00:00
Miklos Vajna
08b52fae72 MasterProcessSession: fix missing prefixes 2016-03-25 17:10:16 +01:00
Ashod Nakashian
ca9c14dfdd loolwsd: logs and comments
Change-Id: I2fbfb7ee7ada48390bec65ee6911bde00885fbdb
Reviewed-on: https://gerrit.libreoffice.org/23450
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-03-23 00:03:36 +00:00
Tor Lillqvist
9d35b956d9 bccu#1399: Initial code for auto/idle save
Just a skeleton, actual saving not yet implemented. Also, not sure
the logic when to trigger save is as intended.

Note that no separate timer classes or objects are used. The existing
watpid/sleep loop that wakes up once every two seconds currently is
used. If that loop is re-factored to be less silly, the auto/idle save code
must be implemented differently.
2016-03-22 20:27:38 +02:00
Ashod Nakashian
e0b14c0e22 loolwsd: give Broker the docKey, not URL
And reject connections with no doc URL.

Change-Id: I11490be6aaea6a4ca2d66d8d2c8d6b52e1e48a04
Reviewed-on: https://gerrit.libreoffice.org/23225
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-03-14 03:17:04 +00:00
Ashod Nakashian
29e9ba68c3 loolwsd: removed unnecessary childId, which is in the child URL
Change-Id: Ibea2cd73657446ad4660400a0a9a38b376499df5
Reviewed-on: https://gerrit.libreoffice.org/23222
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-03-14 03:14:43 +00:00
Ashod Nakashian
38c4acd5f0 loolwsd: moved document loading outside of MasterProcessSession
Change-Id: I8ecce82abcae6d0f07b86c188c91913ff9ca115a
Reviewed-on: https://gerrit.libreoffice.org/23219
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-03-14 03:13:37 +00:00
Ashod Nakashian
c6b47cc437 loolwsd: removed superfluous getJailPath
Change-Id: Iff11ea791866f31a47cf0d0b1d1fb06d18f5be40
Reviewed-on: https://gerrit.libreoffice.org/23218
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-03-14 03:13:02 +00:00
Ashod Nakashian
bb16272e11 loolwsd: DocumentStoreManager -> DocumentBroker
Renamed DocumentStoreManager to DocumentBroker and
restructured the handshake process.

Currently, at first client connection to a given doc
a DocumentBroker is created to serve as the clearing house
of all client-side activities on the document.

Prime goals is loading and saving of the document, but
also to guarantee race-free management of the doc.

Each doc has a unique DocKey based on the URL (the path,
without queries). This DocKey is used as key into a map
of all DocumentBrokers. The latter is shared among
MasterProcessSession instances.

Change-Id: I569f2d235676e88ddc690147f3cb89faa60388c2
Reviewed-on: https://gerrit.libreoffice.org/23216
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-03-14 03:10:08 +00:00
Ashod Nakashian
64d2ff98b8 loolwsd: document saving and restructuring
Change-Id: Ia4c644d07a16ba5284e9cdfaf7b838134fbf640b
Reviewed-on: https://gerrit.libreoffice.org/23212
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-03-14 03:06:13 +00:00
Ashod Nakashian
0d8fcf5699 loolwsd: logging
Change-Id: I9a4dc248aca87983e3d7d3ace0071e5bbf92e688
Reviewed-on: https://gerrit.libreoffice.org/23209
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-03-14 03:04:17 +00:00
Ashod Nakashian
f1007266e1 loolwsd: DocumentStoreManager shared by MasterProcessSession instances
Change-Id: Id7ada60387cafdf742690dbf345bb1e703b2ca76
Reviewed-on: https://gerrit.libreoffice.org/23206
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-03-14 03:01:48 +00:00
Ashod Nakashian
73bde2b5d2 loolwsd: moved DocumentURI into own file and renamed to DocumentStoreManager
Change-Id: I5948ae532f0fd5917b99369733ec5ea36da2e437
Reviewed-on: https://gerrit.libreoffice.org/23204
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-03-14 03:00:35 +00:00
Henry Castro
2e49729ff4 loolwsd: coding style minor correctness 2016-03-10 15:42:01 -04:00
Ashod Nakashian
237e0c0e9a loolwsd: minor cleanups and const correctness
Change-Id: Ic3b26e1fbf5feba1667bc3dc1737d037590a5928
Reviewed-on: https://gerrit.libreoffice.org/23109
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-03-10 04:24:30 +00:00
Tor Lillqvist
e8a5ba1b29 _bShutdown is always false 2016-03-08 09:45:23 +02:00
Tor Lillqvist
e7e1ef58ae Cosmetics: Sort and prune #include and 'using' lines 2016-03-08 09:44:04 +02:00
Tor Lillqvist
9f67eecadd Improve exception logging
Always try to identify *where* we caught the exception. It is not that
useful to have half a dozen places that all just log "Exception:".
2016-03-07 18:36:01 +02:00
Miklos Vajna
6ef8312357 loolwsd: fix -Werror,-Wshadow 2016-03-07 09:09:32 +01:00
Ashod Nakashian
c980ece8bc loolwsd: preparing for wopi storage
Change-Id: Iae1bd042d84603cf81115789df40f50e8dc20d16
Reviewed-on: https://gerrit.libreoffice.org/22884
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-03-04 03:04:43 +00:00
Tor Lillqvist
fa0fd3303d Avoid logging \r\n here, too 2016-03-02 14:55:04 +02:00
Tor Lillqvist
6af8a9bbc1 Avoid 'short' and 'signed' 2016-02-23 10:22:18 +02:00
Tor Lillqvist
819d5c23c0 Use all tokens 2016-02-22 16:31:24 +02:00