Commit graph

673 commits

Author SHA1 Message Date
Michael Meeks
ce0dffdc12 Use callback API to implement alertAllUsers safely and simply. 2017-03-21 08:31:20 +00:00
Ashod Nakashian
dc90499514 wsd: remove the socket on move
Avoid explicit socket removal too.

Change-Id: I44d773761a5a463aad828c19c6b394bb6bac63d8
2017-03-20 23:26:06 -04:00
Ashod Nakashian
5eb6607f08 wsd: terminate the DocBroker when the kit disconnects
This can happen most notably when the kit crashes.
In this case the DocBroker is terminated so all
client connections are closed, allowing clients
to re-connect and re-open the doc.

Change-Id: I9854e11b002ca6e3c2a1a0bbb91ca087679d25bb
2017-03-20 23:26:06 -04:00
Ashod Nakashian
4df1e3c8f2 wsd: timeout after last save before terminating DocBroker
Change-Id: I87430285be7350ffbd3dfd6516257ed2b4ce1869
2017-03-20 21:57:58 -04:00
Ashod Nakashian
c7b4d9ecab wsd: fix rendering options regression
The rendering options must be last in the load
command. This is because it could contain
characters that interfere with the parsing.

Change-Id: I14930d580d59014532d07410251acbd1316b4f61
2017-03-20 20:42:13 -04:00
Andras Timar
2cf1f22439 Use LO_PATH instead of hardcoded path as config default
Change-Id: I0d6ce9e7938e2521e764978526fe2d9ce632c992
2017-03-20 23:29:14 +01:00
Miklos Vajna
98e2f0669a wsd: fix -Werror,-Winconsistent-missing-override
Change-Id: I25f644665951bbb7c188c0a73e929cb63eb1d580
2017-03-20 09:29:08 +01:00
Ashod Nakashian
d0bb5cbdc7 wsd: restore forkit after crash
Change-Id: Iacfcbfbf922897ea1bb9896d01a9a8afd4e194cc
2017-03-20 00:41:54 -04:00
Ashod Nakashian
53da72a1dc wsd: fix hot looping the poll
When not sending ping the ping time is not set
which results in the setting the poll timeout to
a negative value, forcing it to return immediately.

This happens when sending ping before upgrading
to WebSocket, which isn't common. One way to
reproduce it, however, is to connect to the
admin console with an unauthenticated socket.

Change-Id: I9f3db1a02b8f8e2781d23d843e848068ad434958
2017-03-20 00:41:54 -04:00
Ashod Nakashian
5a3b812167 wsd: stop DocBroker poll and terminate child when no more sessions
Normally the last session either stopped and terminated
the DocBroker upon saving the doc, or immediately upon
removal when nothing to save.

However, saving could fail, or the session could be
disconnected by the client, or saving could timeout, etc.

In all those failure scenarios the DocBroker should
not linger as a zombie (alive but without sessions).
Here we detect that we are left with no sessions
and terminate correctly.

Change-Id: I31862234e321f63e686f54fa69daacc1fa06ae75
2017-03-20 00:41:53 -04:00
Ashod Nakashian
47bbbbb2dc wsd: correct prespawning of children and simplify
The prisoner poll should wake every so often
to check and rebalance the new children.

However this didn't happen correctly and
WSD would starve of children every so often.

The frequency of checking and rebalancing of
children should be reviewed and optimized.

Also simplified the code to avoid rebalancing
DocBrokers and only do NewChildren.

Change-Id: Id3be34ed3a47c739b606ee7969088397d3807e7a
2017-03-20 00:41:53 -04:00
Ashod Nakashian
714eeac3aa wsd: simplify DocBroker creation
Change-Id: Icc93af2e32ce544c42cc65bbea83b9539c044db9
2017-03-20 00:41:53 -04: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
6e7bd4bcf0 wsd: cannot broadcast alert messages from random thread
Will have to come up with a different solution
to broadcasting alerts to all users.

Change-Id: I00260402f71c516f4335c592b10dee7555dc67a6
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
Andras Timar
b17d64a854 switch to 5.3
Change-Id: I21cf56f8d061453c4ff3f609ea81a5604e12b78c
2017-03-18 21:56:19 +01:00
Michael Meeks
50661924b7 Dump much more ClientSession state, and also websocket latency. 2017-03-18 15:03:04 +00:00
Michael Meeks
a6a4094e52 Send ping message, handle pong & store ping-time on the Websocket. 2017-03-17 22:59:03 +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
Dewan
92ad94f259 display lokit and loolwsd version in admin panel
Change-Id: Ia5b89373bfd7e921597b73d5a84963268244b748
Reviewed-on: https://gerrit.libreoffice.org/35199
Reviewed-by: pranavk <pranavk@collabora.co.uk>
Tested-by: pranavk <pranavk@collabora.co.uk>
2017-03-17 07:53:06 +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
bb3fa00631 UnitPrefork - restore most of the functionality.
No need for the memory reporting bits now that Admin gets this right.
2017-03-16 19:13:14 +00:00
Michael Meeks
ab67d605e6 Unit tests: use WSD's main socket-poll for test timeouts. 2017-03-16 18:52:49 +00:00
Michael Meeks
8749f4f2e3 Cleanup unit test hooks. 2017-03-16 18:32:12 +00:00
Michael Meeks
e7ebe0fdaa remove obsolete Poco headers, and Poco SSL pieces. 2017-03-16 18:03:23 +00:00
Michael Meeks
a6de441ed0 rename AdminRequestHandler to AdminSocketHandler. 2017-03-16 17:32:38 +00:00
Michael Meeks
4bc71cc86d Admin: remove debug. 2017-03-16 17:29:18 +00:00
Michael Meeks
97cb6597c8 Admin: don't set 'secure' on auth cookie for http.
Also tweak paths to accomodate bundlification, apparently un-necessary
in secure cookie mode, interestingly.
2017-03-16 16:44:27 +00:00
Jan Holesovsky
b384867b3f Fix limiting of the connections.
Change-Id: I9ff0aec168fd971599248fee177bf51b134e3e58
2017-03-16 11:33:35 +01:00
Jan Holesovsky
191d22992d This must have been pushed by mistake.
Change-Id: I62c516fec4485b176c9d50425030998e296ea369
2017-03-15 21:00:24 +01:00
Michael Meeks
f392d9e6f0 Move http serving into socket impl.
Avoid caching headers with parameter, and add Date: parameter.
2017-03-15 18:21:59 +00:00
Michael Meeks
d19b6eb351 Move memstats & cpustats into the main polling thread.
We can calculate the timeout ourselves easily and add it to the
polling loop simplifying life.

Also ensure we never send messages to a non-authenticated thread.
2017-03-15 17:24:44 +00:00
Michael Meeks
0089723f69 Admin: review error handling on auth. failure. 2017-03-15 16:25:29 +00:00
Michael Meeks
909b5f8ac3 Admin: should be its own socket-poll goodness. 2017-03-15 16:13:13 +00:00
Michael Meeks
e1f576bdb3 Switch to using websocket here. 2017-03-15 15:12:52 +00:00
Michael Meeks
d9980e3392 Adjust initial AdminRequestHandler entry point. 2017-03-15 14:40:24 +00:00
Michael Meeks
6d6dc45850 Remove un-necesssary and inefficient wakeupWorld.
While message emplacement happens in the DocumentBroker poll, we
can be sure that the next iteration of the poll will call
hasQueuedWrites before polling.
2017-03-15 12:07:34 +00:00
Michael Meeks
44ec90343e SenderQueue - remove condition, and waiting. 2017-03-15 10:20:43 +00:00
Ashod Nakashian
969fcbefb3 wsd: move convert-to handling into ConvertToHandler
ClientSession still isn't getting the notification,
so document is not uploaded to the client just yet.

Change-Id: Ifda8ed394f6df1ec1a5bc1975d296dea496c0aed
2017-03-15 00:04:55 -04:00
Ashod Nakashian
1288837401 wsd: createNewClientSession takes optional WS to notify client of progress
Change-Id: Ief64685dd8cc363cfd21cedda38f907b6787b609
2017-03-15 00:04:55 -04:00
Ashod Nakashian
6c8f3633de wsd: ClientSession becomes SocketHandler for WS sockets
Change-Id: I02706ccac186e4934b8ccdab5cdebdba7170fd46
2017-03-15 00:04:55 -04:00
Ashod Nakashian
c8bece208d wsd: socket logs include socket FD for better traceability
Change-Id: I994c7c5ab73b97be312a9d6abf3258dc5f4c08c1
2017-03-15 00:04:55 -04:00
Jan Holesovsky
d71ff2240a We don't expect the DocumentBroker isAlive() yet here.
Change-Id: Ib0349d3764ca2f8a71f6ac355b0ebc8799ee3d43
2017-03-14 17:43:21 +01:00
Pranav Kant
60e86cfba8 clearer log message, insert space here
Change-Id: I883867e66060838d8f6c879b9bba44f93fb7bd51
2017-03-14 19:19:27 +05:30
Pranav Kant
9efb0e8701 loolwsd: Fix dump states output
Change-Id: Idf578e1833b0013bb694e8cd5a8630bf48938c56
2017-03-14 18:04:50 +05:30
Ashod Nakashian
8b9623010a wsd: sendHttpResponse -> send
Change-Id: I7c94f6d4cd1054ea86585bfcd4079140471f3518
Reviewed-on: https://gerrit.libreoffice.org/35157
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-03-14 04:30:55 +00:00
Michael Meeks
fad3a046ae AdminConsole - get credentials sorted, and serve the HTML pieces. 2017-03-13 21:48:19 +00:00
Michael Meeks
bf8068de18 Clarify comment a little. 2017-03-13 13:42:05 +00:00
Michael Meeks
97e9463f17 Revert "wsd: TerminatingPoll always starts its own thread"
This reverts commit 388d7b1dbf.

