Commit graph

366 commits

Author SHA1 Message Date
Jan Holesovsky
25224666a7 Revert "Implement File -> Download As -> Plain text (.txt)."
Actually it is enough to do Ctrl-a Ctrl-c, no need to have a special Download
As -> Plain text.

This reverts commit 1c13d5523f.
2017-05-10 15:01:01 +02:00
Michael Meeks
495d6da532 Reset ownership before executing the socket move.
Change-Id: I98532e59ef9c78a6cc1eb25a5a8535c4e2d9b15d
2017-05-09 13:02:23 +01:00
Michael Meeks
1fc176fb05 Restore some clean exists during requests - avoiding exceptions.
Change-Id: I89bb82f85341fcd87daf34d19f30031d1c6d1366
2017-05-08 13:15:44 +01:00
Ashod Nakashian
3aec6e1227 wsd: build fix due to merge error
Change-Id: Ib1d7ce1b880c71b0b2fd8262a92e7e965211653e
Reviewed-on: https://gerrit.libreoffice.org/37375
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-05-08 05:23:46 +02:00
Ashod Nakashian
7d823787bb wsd: configurable idle document timeout
When a document is idle (no activity from
any views) for this timeout duration, the
document is saved and unloaded to minimize
resource consumption.

Change-Id: If6f09136ae40c7e84180fc8c8adbf6db8396d292
Reviewed-on: https://gerrit.libreoffice.org/37374
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-05-08 05:00:56 +02:00
Ashod Nakashian
9798eafb8c wsd: random jail paths instead of pid
Jail paths are now generate from a PRNG
instead of using the PID of the kit process.

The PRN is converted to base-64 and used
as the directory name where a given
kit is jailed.

Change-Id: I8e4bc35d9ccdfdae0e542ab707c417cd29ad52f3
Reviewed-on: https://gerrit.libreoffice.org/37372
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-05-08 04:59:12 +02:00
Michael Meeks
9e45fb30d7 SocketDisposition: push it down the stack, and cleanup around that.
Dung out overlapping return enumerations. Move more work into 'move'
callbacks at a safer time, etc.

Change-Id: I62ba5a35f12073b7b9c8de4674be9dae519a8aca
2017-05-05 18:37:26 +01:00
Jan Holesovsky
1c13d5523f Implement File -> Download As -> Plain text (.txt).
Change-Id: I446f73a3110312cbaab1ce1053aee854b421e71c
2017-05-05 18:24:23 +02:00
Ashod Nakashian
c31bf89976 wsd: trace file cleanups
Change-Id: I72ccbb9f01d4e27b59d88cca9da05c1472008825
Reviewed-on: https://gerrit.libreoffice.org/37130
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-05-02 06:12:49 +02:00
Michael Meeks
cda55f3a21 Various cleanups & improvements to file-serving.
Use what we read at startup as the complete set of files to serve.
Trace log filenames as we read them.
Simplify and accelerate path related checks via the hash.
Kill leak with get_current_dir_name and use the correct path.
2017-04-27 15:02:16 +01:00
Aditya Dewan
be4ebb9b1f Migrated from deflate to gzip
Change-Id: I64aec9305fe74b6cdcfe15e2f67f9d38cfd6d99a
2017-04-27 15:02:16 +01:00
Michael Meeks
fc8563e778 Add LOOL_DELAY_SOCKET_MS env. var to simulate latency. 2017-04-27 10:13:58 +01:00
Michael Meeks
faf24f7888 SocketDisposition - controls socket movement & lifecyle.
It is important that moving sockets between polls happens in a
safe and readable fashion, this enforces that.
2017-04-25 22:49:08 +01:00
Michael Meeks
c8d1c18cb5 Revert "wsd: correctly remove request from socket buffer"
This reverts commit c851c3e93b.
2017-04-25 22:49:08 +01:00
Ashod Nakashian
8b3a2ed9d7 wsd: reduce included headers
Change-Id: I3107b18b2edae34a76e9f56a5cbd24836b1b57c0
Reviewed-on: https://gerrit.libreoffice.org/36872
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-04-24 06:52:02 +02:00
Ashod Nakashian
c851c3e93b wsd: correctly remove request from socket buffer
POST requests require the full request to be
left in the socket buffer to be parsed in full.
But GET requests, especially WS upgrade, must
have the request cleared from the socket, as
there is more data expected to be read after
the upgrade, which happens by the DocBroker
thread, so clearing the buffer must be done
before the upgrade.

