Commit graph

118 commits

Author SHA1 Message Date
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
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
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
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
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
Miklos Vajna
836af6724f wsd: fix -Werror,-Wunused-function
Change-Id: I957440a2ac78f89d2f74aad66813b1ef56b5b532
2017-02-08 08:29:10 +01: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
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
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
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
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
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
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
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
Miklos Vajna
0026f580a3 wsd: clean up redundant .c_str() call
Change-Id: I83e6160dec6cdbd8b621e1b783c9ea51be6b9125
2017-01-18 10:39: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
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
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
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