It is vital to have clean control of thread start. By starting
a thread during init. of a member (or base-clase) we loose lots of
control, some examples:

	Any members initialized after a member that auto-starts a
	thread, is effectively un-defined, and cannot be accessed
	reliably.

	This is particularly problematic for sub-classes.

	I've seen threads started before the base-class has
	finished constructing in the original creating thread -
	such that the vtable was not yet updated to the sub-class
	causing the transient parent vtable used during construction
	to be used in-error.
2017-03-13 12:13:22 +00:00
Ashod Nakashian
3d78e5f2a1 wsd: improved logging of extant DocBrokers after cleanup
Change-Id: I4de8fde607e9e94cbadd8e100d39e0e21f2f2bdc
Reviewed-on: https://gerrit.libreoffice.org/35126
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-03-13 04:25:57 +00:00
Ashod Nakashian
9248107702 wsd: SocketPoll reports thread isAlive and use in DocBroker
Now that DocumentBroker has SocketPoll thread,
it's isAlive() must be defined by the lifetime of
both the SocketPoll thread and the ChildProcess,
which it previously did.

Change-Id: I093f8774cf4374d01729a383f6c535de4143fec6
Reviewed-on: https://gerrit.libreoffice.org/35122
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-03-13 04:23:18 +00:00
Ashod Nakashian
8901fcf074 wsd: ChildProcess doesn't need friends
Change-Id: I1911920c9b49adecac4ea4d8fc4b0830687b80c7
Reviewed-on: https://gerrit.libreoffice.org/35121
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-03-13 04:21:25 +00:00
Ashod Nakashian
04bbb75200 wsd: dump state to generic ostream for flexiblity and to log
Change-Id: I4670ee2e90b7809ebc66a2b324a44334b3dbba2b
Reviewed-on: https://gerrit.libreoffice.org/35119
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-03-13 04:19:58 +00:00
Ashod Nakashian
2e2f62edde wsd: improved logging
Change-Id: I6c4a5bcd54c0748cc413afbfcfb34c365b347669
Reviewed-on: https://gerrit.libreoffice.org/35118
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-03-13 04:11:24 +00:00
Ashod Nakashian
c939eeab68 wsd: remove the last session immediately if no saving needed
Change-Id: I509c7a83f16caf0d55fcb6af9c7ce707b7a0e389
Reviewed-on: https://gerrit.libreoffice.org/35115
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-03-13 04:09:36 +00:00
Ashod Nakashian
388d7b1dbf wsd: TerminatingPoll always starts its own thread
Since all TerminatingPoll instances need to fire
a thread, no reason to do it manually and risk
races. Now TerminatingPoll does it in the ctor.

Change-Id: I59850ad48b3789f3a23d01abb05a7f28e5717031
Reviewed-on: https://gerrit.libreoffice.org/35114
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-03-13 04:09:15 +00:00
Ashod Nakashian
cbd00bf7c8 wsd: simplify DocumentBroker construction
DocumentBrokerPoll is always owned by a
single DocumentBroker instance, so we
can hold a reference to it. This eliminates
the need to hold a shared_ptr to the owner
which, in turn, eliminates the need for
a create wrapper.

Change-Id: I954c9dddcc3b2cfdd5dfcc8248ab3d47a897f684
Reviewed-on: https://gerrit.libreoffice.org/35113
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-03-13 04:08:40 +00:00
Michael Meeks
71a1e188a7 Handle If-None-Match / ETag (hopefully) - hard to test ... 2017-03-11 22:28:59 +00:00
Michael Meeks
51ae42d513 DocumentBroker: log load time and dump it on request. 2017-03-11 22:01:27 +00:00
Ashod Nakashian
57e7d22e28 wsd: logging and formatting cleanup
Change-Id: I5bfbd517c37b6df864d181abe7c70857815b9ece
Reviewed-on: https://gerrit.libreoffice.org/35082
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-03-11 19:50:08 +00:00
Ashod Nakashian
e9614fc697 wsd: support logging file and line with logger objects
Change-Id: Ibf82105d91ece29c0a4742c6b2e81f6b179c0be4
Reviewed-on: https://gerrit.libreoffice.org/35081
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-03-11 19:49:09 +00:00
Ashod Nakashian
2e16fd2852 nb: don't read socket data without handling
When we read data, we must also handle it,
otherwise the next poll might have no
more data (the request data was read
completely the first time) and we dead
lock waiting for data to process.

Change-Id: I26c69ecc1f0550e8371cf77a6f3928a7a877eff7
Reviewed-on: https://gerrit.libreoffice.org/35080
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-03-11 19:48:22 +00:00
Michael Meeks
93d46fc469 Don't treat a session as non-editable when it is not (yet) loaded. 2017-03-10 23:52:28 +00:00
Michael Meeks
5cafa006dc Wakeup poll after queueing a new session. 2017-03-10 23:28:54 +00:00
Michael Meeks
5763d8d9bb Improve debugging. 2017-03-10 23:28:34 +00:00
Michael Meeks
160446fd23 Work on resurrecting dying DocumentBrokers if we can.
The hope is that they will close lingering session sockets at the
end and the client will re-connect.
2017-03-10 17:58:51 +00:00
Michael Meeks
1065441e7c Don't autosave if we're being stopped and happened to be overdue. 2017-03-10 16:42:59 +00:00
Michael Meeks
173ca5e3d6 Quote ETag. 2017-03-10 16:42:48 +00:00
Michael Meeks
3b370022c0 Improve state dumping. 2017-03-10 15:37:09 +00:00
Miklos Vajna
2e2381b5b3 wsd: fix -Werror,-Winconsistent-missing-override
Change-Id: I0f009aea715e93c90683f333c96a04088d103964
2017-03-10 10:53:40 +01:00
Ashod Nakashian
5677eb30b7 nb: fix saving when last client disconnects
When the last client session is disconnected
docBroker must first issue a save and wait
until the kit processes the save and sends
back notfication. Since said notification
goes to the ChildSession (which is the last)
and said ChildSession is the one that signals
to docBroker to persist the doc to the Storage,
we need to keep all components alive and kicking
during this final saving.

As such, when the last session is to be removed
from docBroker, we instead issue an autosave and
continue everything as normal. When the save
notification even arrives and ChildSession signals
docBroker to persist the doc, we check if we were
destroying and in that even remove that last session
and stop the polling thread.

The docBroker instance itself will get cleaned up
in due time.

Change-Id: Ie84e784284e1ec12b0b201d6bf75170b31f66147
2017-03-10 10:47:44 +01:00
Ashod Nakashian
41eb052780 nb: really wait 20 seconds for last save
Change-Id: Ia30beb1e68c55b9987a9730e9acab11bd2871811
2017-03-10 10:47:44 +01:00
Ashod Nakashian
2d621f1a47 nb: logging
Change-Id: Ic3b724d5869f75234af2238b96a90c4745155b86
2017-03-10 10:47:44 +01:00
Ashod Nakashian
7a5cc9ce6f nb: correct forkit initialization sequence
This avoids extra kits, avoid logging
unnecessary errors and adds informative logging.

Change-Id: I7a4bb0b690f9787fc362d0b6aefcc722586eaed1
2017-03-10 10:47:44 +01:00
Ashod Nakashian
0bf6e28f54 nb: cleanup old comments and move MAX_CONNECTIONS assertion
Change-Id: I24f3f4321ccc62c26c433d4a709b41c894a0196d
2017-03-10 10:47:44 +01:00
Michael Meeks
42a19e66e3 Centralize idle poll time. 2017-03-10 10:47:44 +01:00
Michael Meeks
438630c68f Start DocBroker thread later - when we've added our 1st session. 2017-03-10 10:47:44 +01:00
Michael Meeks
33d1fa7cc0 Kill SenderThreadPool. 2017-03-10 10:47:44 +01:00
Michael Meeks
e16fc97c15 SocketPoll - better control starting our threads.
Extraordinary trace with a thread starting before the SocketPoll's
derived classes had started - ie. with wrong vtables etc.
2017-03-10 10:47:44 +01: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
c097925e51 Move Kit / prisoner re-balancing into the PrisonerPoll thread. 2017-03-10 10:47:44 +01:00
Jan Holesovsky
b895393cea nb: Perform the socket shutdown asynchronously after the data is served.
Change-Id: I642e26abf4ef9c8d2be1be428b5786692dfea2c7
2017-03-10 10:47:44 +01:00
Ashod Nakashian
b8af470918 nb: serve files synchronously
As there isn't support (yet) to send files
asynchronously, when the socket native buffer
is small, asynchronous writes naturally return
EWOULDBLOCK. As a temp solution, we send files
synchronously, so there is no need to poll.