This patch accomodates these two conflicting
cases and refactors the code slightly to
make it more structured and readable.

Change-Id: Ia7357a745a3900f986099ba14af2a0946023018b
Reviewed-on: https://gerrit.libreoffice.org/36873
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-04-24 06:49:33 +02:00
Michael Meeks
8ef8e6737f DelaySocket - disable latency for now. 2017-04-22 18:42:16 +01:00
Michael Meeks
1c7f94045a Initial DelaySocket goodness. 2017-04-22 18:42:16 +01:00
Ashod Nakashian
15e13e58f6 wsd: clear the socket buffer only after processing the request
Because POST requests need to consume the complete
request message, we shouldn't clear the buffer
before handling the POST request.

Change-Id: I53f7b664378dd6614afc6983fdd10d0102b38acf
Reviewed-on: https://gerrit.libreoffice.org/36763
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-04-21 05:54:43 +02:00
Ashod Nakashian
9b3a22aafe wsd: save document upon server shutdown
The server correctly saves all documents
and waits to upload them before exiting.

Change-Id: I04dc9ce588bc0fa39a9deb298d0a5efa61a03f1a
Reviewed-on: https://gerrit.libreoffice.org/36654
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-04-19 07:04:26 +02:00
Ashod Nakashian
9c14446c88 wsd: re-enable a couple more tests that are stable
Change-Id: I01bc96ce7bde7cac10d0b4d023b0d5dd774ed058
Reviewed-on: https://gerrit.libreoffice.org/36602
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-04-17 07:12:16 +02:00
Ashod Nakashian
6023fdc3c7 wsd: take DocBrokers lock before broadcasting diskfull
Change-Id: I4f7cccb1112c17091d1039441af4c84d5d13d059
Reviewed-on: https://gerrit.libreoffice.org/36601
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-04-17 07:09:22 +02:00
Ashod Nakashian
1262378301 wsd: send document unloading error as WS message
Without an explicit WS message, the client
does not get this message and the handler
is not invoked at all.

Change-Id: I71e210a9958965cff35dd4d0f1d99985429b82f4
Reviewed-on: https://gerrit.libreoffice.org/36593
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-04-17 06:49:23 +02:00
Miklos Vajna
4269fbbaa4 wsd: remove unused using declarations in LOOLWSD
Change-Id: Id8a7f94cef0ab34fb7d789adff92b9c822af62c2
2017-04-13 10:31:24 +02:00
Jan Holesovsky
ba3b32aad1 Clean the cache even when the document was not modified.
And rename the option, to match better the existing tile cache setting.

Change-Id: Iea5c2c5628a403dd2dc3e2943cd858f40e2a2ebc
2017-04-12 20:04:30 +02:00
Marco Cecchetti
c651a69485 wsd - implemented an option to clean cache on doc close
Change-Id: I0bdb373efb93546527a168df2ed1c75539e95fe4
2017-04-12 19:00:25 +02:00
Ashod Nakashian
1752dd74d6 wsd: avoid miscounting outstanding child forks
The number of outstanding child forks can
become negative if more children are
spawned than requested.

This prevents such a scenario from
permanently preventing WSD from spawning
new children, which happens when
OutstandingForks is negative.

Change-Id: Ief1e56d7b4a079e097ca2d18bd90a01d935f6b30
Reviewed-on: https://gerrit.libreoffice.org/36437
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-04-12 06:11:05 +02:00
Pranav Kant
1437a060ec security: Implement HTTP Public key pinning
Though this guard the user against MITM attacks, but enabling this also
has the potential to brick your websites. So, do not use it/enable it
without understanding what it actually is.

See: https://developer.mozilla.org/en-US/docs/Web/HTTP/Public_Key_Pinning

Though this should work, but I have not been able to test it because of
Firefox and Chrome's limitation/feature that key validation is not done
when certificate chain terminates at a user-defined trust anchor and I
couldn't find any way to temporarily enable the HPKP key validation for
such CA chains.