This should be replaced witha file-server
polling/serving thread that is dedicated to
sending files only (which closes the connection
when done).

Change-Id: I062fea44bfe54ab8d147b745da97bd499bf00657
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
c4c8d93bba nb: Blind attempt to fix running inside docker.
If nothing, it will at least improve the logging.

Change-Id: I35a8eb620a210aea9cf55c0eb47bda7b0d777cf8
2017-03-10 10:47:43 +01:00
Jan Holesovsky
59c5eeec4c Fix build.
Change-Id: I218895b6ba314250f0009fa465499f38953b49d8
2017-03-10 10:47:43 +01:00
Michael Meeks
d807db08f2 More descriptive comment. 2017-03-10 10:47:43 +01:00
Ashod Nakashian
ec3e795813 nb: remove superfluous assertion
Change-Id: I22e0e031768e52f83b6e0f062df61aaf6e881279
2017-03-10 10:47:43 +01:00
Ashod Nakashian
826217b4d8 nb: move the child socket to DocBroker poll
Change-Id: I8cbec60e49ca508df0e96e7e594f9dad15f84276
2017-03-10 10:47:43 +01:00
Ashod Nakashian
9f90722673 nb: contain exceptions when adding new session and loading
Change-Id: I35e6714e87eaf2c65d36bbf813ac1fd286a0fbb7
2017-03-10 10:47:43 +01:00
Ashod Nakashian
7b1ed1b4d4 nb: more informative logging of socket activity
Change-Id: I9036c778c195936678c6451ba57cc794d6ba0006
2017-03-10 10:47:43 +01:00
Ashod Nakashian
d6aa3324d5 nb: childProcess might not exist yet when terminating
Change-Id: I28b84233ea47ca0d8e3be33ba73d1165f37adb40
2017-03-10 10:47:43 +01:00
Ashod Nakashian
0f1c5827ec nb: sockets may disconnect before loading
So startDestroy must not assume the session
was already added at that point, since addSession
is done when we poll for reading, but not when
the socket has already disconnected.

Change-Id: I7bb7222604269c1cc9f2f4b4dad3ea1054b3e0c9
2017-03-10 10:47:43 +01:00
Ashod Nakashian
222b5562c3 nb: DocumentBroker::pollThread now non-static member
Change-Id: Ib95611f6f696f5810ce7fcb3a4bb67c1d7ac13ac
2017-03-10 10:47:43 +01:00
Michael Meeks
ce4bd9b9be Unify DocumentBroker thread and its SocketPoll. 2017-03-10 10:47:43 +01:00
Michael Meeks
79fb1e2c1f Sub-class the SocketPoll to allow more flexibility in termination. 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
Ashod Nakashian
a8ddbf55f2 nb: fixme to merge DocumentBroker polling thread with SocketPoll
Change-Id: I82c289b0d30f687bc9ce7bb6ba5d85a248449f63
2017-03-10 10:47:43 +01:00
Ashod Nakashian
6a29fc943b nb: remove unused polling threads
Change-Id: I1255a41447f735c3f5d70ac88077da7adf0eef90
2017-03-10 10:47:43 +01:00
Ashod Nakashian
c6dbce9767 nb: transfer client sockets to respective DocumentBroker
Change-Id: I6af656ec6cbb09d4dd80b7b583a009a763de6eb9
2017-03-10 10:47:43 +01:00
Ashod Nakashian
5a8734b7de nb: cleanup defunct socket code
Change-Id: Iaff9d530ca4a62eb3dcf3068f86d0bd52c47a5d0
2017-03-10 10:47:43 +01:00
Ashod Nakashian
76e96c92c8 nb: SocketPoll is now a thread object
Change-Id: I01d13292f0b97a9ebd1ccdef9e41fec46bfa0b11
2017-03-10 10:47:43 +01:00
Jan Holesovsky
8b8bb67cd7 Fix a misplaced ENABLE_SSL #endif.
Change-Id: Ie2a4b777f7df422eca18e3a1b5331b9e0c722c52
2017-03-10 10:47:43 +01:00
Michael Meeks
52327d78e2 Cleanout old socket code, and several obsolete LOOLWebSocket uses. 2017-03-10 10:47:43 +01:00
Michael Meeks
20f15d4001 Switch Prisoner socket handling to use the SocketPoll.
Kills the Poco ThreadPool usage, and significantly improves debuggability.
2017-03-10 10:47:43 +01:00
Jan Holesovsky
6083911a0d nb: Remember also the messages sent to sessions queued for creation.
Without this, it was impossible to connect to an existing session, because we
were trying to send messages to sessions that were not connected yet.

Change-Id: If9260a1f0ac8f5387f492541548724b0065df9d9
2017-03-10 10:47:42 +01:00
Jan Holesovsky
380624ba32 nb: Remove also the queued sessions.
Change-Id: I455fbbabfea9805d70fe909fd9b4078f02d21438
2017-03-10 10:47:42 +01:00
Ashod Nakashian
3b67f709d2 nb: Fix race when loading a document.
Don't block when creating new sessions, instead queue the requests, and handle
them in the DocumentBroker.

Change-Id: I200bbfc740f004c37178fa316d1eb91afdde5d4a
2017-03-10 10:47:42 +01:00
Jan Holesovsky
1914f9215c Revert "Horror hack to avoid race for now."
This reverts commit e977667754ba34b83ba0259d6568aa88ae5995df.
2017-03-10 10:47:42 +01:00
Michael Meeks
d4cc2e899c ClientSession: kill the writing thread. 2017-03-10 10:47:42 +01:00
Michael Meeks
1655e5d062 Improve socket state dumping on USR1. 2017-03-10 10:47:42 +01:00
Jan Holesovsky
4be3ac614d nb: Fix polling with http.
When we call readIncomingData() outside of the poll, we read the data, and
store them into the buffer.  But then the next poll will not indicate that
there data actually some available (they've been already read from the FD),
and we will get stuck.

I susppect we should remove from the SSL case at some stage too, to be
symmetrict to the non-SSL case.

Change-Id: Ib8339400b41e797adb2eb8519f87093ebf6be9c5
2017-03-10 10:47:42 +01:00
Michael Meeks
1b8e6f8c78 Horror hack to avoid race for now. 2017-03-10 10:47:42 +01:00
Michael Meeks
11c2e15a93 Rename members: accept and webserver pieces have cleaner names.
As distinct from the websocket poll per DocumentBroker.
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
Michael Meeks
073a216aa1 Annotate some blocking methods - ugly, but necessary. 2017-03-10 10:47:42 +01:00
Michael Meeks
333f8994e9 Cleanup shutdown flag handling.
Pull the notification pieces out of SigUtil.cpp - not signal safe,
and invoked only from LOOLWSD anyway.

In a non-blocking world, the socket close notification sends are
instant - so more work required to count-down / timeout remaining
clients.
2017-03-10 10:47:42 +01:00
Ashod Nakashian
2ed8c3d875 nb: search for free client port
Change-Id: I33238e83756481267c222b3cd3b9d30f4fcd3d48
2017-03-10 10:47:42 +01:00
Michael Meeks
892e755700 Cleanup shutdown. 2017-03-10 10:47:42 +01:00
Michael Meeks
fa96673ee0 Connect USR1 to initial global state dumping goodness. 2017-03-10 10:47:42 +01:00
Jan Holesovsky
7c9082e2a4 nb: No need to construct a new WebSocketHandler here.
Change-Id: I91bdc71732cd54266a2a3f8c751b09e22b7c83a4
2017-03-10 10:47:42 +01:00
Jan Holesovsky
62afe66df0 nb: Make the loolnb / clientnb work again.
The more testing the better :-)

Change-Id: Ibe4249f18109d50b06e1fa35e6d0fef67f9b3643
2017-03-10 10:47:42 +01:00
Jan Holesovsky
653df9dcce nb: No need for the WebSocketSender I think.
Change-Id: I133bb8341a846d70f95e0c70274541b5db62f65d
2017-03-10 10:47:42 +01:00
Ashod Nakashian
a68c33477d nb: support inserting image
Change-Id: I6ef11634bbda7e3ecdc467ce10727c8573caef8d
2017-03-10 10:47:41 +01:00
Ashod Nakashian
f26e64fb54 nb: shutdown on reaching connection or document limit
Change-Id: I5eedaf780ed00804d93c362e83ac4fcfd5d057b1
2017-03-10 10:47:41 +01:00
Ashod Nakashian
28b3813249 nb: clear the input buffer only on success
With multipart streams the parsing isn't
done until all parts are in. We will need
to reparse the header when more data comes in
until we can parse all parts. Otherwise we
end up removing the header and losing it
when we can't find all parts in the body.

This fixes convert-to requests.

Change-Id: Ic1d5ccbd00fd6763eb91fdda35177f6df847f100
2017-03-10 10:47:41 +01:00
Ashod Nakashian
4abf706af6 nb: websocket shutdown support
Change-Id: I2fcab98e9725eca86d097f34236889fdf9289c47
2017-03-10 10:47:41 +01:00
Ashod Nakashian
17fc91e220 nb: process POST requests
These are really GET requests that aren't
WebSocket upgrade. Should rename to something
less misleading.

Re-enabled testSlideShow which depended on this.

Change-Id: I52b7f67b650fcdcbae7c2bff020b756099263141
2017-03-10 10:47:41 +01:00
Ashod Nakashian
4b36fc9716 nb: send the WS upgrade response separate from later frames
Apparently if we don't send immediately after the upgrade
the first frame doesn't get parsed as WebSocket (at least
in Poco).

Change-Id: Ieb30afae1423d8352d81c79af568947d10fca1e6
2017-03-10 10:47:41 +01:00
Michael Meeks
3df5061a6b Wait for more data pleasantly if we fail to parse HTTP header. 2017-03-10 10:47:41 +01:00
Ashod Nakashian
f08d9c9ec1 nb: handle bad requests with 400 response
Change-Id: I15ecc06a933a88f5ccdd0acfd16aac8b357f29df
2017-03-10 10:47:41 +01:00
Ashod Nakashian
ccdb1bcc6e nb: proper POST body processing
Change-Id: Ic37094e50979e14d2862ae32088295b42d9c4931
2017-03-10 10:47:41 +01:00
Ashod Nakashian
0c19d81fee nb: read the socket on accept
It's necessary to do the SSL handshake
and to get the request (if we get there)
on accepting so by the time we poll we know
what SSL needs to do next. No reason to
read on first poll when we should be
expecting a request upon connection anyway.

Change-Id: I8eecaad5f8450075d45e487702972418cad125bc
2017-03-10 10:47:41 +01:00
Ashod Nakashian
72669bf929 nb: logging
Change-Id: Ia67f746a6c71b4753d04b92472eddf1614c0d337
2017-03-10 10:47:41 +01:00
Ashod Nakashian
df45db9da2 nb: shutdown socket after file-serving
Change-Id: Ibe0b33f371d46e62637f570265fcdf9c8bf60b2d
2017-03-10 10:47:41 +01:00
Ashod Nakashian
925934d09d nb: set the Date in http header
Change-Id: I71e3388c1f204135c6dc72ad27890bffe53792b3
2017-03-10 10:47:41 +01:00
Ashod Nakashian
0759d1afbc nb: http error cases in file server
Change-Id: I81b0ef3f080ba61836d99fbdde0fb94e1a44a625
2017-03-10 10:47:41 +01:00
Ashod Nakashian
1bb29282f1 nb: serve files using non-blocking sockets
Change-Id: I254288980f72f197d29b7b57ec9c88a01a5a1d03
2017-03-10 10:47:40 +01:00
Ashod Nakashian
ba8d3c8eb1 nb: log requests as debug and not error
Change-Id: Ic3ec3257f98c80e959c9d980fe6b1d8d6f40f604
2017-03-10 10:47:40 +01:00
Ashod Nakashian
c8619bed1f nb: respond with HTTP 200 on root
Change-Id: Icfcf8d79d5b6370b7965584e89e9006d7bd451b3
2017-03-10 10:47:40 +01:00
Ashod Nakashian
de92b1627e nb: send files over HTTP
Change-Id: I346e97cd19a8dbbdee493d23b89c390ea6e3c948
2017-03-10 10:47:40 +01:00
Ashod Nakashian
0d9bbac18c nb: serve wopi discovery XML
Change-Id: I7bb4910f948e8b4e89f3bbdf2a62a8b1540eef2f
2017-03-10 10:47:40 +01:00
Ashod Nakashian
9bf8720d2b nb: SSL socket support in wsd
Change-Id: I21e8b2d04caf7da872fe07b4950b02a8c52a3552
2017-03-10 10:47:40 +01:00
Ashod Nakashian
2b4e7bd067 nb: SocketHandlerInterface must hold weak_ptr to Socket
Because the socket can be freed while a separate
thread is sending data via the handler, we must
have a locked reference to the socket instance
in the handler.

Change-Id: Iefad3fc2b147f96b8d538d9edd7cac3fce25b5bf
2017-03-10 10:47:40 +01:00
Ashod Nakashian
32b7d5ceee nb: WebSocketSender used to send back loading progress
Change-Id: I3b09c44c4d64db39217d364ebff0a647a82457f4
2017-03-10 10:47:40 +01:00
Ashod Nakashian
5b944cf99b nb: don't own your owner
Change-Id: Ia74dbd3441b8b1f682091ba3d973dd33b2599309
2017-03-10 10:47:40 +01:00
Ashod Nakashian
66bc78aa33 nb: differentiate between incomplete request and processing failure
Change-Id: Ieffae987c9008a92d8040f0c4315afe6625715c4
2017-03-10 10:47:40 +01:00
Ashod Nakashian
221059cd6b nb: move WebSocket upgrade to the ClientRequestDispatcher
Change-Id: Id11b139563a55e50d3f7e216e2231d79e07015b3
2017-03-10 10:47:40 +01:00
Ashod Nakashian
73f9001004 nb: remove HTTP handling from WebSocketHandler
WebSocketHandler now supports upgrading given
the original HTTP header.

Change-Id: Ifb3b8fee9aef8015548a625bbb88e75f4e97255f
2017-03-10 10:47:40 +01:00
Ashod Nakashian
6b28ea0c12 nb: autosave document on client disconnection
Change-Id: Ic75a9796a1cca0bf919fb2dcbe24c504e447e7f1
2017-03-10 10:47:40 +01:00
Ashod Nakashian
3b3b61af30 nb: create and assign ClientSession to DocumentBroker
Change-Id: I684007363de6e25d78f9f1c9236fd623325da509
2017-03-10 10:47:40 +01:00
Ashod Nakashian
3cff4f69c5 nb: find existing DocumentBroker or create a new one
Change-Id: I4e15254a90bc00a77341e8dd85353aa5d68a14e0
2017-03-10 10:47:40 +01:00
Ashod Nakashian
e89e5fb978 nb: create DocumentBroker and attach to ChildProcess
Change-Id: I751ac0b7599400fc9527455f95361cea447d0c69
2017-03-10 10:47:40 +01:00
Ashod Nakashian
1d47d3af8d nb: client request handler outline
Change-Id: I40d403099c7150c5d6365399adbd05ff2c7c386b
2017-03-10 10:47:40 +01:00
Ashod Nakashian
e047f55e3c nb: SessionID and connection throttling support
Change-Id: Ifb871ed42d314038e17d02512c8f3c31c1ab54ad
2017-03-10 10:47:39 +01:00
Ashod Nakashian
7fdb7a1861 nb: StreamSocket takes ownership of SocketHandler instance
Change-Id: Ica99dc8afbcca71c8d79eecb276ba19f6f01fa57
2017-03-10 10:47:39 +01:00
Ashod Nakashian
d9394d7000 nb: Our SSL manager conflicts with Poco's
Change-Id: Ieed6eecabc60997b73636ab6c13bc5ca3682008a
2017-03-10 10:47:39 +01:00
Ashod Nakashian
5e79581952 nb: StreamSocket must always have a handler
And also emits disonnection event.

Change-Id: Ibb60c6fca55c58b886f5ff77c6e22769a128e950
2017-03-10 10:47:39 +01:00
Ashod Nakashian
6d244129b3 nb: more request type handlers
Change-Id: I89ee4d6bf675d2e945199ed63a115f031aec580f
2017-03-10 10:47:39 +01:00
Ashod Nakashian
6dc884160b nb: add ClientSession handler
Change-Id: I5ed2003f07bb5173ea37420d4939cc93b1aef1d8
2017-03-10 10:47:39 +01:00
Ashod Nakashian
3602526f5b nb: add request-specific handlers
Change-Id: I219fc9ef23c6c9e646dd609bb3ece2607ca78828
2017-03-10 10:47:39 +01:00
Ashod Nakashian
d9d6bfdb80 nb: new ClientRequestDispatcher added
Requests need to be introspected and
dispatched to the appropriate handler.

File serving, admin, POST request, etc.
are all valid types that we need to support.

But of course the primary one is the WS request
to load to and interact with a document.

Change-Id: Id2c3214deb6b54b06b2735ec3370f09ed7a1ae51
2017-03-10 10:47:39 +01:00
Ashod Nakashian
510c499e70 nb: stop server threads on termination flag
Change-Id: I2eb0bed49b289b96c4c82687ee7b949c3162de31
2017-03-10 10:47:39 +01:00
Ashod Nakashian
607f7214ba nb: simplify hardcoded test document path
Change-Id: I0e5a078401d4b0be7a2504c5a1a3909ef287d198
2017-03-10 10:47:39 +01:00
Ashod Nakashian
c6fe2452cf nb: take DockBrokers lock where required
Change-Id: I26a1a7f07b4f902dd9f7bbe7bf5eb2571a57099b
2017-03-10 10:47:39 +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
Jan Holesovsky
ba9239441b nb: Comment out the POCO server in loolwsd.
Change-Id: Ie4f276a6f1c8f3d132b23bb2111466b38f4fb581
2017-03-10 10:47:39 +01:00
Jan Holesovsky
0696082653 Clarify the PrisonerRequestHandler documentation.
Change-Id: Ie3750b17ce4f2d99b80f39f3c0e1374f3e9c1a5a
2017-03-10 10:47:39 +01:00
Ashod Nakashian
28bfb5547b nb: comment to replace ConsoleCertificateHandler
ConsoleCertificateHandler will block on stdin
when a certificate error occures. This is hardly
helpful to users. Although in a server environment
this is likely to go to the journal, we should
properly log it and shutdown, rather than hang
waiting for the unlikely console input.