Change-Id: I64d4ff82b04c59642fa7b8bac2f8788a03950b28
Reviewed-on: https://gerrit.libreoffice.org/36357
Reviewed-by: pranavk <pranavk@collabora.co.uk>
Tested-by: pranavk <pranavk@collabora.co.uk>
2017-04-10 14:46:24 +02:00
Ashod Nakashian
9a761ffe68 wsd: clear the incoming buffer before upgrading to WS
There was an interesting race when we cleared the
inBuffer after the WS upgrade. Since during the
upgrade we also transfer the socket to the DocBroker,
which has its own poll thread, the DocBroker poll
could trigger a POLLIN event if data comes
while the handler (that is handling the WS upgrad
and transfer to DocBroker) hasn't got to the point
where it clears the inBuffer of the data we just
read (i.e. the HTTP GET request). Even if not
the case, after transfering a socket to another
poll thread the socket buffers should not be
touched.

Here we move the inBuffer clearing to be as soon
as we have successfully parsed the request and
are ready to process it.

Also, we don't clear the full buffer, in case
we had read into the buffer both the requst
and the first message, if the thread was switched
out right after getting the POLLIN but before
reading from the socket, giving enough time to
receive more data and reading it together with
first read (which is the request).

Change-Id: I9888d4c2b70d2e433824818bbe7f69f13742486c
Reviewed-on: https://gerrit.libreoffice.org/36326
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-04-10 06:11:06 +02:00
Ashod Nakashian
bc41ad9bf9 wsd: remove outdated comment and simplify
Change-Id: I47e8b22708ab64ad95aa681407344686e6d4eb9d
Reviewed-on: https://gerrit.libreoffice.org/36325
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-04-10 06:10:30 +02:00
Pranav Kant
61b7112aa7 security: X-Content-Type-Options: nosniff
Don't think it is necessary/useful to have this header at other places.
This is the most important and perhaps the only where presence of this
header is required and seems sensible to prevent potential attacks.

Change-Id: Iad318e4b83264ac83620b86a40a49e7384e4015e
2017-04-09 23:32:06 +05:30
Pranav Kant
49bd32c630 security: CORS: No need for this header
No idea why it was here in the first place, but download requests are
only made from frames with same origin, so there should be no need to
specify such headers which allow anyone (with other origins) to make
download requests to us.

Change-Id: I314a7ad4c6df8664b1d191cb88ae42c4248ff517
2017-04-09 23:32:06 +05:30
Pranav Kant
32dde923f7 security: CORS: No need to allow requests from anywhere
insertfile post requests should be made only from our origin.
Mentioning a '*' against allow-access-allow-origin allows other origins
to be able to make requests to insertfile too provided the attacker
knows the doc key which is not very hard to guess/get.

Change-Id: If98351df48935cfcdc18d6879167c0ac6089796c
2017-04-09 23:32:06 +05:30
Michael Meeks
254de88a58 Clear ownership of socket while it is being transferred.
This addresses a gap between ServerSocket accepting new sockets,
and their being added to their new polls.
2017-04-07 20:59:34 +01:00
Ashod Nakashian
bb12de8035 wsd: lower the max number of test docs and connections
Tests should have sensible limits so they don't
go overboard and fail needlessly causing noise.

Change-Id: Idd556c348cc0e97e38c710fdbf76fe20c76d8f9b
Reviewed-on: https://gerrit.libreoffice.org/36241
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-04-07 04:41:30 +00:00
Michael Meeks
90127ac0e3 Let the DocBroker thread clean itself up and expire.
(cherry picked from commit 2e372b70b32d4e052458547daa229c537442774f)

Change-Id: I5835c83f44ef770fa6ccd2418fc6ca73e17694e4
Reviewed-on: https://gerrit.libreoffice.org/36225
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-04-06 17:53:48 +00:00
Michael Meeks
3d945a5c38 Revert "Don't cleanup DocumentBrokers that still have their thread running."
This reverts commit df8dc43be4.

DocumentBroker::isAlive already checks _threadFinished.
2017-04-06 16:35:55 +01:00
Michael Meeks
df8dc43be4 Don't cleanup DocumentBrokers that still have their thread running.
Plenty of time to do that next time around the cleanup.
We should still, really be doing the majority of the timeout work
inside the DocumentBroker poll itself.
2017-04-06 16:24:54 +01:00
Ashod Nakashian
3d03a0fb5d wsd: accomodate accept_poll shutdown
When shutting down accept_poll from
main, we can't remove sockets or cleanup.
That work needs to be done fro within accept_poll's
thread. This is different from when DocBroker's
poll needs to cleanup its own sockets before
it exists.

So we split the stop and removeSockets so they
can each be called in the proper way.

For accept_poll and others that joinThread
we queue a callback to cleanup before stopping.

Change-Id: If780d6a97ac0fc6da6897f895d5b4dda443f9e73
Reviewed-on: https://gerrit.libreoffice.org/36186
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-04-06 07:01:18 +00:00
Ashod Nakashian
a22118df10 wsd: inhibit thread checks sooner when shutting down
LOOLWSDServer::stop() now removes the accept_poll
socket, which will assertCorrectThread. So we need
to disable checks before it.

Change-Id: I3445610c1c48c2b4c23bcfcbc87e236b36d18c0b
Reviewed-on: https://gerrit.libreoffice.org/36185
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-04-06 06:33:24 +00:00
Michael Meeks
01519eff70 Always cleanup DocBrokers in the PrisonerPoll thread.
This simplifies things, and keeps process management in one thread.
Also - wakeup the DocumentBroker when we want to stop it.

Change-Id: I597ba4b34719fc072a4b4ad3697442b5eebe5784
Reviewed-on: https://gerrit.libreoffice.org/36182
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-04-06 06:16:44 +00:00
Ashod Nakashian
cbe6f0c813 wsd: move prisoner socket in the poll thread
Change-Id: I4097da97d4485d98618604c039a4570efe52bc19
Reviewed-on: https://gerrit.libreoffice.org/36181
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-04-06 06:12:39 +00:00
Michael Meeks
bb4459a288 Give up on doing thread checks during late shutdown.
Change-Id: Icb600e4d734e075bec6c2cf6adbb2afd58c0d98b
Reviewed-on: https://gerrit.libreoffice.org/36180
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-04-06 06:11:35 +00:00
Michael Meeks
737f7111b0 Set thread owner to zero earlier to avoid race.
Stop-gap fix, while we come up with a nice API for transferring
sockets between SocketPolls, and/or detaching them generally.
2017-04-05 21:01:48 +01:00
Michael Meeks
185540bcde Inhibit thread checks for SIGUSR1 handling.
USR1 handling is not thread-safe; we walk the structures and hope.
2017-04-05 17:58:52 +01:00
Jan Holesovsky
cb2b788cc7 assert(isCorrectThread()) -> assertCorrectThread().
assert()'s are no-op in the release builds, but we still want to see threading
problems in the log at least.

Change-Id: Idb02bb018e8f2d628a57ab570249613ad00bcff2
2017-04-05 14:49:30 +02:00
Michael Meeks
4b7dee5652 Remove un-used _stop member, and cleanup redundant code. 2017-04-05 11:57:11 +01:00
Ashod Nakashian
1ad4037dd7 wsd: allow for slow startup of LOK
Change-Id: Idf821f2a3638e76e1a8b169d5672a2059b00491c
Reviewed-on: https://gerrit.libreoffice.org/36118
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-04-05 04:48:00 +00:00
Ashod Nakashian
38f955b5c5 wsd: start DocBroker thread before adding callbacks
And move more into the callback to ensure
thread affinity.

Change-Id: I1d6985716d0d36aa488b65263ecb41f444f77255
Reviewed-on: https://gerrit.libreoffice.org/36115
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-04-05 04:46:22 +00:00
Ashod Nakashian
2576f9c4e9 wsd: correctly search for available prisoner port
Search for the next 100 ports for a usable one
and pass the one found to forkit so it connects
on that one instead of the default.

Change-Id: I26697dd8b5a35992f9e000a35ad5b44c3a3699dd
Reviewed-on: https://gerrit.libreoffice.org/36114
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-04-05 04:45:49 +00:00
Ashod Nakashian
e848996247 wsd: simplify career span timing
Change-Id: I0bfb3bca99f3f20ca9244e580c80801e89890fc2
Reviewed-on: https://gerrit.libreoffice.org/36113
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-04-05 04:45:23 +00:00
Ashod Nakashian
e0d6ab7835 wsd: stop poll threads before joining
Also add symmetric stopPrisoners to
match startPrisoners to LOOLWSDServer.