Change-Id: I54bb38ec60f443c579ef20dbb759941fae182e5b
2017-03-10 10:47:38 +01:00
Miklos Vajna
f296c0ffeb wsd: avoid redundant string initialization
Change-Id: I5ac26d56c3b73e380d26226e83020ace3f1b54f4
2017-02-14 09:33:23 +01:00
Ashod Nakashian
9120fbabad wsd: use separate read/write locks in LOOLWebSocket
When two sockets send data to each other in blocking
mode, they can both wait until the other end-point's
buffers are free enough to receive the data being
sent. Since in LOOLWebSocket we lock both send and
receive with the same lock, this prevents the
reader thread from freeing the buffer while we try
to send data. But since our peer is in the same
dilemma, neither of us will make progress--deadlock.

Since sockets are full-duplex, they are capable of
handling two way communication concurrently. Poco
seems to not share data between them either, so
this seems safe.

Change-Id: I1fd68cd4fb3b4250b93c8f94cd42e49ee78f6650
Reviewed-on: https://gerrit.libreoffice.org/34194
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-02-13 06:53:38 +00:00
Ashod Nakashian
2da90d0cfc wsd: explain the root of the document bifurcation bug
Change-Id: I9ac290c94296ed18dc25ce3b2d9c4939e4eeea91
Reviewed-on: https://gerrit.libreoffice.org/34192
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-02-13 05:25:13 +00:00
Ashod Nakashian
79c1791764 wsd: don't block on autosave
Change-Id: Id87465f0aeea9d4f29caea9c88d3a8c7837d8ec2
Reviewed-on: https://gerrit.libreoffice.org/34191
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-02-13 05:20:44 +00:00
Miklos Vajna
f81ab32c57 wsd: remove remaining unused using declarations
Change-Id: I7d0d453194bdd069654f29105e3f17769036cd39
2017-02-10 09:07:40 +01:00
Ashod Nakashian
7f19d809b1 wsd: skip busy docBrokers when cleaning up
When cleaning up DocumentBrokers we hold
the global DocBrokersMutex. So we need
to keep this lock as short as possible
to serve new requests.

However when a given DocBroker is locked
and busy, or worse deadlocked, we'd end
up blocking any new client connection.

So here we skip busy DocBrokers while
cleaning up.

Change-Id: I188c9abc34fd90c4ba388894b47c1ab08d185129
Reviewed-on: https://gerrit.libreoffice.org/34119
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-02-10 07:12:45 +00:00
Ashod Nakashian
15862a5b5f wsd: we need to dump NewSession event on every connection
...and not just when loading a new document.

Change-Id: If5b19e500c59a8d1fcf96666ef244833c05e2b99
Reviewed-on: https://gerrit.libreoffice.org/34118
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-02-10 07:07:32 +00:00
Ashod Nakashian
2cff31d0fd wsd: decode URI before calling URI::getPath as it fails
Poco documentation for getPath says
"Returns the decoded path part of the URI."

Unfortunately, this isn't true for encoded URIs.
It ends up returning the full URI (albeit decoded).

So we decode the URI ourselves before calling
getPath to ensure it will be able to parse it
and return only the path, as promised.

Change-Id: I23ed65f753f7e5db74ce7833b812f566b1964037
Reviewed-on: https://gerrit.libreoffice.org/34117
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-02-10 07:06:28 +00:00
Ashod Nakashian
53a8101331 wsd: log the trace file duration and each record before executing
Change-Id: Ia5c21f01198de3dc655fe3bf247178dd04f5eaa7
Reviewed-on: https://gerrit.libreoffice.org/34113
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-02-10 07:03:26 +00:00
Ashod Nakashian
31fc9e1db2 wsd: fix fuzzer build
Change-Id: I121e5e24198e8906af27300752919592283bdb11
Reviewed-on: https://gerrit.libreoffice.org/34054
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-02-09 04:50:18 +00:00
Ashod Nakashian
3fb136170f wsd: extend timeout when nocaps is specified
Change-Id: Id10b38716cc184bf899120bbe18d9095fd2f48e5
Reviewed-on: https://gerrit.libreoffice.org/34053
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-02-09 04:36:17 +00: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
Jan Holesovsky
c49e810437 Avoid crash on exit with trace file disabled. 2017-02-08 22:57:50 +01:00
Jan Holesovsky
ad20adce1a fuzzer: Don't handle signals when fuzzing.
Change-Id: I2febdf96bcbbd5c6edaf791d99a77674e6f0b0a9
2017-02-08 21:39:55 +01:00
Jan Holesovsky
cb3ccfe32d Fix crash on exit in the Admin console.
Change-Id: I5f90a12eb95f59d2b52a52e59526488b94975387
2017-02-08 21:39:10 +01:00
Jan Holesovsky
cd90d8adfe fuzzer: Add --dummy-lok command line option that bypases LibreOffice.
When provided, the DummyLibreOfficeKit is used instead of the real one that
calls LibreOffice.

Change-Id: Ic170d7b4adb72ba17a2b066c509c2b1e657dbccf
2017-02-08 12:34:16 +01:00
Jan Holesovsky
6dd581f635 fuzzer; Added --fuzz param that takes a looltrace file as input.
To perform one fuzzing iteration, use something like:

  ./loolwsd_fuzzer --config-file=loolwsd.xml --o:lo_template_path="/opt/libreoffice/instdir" --o:storage.filesystem[@allow]=true --fuzz=/tmp/looltrace

Change-Id: I27210d55a65f75e7d51e05c2f5f999acb758c4b1
2017-02-08 08:35:13 +01:00
Jan Holesovsky
964ae25ccf fuzzer: Factor out the replay functionality to a separate file.
Change-Id: Ief946b1703ef1ca0b17de3467dce66b4c3da2601
2017-02-08 08:35:13 +01:00
Miklos Vajna
836af6724f wsd: fix -Werror,-Wunused-function
Change-Id: I957440a2ac78f89d2f74aad66813b1ef56b5b532
2017-02-08 08:29:10 +01:00
Michael Meeks
e662b3457a AdminConsole: add new propchange notification, and update memory live. 2017-02-07 18:55:32 +00:00
Michael Meeks
9ec0466c57 Admin - measure dirty memory of kits, and RSS of forkit.
Gives a more accurate real memory consumption for each process.
2017-02-07 18:55:32 +00:00
Andras Timar
69ea3a2721 wsd: typo: Conection -> Connection
Change-Id: I4f46298cde972504aa90028344f0c43eb5660ebf
2017-02-07 13:47:03 +01:00
Jan Holesovsky
04d7ed9d09 fuzzer: Make the shared loolwsd and loolforkit binary actually work.
Change-Id: If6ee9f22d93aa040f94df86b30fdc8a0a1ad68e2
2017-02-07 13:27:14 +01:00
Jan Holesovsky
0dac1c4321 fuzzer: Compile a separate binary that contains both loolwsd and loolforkit.
Change-Id: I158e4b19d0929de03f09645c106aebfdbc44ea74
2017-02-07 13:27:14 +01:00
Jan Holesovsky
898b5d9e4c Treat the rest of the line as payload, because it may contain the delimiter.
Change-Id: I883f41727cf46c4b71484d2b99144ae7e30ef6d3
2017-02-06 13:36:54 +01:00
Ashod Nakashian
11c08d7663 wsd: remove logging of detailed memory stats
Change-Id: Id804cc342d786e745d7ac214ea72b198bf0b639b
2017-02-05 22:08:23 -05:00
Ashod Nakashian
7d58df49fa wsd: new config to enable/disable snapshots when recording trace
By default snapshots are disabled, since trace recording
is enabled, to avoid unexpectedly flooding the disk.

Change-Id: I6c8728e14801f0a72accde1378455ec0e6046e3e
2017-02-05 22:03:18 -05:00
Ashod Nakashian
57212b69b8 wsd: take snapshot of source file before trace recording
Change-Id: Ia3e25467a20d2442dcf0497c21a8fdce2efedbc2
2017-02-05 21:59:23 -05:00
Ashod Nakashian
64335b4127 wsd: correctly initialize forkit pid in Admin
Change-Id: I376742fa324f207d77fa290046657f17f8872b27
2017-02-05 21:59:23 -05:00
Ashod Nakashian
a7afc59e51 wsd: trace files support timestamp to prevent overwritting on restart
Change-Id: Ided928e7428d35f9ed322720ea306e090bdd0c38
2017-02-05 21:59:23 -05:00
Ashod Nakashian
0476d1d9f2 wsd: don't complain to the user on idle termination
We no longer tell the clinet "This is embarrassing..."
when we disconnect and unload an idle document. Instead,
the client UI remains greyed out so the user can resume
as if it was inactive (and reload the document in this case).

Also, we now always send the "close: " message prior
to shutting down a client websocket. This is more
reasonable and consistent when we intentionally disconnect,
so clients can rely on it to signal intent and give reason.

Otherwise, a disconnection without this application-level
message should be unexpected and is therefore reasonable
to show the "This is embarrassing..." message.