Change-Id: I78d76d86a8e7efc0964cd06df2340658c1b6c4ba
Reviewed-on: https://gerrit.libreoffice.org/36111
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-04-05 04:43:22 +00:00
Ashod Nakashian
cbd78484ad wsd: warn when waking dead poll
And insert sockets after starting the
thread so we poll the socket immediately.

Change-Id: Id336e1838f2f624ebfe59c4c2caf33eaa1a638c9
Reviewed-on: https://gerrit.libreoffice.org/36110
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-04-05 04:41:23 +00:00
Ashod Nakashian
4a5c71c13c wsd: move socket to DocBroker in callback
Change-Id: I23af97788d64268a822700ab16d63b970795a105
Reviewed-on: https://gerrit.libreoffice.org/36059
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-04-04 04:29:56 +00:00
Ashod Nakashian
26ac978266 wsd: don't close invalid forkit pipe
Change-Id: Ib66df894560ad592a7e90774897cb82b573dc77d
Reviewed-on: https://gerrit.libreoffice.org/36056
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-04-04 04:17:38 +00:00
Michael Meeks
94022e90d9 Join threads to force a reasonably sensible shutdown sequence.
ie. actually wait until documents are saved and sessions closed.
2017-04-03 15:21:30 +01:00
Jan Holesovsky
a9389687a4 Don't try to clean up after a runtime error.
We don't know in what state we are...

Change-Id: I8d144000ba684ca23ff67977959c95b31de34367
2017-04-03 11:39:09 +02:00
Ashod Nakashian
c81db87235 wsd: do child housekeeping on finishing DocBroker thread
Change-Id: I109737b79759986cb2a1cbfc6d711ee2f19ff59d
Reviewed-on: https://gerrit.libreoffice.org/36034
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-04-03 05:15:37 +00:00
Ashod Nakashian
d6577654bd wsd: initialization and logging
Change-Id: Icd82a966b94875a65ddb3817c88a3c4c7bedd4ff
Reviewed-on: https://gerrit.libreoffice.org/36030
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-04-03 05:13:14 +00:00
Ashod Nakashian
63ab3bcfa4 wsd: remove queueSession and simplify session loading
Change-Id: Ia03a4ed64b743da8fa7e27de853623126698b9c0
Reviewed-on: https://gerrit.libreoffice.org/36016
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-04-02 04:47:51 +00:00
Michael Meeks
68bbd40bdc UnitTimeout: repair unit test timeout fidelity. 2017-03-31 16:00:32 +01:00
Michael Meeks
ca24df225e Prefork children correctly on start, rather than after a delay. 2017-03-31 15:47:50 +01:00
Andras Timar
ec5fb2a794 add missing default config values
Change-Id: Ic7829c8f97f43bf8f4f2ba4eccdbdf1da89665e4
2017-03-31 07:51:43 +02:00
Michael Meeks
a2398fc367 Improve debugging information. 2017-03-30 21:59:05 +01:00
Michael Meeks
eab89a0e70 Fix unit test delay time check. 2017-03-30 21:59:05 +01:00
Michael Meeks
913c469aa8 Cleanup whitespace, return is not a function. 2017-03-30 17:34:52 +01:00
Ashod Nakashian
7d3f5c0d2b wsd: terminate DocBrokers asynchronously
Remove locks and replace with isCorrectThread
assertions instead.

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

Change-Id: I9ac3e21854447d19a8e6106487dfd8be00fcf5ef
2017-03-30 02:19:24 -04:00
Ashod Nakashian
00f8232652 wsd: simplify getNewChild
Change-Id: Id939025fabdcd81ee3ab5ba3ae6c4ed446944a2a
2017-03-30 02:19:24 -04:00
Ashod Nakashian
2fa34440c5 wsd: handlePostRequest no longer blocks
Change-Id: Id5054ce3b8d5937154493959b1e71e1a0c7387bc
2017-03-29 23:55:19 -04:00
Ashod Nakashian
d77ede8954 wsd: consistent naming sendFrame -> sendMessage
Change-Id: I06c6bb42392a8982a8bb232eee33ece4c8dfc451
2017-03-29 20:03:01 -04:00
Ashod Nakashian
fbf3b87626 wsd: simplify and cleanup session creation
Change-Id: I8cc05bc7a8dc89c6a521b81c6d59ff1e9968763a
Reviewed-on: https://gerrit.libreoffice.org/35789
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-03-28 05:15:28 +00:00
Ashod Nakashian
1a6f6e9a65 wsd: trigger child and doc housekeeping upon terminating kit
Change-Id: I7ffbadb40221c19b24fd172d1b9aabcaa8c581e5
Reviewed-on: https://gerrit.libreoffice.org/35787
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-03-28 05:14:22 +00:00
Michael Meeks
e26079eecb tdf#106797 - avoid locking up / crashing on exceptions from main. 2017-03-27 20:15:30 +01:00
Miklos Vajna
c1e8fc5334 wsd: fix libstdc++-4.8 build
error: no viable conversion from returned value of type 'bool' to
function return type 'std::shared_ptr<DocumentBroker>'

Change-Id: I5d4215ce61e5327ab702dbf6e4cc7be1330afed2
2017-03-27 09:18:36 +02:00
Ashod Nakashian
f2f0040275 wsd: use isCorrectThread
Change-Id: Id63c30b19489d590b995e0ea66ef2f44e8cddfb7
Reviewed-on: https://gerrit.libreoffice.org/35738
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-03-27 03:20:43 +00:00
Ashod Nakashian
5ae94cc7ec wsd: onConnect takes shared_ptr and better logging
Change-Id: I175dfa1f28444b9bb1f612242ee44b6d0507272c
Reviewed-on: https://gerrit.libreoffice.org/35737
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-03-27 03:20:22 +00:00
Ashod Nakashian
2a049cf60f wsd: kill unused code
Change-Id: I09fb52f0455e45e7217b290d5355019e14b9dbc1
Reviewed-on: https://gerrit.libreoffice.org/35736
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-03-27 03:19:35 +00:00
Ashod Nakashian
1c5896f302 wsd: count connections symmetrically
ClientSession::onDisconnect might not always be
called. The disymmetry between incrementing in
the ctor and decrementing in onDisconnect always
ran the risk of mismatch and leaking connection
counts, eventually blocking new clients.

Change-Id: I39ec65016984c0cddd0e16cfbf201049ced53713
Reviewed-on: https://gerrit.libreoffice.org/35713
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-03-26 05:12:12 +00:00
Ashod Nakashian
25dee367d4 wsd: load the convert-to doc in callback
Since this a fake session that doesn't
have a client socket, we push the
messages directly into the ClientSession.
But since the DocBroker poll thread will
probably not be ready by then, there
is no child process and the other
document bits needed to load (or indeed
process any client messages).

So we defer all the fake messages in
a poll callback to insure they are done
in the correct order.

Change-Id: Id81dc4288b305829149e6e9c81d0f7da719c59ad
Reviewed-on: https://gerrit.libreoffice.org/35712
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-03-26 05:11:30 +00:00
Ashod Nakashian
e9e36ba848 wsd: reduce main poll timeout to recover child processes faster
Change-Id: Ic5c43df9df7d50e101a8ed3c84ed12a113da1f2b
Reviewed-on: https://gerrit.libreoffice.org/35711
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-03-26 05:10:59 +00:00
Ashod Nakashian
c3e67575a7 wsd: reject the client's connection when destroying the doc in question
Change-Id: Ieb437c9a35af6e809a08e5835aabb18db3934040
Reviewed-on: https://gerrit.libreoffice.org/35710
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-03-26 05:10:33 +00:00
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
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
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
9381d4134f Unify and simplify timeout and poll events setup.
Both happen at the same time, and need support from the
SocketHandlerInterface.

Rename hasQueuedWrites to getPollEvents and merge updateTimeout.
2017-03-17 22:00:28 +00:00
Ashod Nakashian
5aedff2422 wsd: convert-to functional again
Change-Id: Ibfdec5e898ccb7f851a09fb3fb5eae85ca20f482
Reviewed-on: https://gerrit.libreoffice.org/35307
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-03-17 04:05:19 +00:00
Ashod Nakashian
f9664bb369 wsd: send recylcing message to clients on shutdown
Change-Id: Ibeb37b801e388fa33671a3c7df564c8ed86d9b71
Reviewed-on: https://gerrit.libreoffice.org/35306
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-03-17 04:04:46 +00:00
Michael Meeks
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