Change-Id: Ic7439bcc9267be155586ccd5d122e9fe60225516
2017-02-05 21:59:23 -05:00
Ashod Nakashian
b095e06173 wsd: fix crash when unloading idle documents
A race condition between the client socket thread
and the idle-document cleanup caused segfault
on the websocket.

Now the ChildProcess object doesn't reset
the websocket on closing, rather on destruction.

Change-Id: I10d0dfb1ba677a65479df85b7a53de8c5f1b44c3
2017-02-05 21:59:23 -05:00
Ashod Nakashian
5cac95e6a9 loleaflet: remove pagepartrectangles request and handling in loleaflet
Change-Id: Ib83e7c0ca05a7d7d1a3d30675ef3cf5804f5ac4c
2017-02-05 21:59:22 -05:00
Ashod Nakashian
5dad626b6d wsd: remove handling of depricated partpagerectangles command
Change-Id: I13285e83179ab7654b6fd21a6548730e74d67425
2017-02-05 21:59:22 -05:00
Samuel Mehrbrodt
1f2d04a5e4 Online, not on-line
Change-Id: I93a8322dceca7c1ed95449c6aeb4ae854b982957
Reviewed-on: https://gerrit.libreoffice.org/33886
Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
Tested-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
2017-02-03 13:47:30 +00:00
Ashod Nakashian
d7a9a76ddb wsd: report PSS of kit processes
Each Kit process now reports its own PSS,
which is much more accurate as they share
a significant ratio of their pages with
one another.

Admin tracks the PSS values of the Kits
and reports to the console.

Change-Id: Ifa66d17749c224f0dc211db80c44f7c913f2d6c4
Reviewed-on: https://gerrit.libreoffice.org/33864
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-02-03 07:12:31 +00:00
Ashod Nakashian
ae8c352928 wsd: access AdminModel instance under lock
Change-Id: I6c5c07dafa69f052ee81e7cbecb4d1f2b772fef9
Reviewed-on: https://gerrit.libreoffice.org/33863
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-02-03 07:08:58 +00:00
Ashod Nakashian
4eed11e2be wsd: Admin logging updated
Change-Id: I7d7e0f98f10ae3ef10ca15cf6ad510a3d7bab00e
Reviewed-on: https://gerrit.libreoffice.org/33859
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-02-03 07:06:06 +00:00
Ashod Nakashian
942aedb414 wsd: AdminModel logging update
Change-Id: Ia9225d4778b69f6417d4025876d7e9560918b05b
Reviewed-on: https://gerrit.libreoffice.org/33856
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-02-03 07:04:41 +00:00
László Németh
3616b4a6a8 wsd: fix snap support
- add loolwsd option --config-file=path

- search all data files in the actual data directory
  instead of the default one.

(cherry-picked from commit c4e9681fd17381c7af2936726262d7357a7dda10)

Change-Id: I028ff8a696aa6336da55bcac2952f13b12ba8eb8
Reviewed-on: https://gerrit.libreoffice.org/33504
Reviewed-by: Jan Holesovsky <kendy@collabora.com>
Tested-by: Jan Holesovsky <kendy@collabora.com>
2017-02-01 14:24:48 +01:00
Ashod Nakashian
cc3285e923 wsd: log memory stat duration and averages
Change-Id: I8c84053c52c6725d2bda2e75313c52520e4bae6e
Reviewed-on: https://gerrit.libreoffice.org/33679
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-30 05:10:44 +00:00
Ashod Nakashian
292400eeed wsd: reuse the timer-based memory stats for admin requests
Change-Id: I3778458043174fb5489617d022445205daf91532
Reviewed-on: https://gerrit.libreoffice.org/33673
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-30 02:10:13 +00:00
Ashod Nakashian
e342c87dbf wsd: account for transient file connections
The connection limit MAX_CONNECTIONS
is for document WS connections, which
doesn't take into account the other
resources (.js, .css, etc.) that clients
request. These transient files are as
many as 10 per client. While they
are being requested, other clients
should not be blocked due to reaching
the limit.

We now take into account these connections
and allow at least half as many clients
as the limit to connect simultaneously
without blockage.

Change-Id: I42fd27b992457bcf765a7a85382e6d7caad4bc97
Reviewed-on: https://gerrit.libreoffice.org/33669
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-30 02:04:41 +00:00
Pranav Kant
440ca8e2f7 Initial support for comments lok api
Change-Id: I1fc48e245a47f7b8d4260009d8c377c30d0b8820
2017-01-27 23:36:24 +05:30
Jan Holesovsky
3c9f4e1e1f Deduplicate & remove obsolete invalidations from the queue.
There's no point in trying to paint something we know will be obsolete anyway.

Change-Id: I14f61f389b114f2cda1f97e5223b31fa2f01b06c
2017-01-26 11:49:29 +01: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
f73a17c759 wsd: use Message objects to handle kit responses
Change-Id: Ifc9c53ead8d87e9aebfd8c60442a726de5270cc5
Reviewed-on: https://gerrit.libreoffice.org/33440
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-26 02:12:00 +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
c7e2a4cc88 wsd: move headless check in enqueue function
Change-Id: I2a09d2c5e5c1705e5caeb8563babcd939384a583
Reviewed-on: https://gerrit.libreoffice.org/33432
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-23 05:54:15 +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
8c34244285 wsd: forwardToPeer now takes pre-constructed Message
Change-Id: I58acbeb6d27fbc9b99434c2743f69a4faa3a048b
Reviewed-on: https://gerrit.libreoffice.org/33430
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-23 05:53:11 +00:00
Ashod Nakashian
bb4733b6d6 wsd: Message::abbrevation -> abbr
Change-Id: If8cab421808689ba4f5ba6a75a960d6b64755b4b
Reviewed-on: https://gerrit.libreoffice.org/33429
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-23 05:48:15 +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
6b17f96318 wsd: refactor MessagePayload into own file
Change-Id: Ifc0d2abd2e94d4a1b58915664fb0545dca6e96cc
Reviewed-on: https://gerrit.libreoffice.org/33427
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-23 05:45:23 +00:00
Ashod Nakashian
11d7d8c595 wsd: log the fingerprint of WOPI files
Change-Id: I99bd77c2ae892876d82bab64210bd132f34ed364
Reviewed-on: https://gerrit.libreoffice.org/33439
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-23 05:43:38 +00:00
Ashod Nakashian
cb052c98c7 wsd: DocumentBroker cleanup
Change-Id: I7feadf8c6b14b42e88d4f4eb4de29a77235dd953
Reviewed-on: https://gerrit.libreoffice.org/33436
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-23 05:43:12 +00:00
Ashod Nakashian
16eb196820 wsd: each Message object now has a unique ID for logging purposes
Change-Id: I5f3c3afec57f3d9336e0994a1d87421281028d79
Reviewed-on: https://gerrit.libreoffice.org/33426
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-23 05:42:34 +00:00
Ashod Nakashian
b497fcfac5 wsd: close the socket when shutting down fails
Change-Id: Iea5c6a259272b6af881a5bfb27ffc31d2ad27793
Reviewed-on: https://gerrit.libreoffice.org/33424
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-23 05:40:52 +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
Tor Lillqvist
55010980aa Avoid misleading logging
If Poco::Bet::WebSocket::receiveFrame() returns 0 or -1, flags is
likely meaningless.

Change-Id: Ia1d7cbcbfc338f9d0c60e14a6b460ddc090d0b6d
2017-01-18 15:45:33 +02:00
Miklos Vajna
0026f580a3 wsd: clean up redundant .c_str() call
Change-Id: I83e6160dec6cdbd8b621e1b783c9ea51be6b9125
2017-01-18 10:39:20 +01: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
73cd57d09c wsd: not spawnining is not failure to rebalance children
Change-Id: Iab29073a610ba19f3c25584fbdd08a7407258e1b
Reviewed-on: https://gerrit.libreoffice.org/33201
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-17 04:13:13 +00:00
Miklos Vajna
2c978b0359 wsd: these enum values are intentionally from different enum types
Which is dangerous in general, but here the values are from
non-overlapping ranges. Make it a bit more explicit that this is not an
accident.

Change-Id: I56897473a755e28cd9e7f74ceacecbab2db5e829
2017-01-16 13:50:16 +01:00
Ashod Nakashian
dc57cf8d3c wsd: 0-byte files are valid and LO loads them as new docs
Change-Id: Icf0cdd05ca7397f29bf66139d4ef15ef86ec05fd
Reviewed-on: https://gerrit.libreoffice.org/33141
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-16 06:26:22 +00:00
Ashod Nakashian
63dd8fca9b wsd: improved forkit crash recovery
Refactored the forkit process wait and
re-fork into separate function.

Change-Id: If6106ea3820d10b4448bb27740d757afcea4779f
Reviewed-on: https://gerrit.libreoffice.org/33137
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-16 02:17:10 +00:00
Ashod Nakashian
bccb2fcad6 wsd: forkit process id is now a static member
Change-Id: I4bb6a419a83ecd30745681848e93629658baa763
Reviewed-on: https://gerrit.libreoffice.org/33136
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-16 02:15:19 +00:00
Ashod Nakashian
c74c2b8f47 wsd: increment outstanding forks counter when forking
Change-Id: I6360ea582cc060c51e54fe8bb55eac2f709fbabc
Reviewed-on: https://gerrit.libreoffice.org/33134
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-16 02:14:07 +00:00
Ashod Nakashian
f3fb3beeea wsd: block new requests when recovering forkit
Change-Id: Ibed650b52f2398cd336332b5264439752ff9e290
Reviewed-on: https://gerrit.libreoffice.org/33133
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-16 02:13:38 +00:00
Ashod Nakashian
e3aec0e6c4 wsd: detect and fail child forking when forkit is down
Change-Id: I97ba133b0285403b7dfa4b6a6cbef26b818dcaf3
Reviewed-on: https://gerrit.libreoffice.org/33132
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-16 02:11:33 +00:00
Ashod Nakashian
818329d66e wsd: update outstanding forks only on successfull write
Change-Id: I312b3f860d98a31e8a28742915df32eb7e737037
Reviewed-on: https://gerrit.libreoffice.org/33131
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-16 02:10:20 +00:00
Ashod Nakashian
373b464645 wsd: logs and cosmetics
Change-Id: I67b0a929a50b05cd44de056ce6f8baafb8574dbf
Reviewed-on: https://gerrit.libreoffice.org/33130
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-16 02:09:41 +00:00
Ashod Nakashian
b1ff72e13f wsd: move shutdown web socket helper into LOOLWebSocket
Change-Id: Ide377fe3a8c950490bb6c04382464f0fdfd66088
Reviewed-on: https://gerrit.libreoffice.org/33129
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-16 02:08:28 +00:00
Ashod Nakashian
be5659d534 wsd: simplify preforking of children
Forkit always spawns a single child.
This is done to validate that forking
children is working and to be ready to
serve clients.

However, this initial forking can be slow,
mostly due to cold file reading and loading.
This often causes multiple child spawning
and other undesirable effects.

This patch makes sure that a single child
is always at the ready before proceeding
while simplifying the code. Otherwise, if
forkit fails to fork a single child within
4x an expected command-timeout (currently 5
seconds) then we fail the service altogether.

Change-Id: Ie2a441a2479db98a54f7fb9b9c8e98cda2f07c1c
Reviewed-on: https://gerrit.libreoffice.org/33128
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-16 02:04:21 +00:00
Ashod Nakashian
bc36241d89 wsd: cosmetics
Change-Id: I250590b105dbfdd6a0589327fece752481253863
Reviewed-on: https://gerrit.libreoffice.org/33127
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-16 01:59:15 +00: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
a31e606a98 wsd: retry loading DocumentBroker and adding session
In some cases when the last session is destroying
and we expect the DocumentBroker to be removed,
while waiting for autosave, a new client might
connect to the very same document.

In those cases we shouldn't fail but should retry
loading the document again once it has been unloaded.

Change-Id: I97ebb73991b9739cfb4e93b7de9115bdb48fda7a
Reviewed-on: https://gerrit.libreoffice.org/33125
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-16 01:56:20 +00:00
Ashod Nakashian
1c67d9387f wsd: addSession now must be called under lock
Change-Id: I6148d7ac3edd88f922d258f39ea22b372dba84f0
Reviewed-on: https://gerrit.libreoffice.org/33124
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-16 01:55:10 +00:00
Ashod Nakashian
087f993040 wsd: use refactored createNewClientSession
Change-Id: I7d9128865eea6c5fd9f48b469fb35ede3c811b4b
Reviewed-on: https://gerrit.libreoffice.org/33123
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-16 01:53:59 +00:00
Ashod Nakashian
296d25d24c wsd: refactor create new client session
Change-Id: Ida08901563c5d2aa4e3708f8d21a7e7bc0685ac6
Reviewed-on: https://gerrit.libreoffice.org/33122
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-16 01:52:58 +00:00
Ashod Nakashian
fa795d8c9b wsd: refactor DocBroker session removal and cleanup
Change-Id: I7019aa7c0c44c6a02e2ee54f280e95fdf1bbe35c
Reviewed-on: https://gerrit.libreoffice.org/33121
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-16 01:52:16 +00:00
Ashod Nakashian
a06c23e18a wsd: refactor create new DocBroker
Change-Id: I3d099bfbd60d68ea0f6fcd38ddaddd4d74c1f017
Reviewed-on: https://gerrit.libreoffice.org/33120
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-16 01:52:00 +00:00
Ashod Nakashian
b8160c1c1a wsd: return 0 when fail to proc get memory
Change-Id: Ie7f0fdc031a71c76484705cfb2feee1744bbbd8b
Reviewed-on: https://gerrit.libreoffice.org/33119
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-16 01:49:07 +00:00
Ashod Nakashian
0e5a75c46b wsd: exit the kit only when no more sessions exist
Change-Id: I26cd8876fd564f537dac4fb1748aee5b4dbdff04
Reviewed-on: https://gerrit.libreoffice.org/33114
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-16 01:43:08 +00:00
Ashod Nakashian
dea8c03912 wsd: no need to have the lock when notifying
Change-Id: If19aac3d52b45b0b0efc143885b933669d8a1198
Reviewed-on: https://gerrit.libreoffice.org/33113
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-16 01:36:00 +00:00
Ashod Nakashian
dcc0dc441e wsd: headers and formatting
Change-Id: I2bd62379cf1008a809638354b618bd2383a316c2
Reviewed-on: https://gerrit.libreoffice.org/33112
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-16 01:35:37 +00:00
Tor Lillqvist
11ae90cfcb No Hungarian notation please
Change-Id: Ia624de45a792db7e39f2245aaea7d940b30b0db2
2017-01-13 14:52:08 +02:00
Tor Lillqvist
40e5a66701 No double colon in English text;)
Change-Id: I3e25a5e1be8672a7796a71a28c2979a30ab326a3
2017-01-13 13:39:10 +02:00
Tor Lillqvist
591fc02384 No Hungarian notation please
Change-Id: I0701dfbecb0b6056c0453d83bac9e85a98eff366
2017-01-13 13:37:00 +02:00
Tor Lillqvist
ba733ffad7 Prevent accidentally having duplicate loolwsds on same port, new approach
Before setting up the socket where we listen for client requests, try
connecting to the same port. If that succeeds, another loolwsd process
is already running and listening on that port. That is obviously
undesirable.

Yes, there is a race condition if multiple loolwsd processes are
started simultaneously and do this check before any of them have
actually created the socket. Live with it. Multiple loolwsd processes
is a problem that happens accidentally for developers only anyway. In
a production environment systemd takes care of having just one, I
hope.

Thanks to Kendy for the idea.

Change-Id: Ifdde83472f9a56e592ec5dc7649dd7706efc2f7c
2017-01-13 13:32:10 +02:00
Tor Lillqvist
bc19f90dd4 Don't send a tile that hasn't changed even if client asks for it
The server tells the client the hash of each tile it sends (calculated
from the contents of the tile, not its PNG encoding). When the client
asks for a tile to be refreshed, it tells the server what the hash of
the existing tile is. If the server notices that the tile contents
hasn't actually changed, it doesn't PNG encode it and doesn't send it
to the client.

The intent is that this will reduce load on the server and also avoid
unnecessary tile traffic.

Change-Id: Ia06ca68655ea984ed4319f24f4470afda322eccf
2017-01-11 23:25:21 +02:00
Ashod Nakashian
b2160ee3a7 wsd: improved logging
Change-Id: I9c10803f451b6226c6a15d89acd4758c04042f28
Reviewed-on: https://gerrit.libreoffice.org/32864
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-09 06:20:33 +00:00
Ashod Nakashian
731bfb08c5 wsd: don't wait on the DocBrokers lock when prespawning children
Prespawning proactively is optimistic, but is not critical.
When getting a space child, more will be spawn perforce,
so prespawnChildren shouldn't block.

Change-Id: I60cc8c1ab87cba384ebc9aca9e79b89f69a99252
Reviewed-on: https://gerrit.libreoffice.org/32858
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-09 06:16:58 +00:00
Ashod Nakashian
e6ee7c2756 wsd: MAX_DOCUMENT is now always defined as positive
Change-Id: I06018eeaab88bb3ede896bf7d74e1a7ce6f84325
Reviewed-on: https://gerrit.libreoffice.org/32857
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-09 06:15:11 +00:00
Ashod Nakashian
dfcada64b8 wsd: tilecombine now includes the versions of the tiles
Previously tilecombine had its own version, which is
nonesensical, since it's not really a tile.

Now it passes the version to the tiles when
parsing and serializes version per-tile.

Change-Id: I5db8d94880431e3d2a40b6787c6fe51a05771305
Reviewed-on: https://gerrit.libreoffice.org/32633
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-09 06:09:05 +00:00
Tor Lillqvist
51c697a473 No need for these default values of parameters
Change-Id: Idc369d8cfb5eb7719d378d871f5e1b589ba1d922
2017-01-05 14:59:26 +02:00
Pranav Kant
62a666c06a wsd: better handling of low storage situation
There is no way to let the user of document currently being
opened, in case of failure, know that disk is low on space.
We check the disk space when forking children after which we try
to alert all users but this would end up doing nothing for
current document because document broker is not registered at
this time (we iterate through doc brokers when alerting). Another
conditional disk check is performed just before opening the
document but this is performed only if last disk check was
performed greater than 60 seconds which would never be the case
because document open is always preceded by a child fork (when
rebalancing children).

Lets not cache the disk check when forking the children to
prevent above mentioned situation while still minimizing the
number of disk checks performed.

Change-Id: Id3add998f94e23f9f8c144f09e5efe9f0b63821c
2017-01-04 14:21:02 +05:30
Ashod Nakashian
59dfe338cb wsd: safely count the number of current connections
Change-Id: I90b2436f804acd9b0295ba2ce944e8b68a59db91
Reviewed-on: https://gerrit.libreoffice.org/32715
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-04 04:32:32 +00:00
Ashod Nakashian
3a79e13214 wsd: use MAX_CONNECTION from configure instead of hard-coded MAX_SESSIONS
Since we always need to set the thread-pool size
anyway, we cannot have 'unlimited' connections.

Actually, we never did, so that was misleading
in configure.ac anyway.

The current defaults are 20 connections and
10 documents, instead of the previous 1024
connections.
The reason for this "low" limit is to
enable unittesting these limits automatically
for the default configure.

There is also a lower-limit (needed by unittests
and internal technical requirements) of 3 connections
and 2 documents.

Change-Id: I6ccf3a607c50bb2a86bf1c0a16ebb6326ee34c7d
Reviewed-on: https://gerrit.libreoffice.org/32712
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-04 04:29:18 +00:00
Ashod Nakashian
a95a40ba5c wsd: break the loop when shutting down WS on reaching limit
Change-Id: Icc2c88d9c506197940cac8ebe14bc7ab8b2c3178
Reviewed-on: https://gerrit.libreoffice.org/32711
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-04 04:23:52 +00:00
Ashod Nakashian
95ff7ba2d7 wsd: don't access erased iterator
Change-Id: I7d9c85b11cd0ea96700c7302c23b5d4b30ce9fa2
Reviewed-on: https://gerrit.libreoffice.org/32710
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-04 04:23:17 +00:00
Tor Lillqvist
f08bb0eed2 There has not been any 'child' message for a while
Was removed in 29e9ba68c3.

Change-Id: I1e351153ff46b83497f203d493f98070ea4358d5
2017-01-03 19:37:31 +02:00
Tor Lillqvist
b01ed94710 Fix std::string::find() anti-pattern
We want to check for exact match here, so just do it.

Change-Id: I12b0efbc8a0c20c38e2308a4af49681d64c94079
2017-01-03 16:01:04 +02:00
Ashod Nakashian
9c35ab156a wsd: exception-safe socket closing
Change-Id: Id51e61195439e100758d63e5e3417e23b0f0fc53
Reviewed-on: https://gerrit.libreoffice.org/32678
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-03 06:01:04 +00:00
Ashod Nakashian
4f90c3e5b9 wsd: simplify ClientSession removal and cleanup
Change-Id: I934f17e978358bef487c5b470cd8cf5d4d747e5d
Reviewed-on: https://gerrit.libreoffice.org/32677
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-03 05:59:39 +00:00
Ashod Nakashian
5cfef7e76b wsd: construct ClientSession under try
In the rare event that it fails, we will
cleanup the DocBrokers correctly.

Change-Id: I6f5346c9ec5021bdadc8a01ed389951ca18d07a3
Reviewed-on: https://gerrit.libreoffice.org/32676
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-03 05:58:53 +00:00
Ashod Nakashian
6b49ef326a wsd: better logging when adding/removing sessions
Change-Id: Ie11886390687c744e1a0f60bff4317898c36f9c2
Reviewed-on: https://gerrit.libreoffice.org/32675
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-03 05:58:16 +00:00
Ashod Nakashian
1cf7a6bca1 wsd: cleanup DocBroker after exceptions
Change-Id: I6a07845506afd5eae482da5d4367eb397846f410
Reviewed-on: https://gerrit.libreoffice.org/32674
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-03 05:57:28 +00:00
Ashod Nakashian
dcdbb0af3f wsd: cleanup logs in getNewChild
Change-Id: Ib5860556d08d162908cd95b5416d7d750d260cbd
Reviewed-on: https://gerrit.libreoffice.org/32673
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-03 05:56:29 +00:00
Ashod Nakashian
fc8d56d70c wsd: refactor DocBroker find or create
Change-Id: Ia5a61ee367de13f1ad7bb62e808067a435d8e926
Reviewed-on: https://gerrit.libreoffice.org/32672
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-03 05:55:00 +00:00
Ashod Nakashian
98b74174e9 wsd: move more boilerplate code from processGetRequest to handleGetRequest
Change-Id: I7ef76c9e1e48aad275db57b2d4b692531abce9ae
Reviewed-on: https://gerrit.libreoffice.org/32671
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-03 05:54:29 +00:00
Ashod Nakashian
4f46af8856 wsd: refactor handleGetRequest into processGetRequest
Change-Id: Ia8a0e390607e6f69d255027baf417fee25c1de74
Reviewed-on: https://gerrit.libreoffice.org/32670
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-03 05:53:37 +00:00
Ashod Nakashian
33b72aa378 wsd: correctly count outstanding spawned children
Change-Id: I6e2d5c7d8fdfbcd268ef97cb1272bce76e8b69de
Reviewed-on: https://gerrit.libreoffice.org/32669
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-03 05:53:14 +00:00
Tor Lillqvist
37135fdeaa Bin outdated comment
Whatever the reason for the extra initial space was, it apparently has
gone away now.

Change-Id: I26fb166df0d0aace3e5e42fdb9cbc2047b74c920
2017-01-02 13:33:07 +02:00
Tor Lillqvist
f94d4c789d 'Handshake' is one word
Change-Id: Ibef905cc42a74052738a71bd4743431e30b863d1
2017-01-02 13:29:09 +02:00
Ashod Nakashian
85102cf76a wsd: log the session name when subscribing for tiles
Change-Id: I478834bdd7e91eaa64b224a56c8344cb0ef9f82a
Reviewed-on: https://gerrit.libreoffice.org/32632
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-02 06:17:44 +00:00
Ashod Nakashian
aebfccd2ca wsd: force forking children when none is outstanding
Change-Id: I06f9063ddf32f9296e5e523454b19e8b5692c285
Reviewed-on: https://gerrit.libreoffice.org/32630
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-02 06:16:43 +00:00
Ashod Nakashian
28db46a59c wsd: always update the last save time to detect failures
When saving we need to differentiate between no-op
and failure. The lastSaveTime must always be updated
when saving didn't fail (i.e. no modification or saved).

Change-Id: I0e2455afac22c82f0b623f9441fbc0bca8a7cb83
Reviewed-on: https://gerrit.libreoffice.org/32629
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-02 06:16:25 +00:00
Ashod Nakashian
228eb98f4c wsd: move rebalanceChildren and avoid declaration
Change-Id: Ie8e7e1e28f5496cf5376622cb8f24696e45cb5fc
Reviewed-on: https://gerrit.libreoffice.org/32628
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-02 06:15:13 +00:00
Ashod Nakashian
65d2036d63 wsd: use chrono instead of time_t
While time_t is much simpler, it's too
opaque. The new chrono library is type-safe
and does conversion correctly, as well as
guarantees monotonity and other desirable
properties.

Change-Id: Id41c44c397a31d73e894e8f1715ff18f2b67df53
Reviewed-on: https://gerrit.libreoffice.org/32627
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-02 06:14:51 +00:00
Ashod Nakashian
a4868edb41 wsd: merge idle document killing with document cleanup
Since we already enumerate the DocumentBrokers and
remove dead ones before every autosave (every 30 seconds)
as well as when loading/unloading documents, there
is little reason to have a separate timeout and loop
for idle documents.

In addition, the previous code only killed the child
but didn't remove the dead DocumentBroker entry from
DocBrokers. Not clear if this was intentional, but it
would have been removed on the next cleanup anyway.

Change-Id: Ie1e09c77133165dd1255930b0b0be06fde7646b1
Reviewed-on: https://gerrit.libreoffice.org/32626
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-02 06:13:20 +00:00
Ashod Nakashian
9b99f64772 wsd: don't sleep after autosaving or spawning children
Between waits on forkit we shouldn't spend too much time.
This is to recover from forkit crashes.

Now we first spawn children, and only when not successful
(i.e. no more spare children needed) we check for autosave
and DocBrokers cleanup. Only when none of the above is done
do we sleep.

This gives the best balance between forkit waits and reduces
the unittests by a good 25 seconds (crash tests down from 34s
to about 10s only).

Change-Id: If69284746859bc78d14f1c6eda07aef4e006709e
Reviewed-on: https://gerrit.libreoffice.org/32624
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-02 06:12:14 +00:00
Ashod Nakashian
d716428f71 wsd: return child forking status
Change-Id: If2504bc8b745c8cf0894a6ccaae7b869e06a8f24
Reviewed-on: https://gerrit.libreoffice.org/32623
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-02 06:10:29 +00:00
Ashod Nakashian
46ef41a687 wsd: force spawning children on startup
Otherwise we throttle spawning to allow
time to fork the process. If we don't wait
we can bomb a loaded server and bring it down.

However during startup this is not necessary
as there are no in-flight spawn requests.

Change-Id: I1beac94571f6d8d96136d32c81310bea6547242b
Reviewed-on: https://gerrit.libreoffice.org/32622
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-02 06:09:54 +00:00