Commit graph

475 commits

Author SHA1 Message Date
Ashod Nakashian
d11b3a76d9 wsd: move correct-thread assertions
Change-Id: Iba5d58d74720aaf02a372f25148047e79c89c1bd
Reviewed-on: https://gerrit.libreoffice.org/36060
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-04-04 04:30:25 +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
0806986c8c Admin model locking - major cleanup.
Do everything in the Admin Model in the AdminPoll thread.
Everything else can push work there safely through callbacks.
2017-04-03 20:42:31 +01: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
Michael Meeks
3e1351ec79 Correct obsolete method name. 2017-04-03 15:21:17 +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
95d51493aa wsd: remove nextmessage
This was a workaround to Poco's limitation
of requiring socket receiveFrame be given
preallocated buffer, which couldn't be
exceeded by a larger payload. This meant
the receiver had to know the maximum
payload in advance.

Since only the Kit uses Poco sockets,
and the Kit never receives large payloads,
this preamble is now obsolete.

100% (94/94) of old-style tests PASS.

Change-Id: I76776f89497409e5755e335a3e25553e91cf0876
Reviewed-on: https://gerrit.libreoffice.org/36037
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-04-03 05:18:09 +00: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
bd82bf4c4b wsd: set DocBroker poll thread once
Change-Id: Ic6397893b2b9b04c6715c393c3f176785b1e2b77
Reviewed-on: https://gerrit.libreoffice.org/36031
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-04-03 05:13: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
c9365ad679 wsd: log the DocBroker ID in the Kit as well
This matches the document between WSD and kit,
making logs much easier to read.

Change-Id: If55a9eb84b4a22d2dc4dd53f5f6ab322ebc3646e
Reviewed-on: https://gerrit.libreoffice.org/36028
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-04-03 05:11:23 +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
aeb204fb14 Kill race during DocumentBroker shutdown over child process.
==20033== Invalid read of size 4
==20033==    at 0x466504: ChildProcess::close(bool) (DocumentBroker.hpp:111)
==20033==    by 0x44EA28: DocumentBroker::terminateChild(std::string const&, bool) (DocumentBroker.cpp:1313)
==20033==    by 0x45F70E: DocumentBroker::pollThread() (DocumentBroker.cpp:264)
==20033==    by 0x504B2F: SocketPoll::pollingThreadEntry() (Socket.hpp:486)
==20033==    by 0x7310E6F: execute_native_thread_routine (thread.cc:84)
==20033==    by 0x7AF60A3: start_thread (pthread_create.c:309)
==20033==    by 0x7DF002C: clone (clone.S:111)
==20033==  Address 0x0 is not stack'd, malloc'd or (recently) free'd
2017-03-31 17:28:20 +01: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
Pranav Kant
ce1084b74f wsd: Send readonly info to clients
With this every other client would be able to know about other client's
permission i.e whether they have opened the document as readonly. This
could be important eg: to hide the cursor overlay of readonly users in
the UI or to mark these users as readonly in the userlist.

Change-Id: I5dcb1b4e5a22c9b546d16b69b9216cc7653cff04
2017-03-31 12:20:09 +05:30
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
Pranav Kant
1507560e11 tdf#106842: Document DisableCopy mode
Change-Id: I4c9efc5a9a32b4eea8cc751fce418c85d9fa4f35
2017-03-30 18:49:02 +05:30
dewana-dewan
4322045667 tdf#106579 - serving gzipped file content
Change-Id: I320b22babf1bf65a0f1d4b1809a6ffb1f5ec8344
2017-03-30 12:09:12 +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
48ad9a2472 wsd: ClientSession::isLoaded -> isAttached
Since this doesn't necessary mean the document
was loaded completely (as the similarly named
flag in DocumentBroker signifies) rather that
the session was added to DocumentBroker.

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

Change-Id: Ie4d99103b0d49d238152f7da3155ebcb6ccd4e22
2017-03-29 23:55:19 -04:00
Ashod Nakashian
d77ede8954 wsd: consistent naming sendFrame -> sendMessage
Change-Id: I06c6bb42392a8982a8bb232eee33ece4c8dfc451
2017-03-29 20:03:01 -04:00
Ashod Nakashian
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
99844c1c92 wsd: protect DocBrokers session member
It is accessed from the PrisonerPoll
when cleaning up.

Change-Id: Ieb57cdd63cc08632bcdaa4fc5ccd4a1a53c06fe7
Reviewed-on: https://gerrit.libreoffice.org/35788
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-03-28 05:14:41 +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
Ashod Nakashian
0624904500 wsd: flush sockets using timed loops
Change-Id: If6cc6194aa36a770913b777a8f19617fea6ba4a7
Reviewed-on: https://gerrit.libreoffice.org/35786
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-03-28 05:12:36 +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
6d7f39356c wsd: flush sockets before exiting DocBroker poll thread
Change-Id: Id5384c113bd761b5b8c25286f1bd5a28051c63d3
Reviewed-on: https://gerrit.libreoffice.org/35740
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-03-27 03:21:38 +00:00
Ashod Nakashian
fddb86744e wsd: stop DocBroker poll thread when poll is flagged to stop
Change-Id: I1bfc3a4e0a0cc7753d330a009bb295c0fce9efca
Reviewed-on: https://gerrit.libreoffice.org/35739
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-03-27 03:21:04 +00: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
f1c371555a wsd: kill unused headless stuff
Change-Id: Ic4ee7603ecd7acd10e4499457de181342f2d7483
Reviewed-on: https://gerrit.libreoffice.org/35735
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-03-27 03:19:11 +00:00
Ashod Nakashian
5eed6575df wsd: don't pretent there was a recent save on creating DocBroker
Now the poll thread can exit immediately when loading
fails, since we don't think there is an active
saving on going.

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

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

Change-Id: I798166b9e45b5707a33d31137e01a32ce63630b1
Reviewed-on: https://gerrit.libreoffice.org/35705
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-03-26 05:06:22 +00:00
Ashod Nakashian
a190084b43 wsd: log document loading stats only the first time
Since these numbers are against the thread start time,
they aren't useful for loading subsequent views.

Change-Id: Ib5cf580282841e5b2dbb71c7db4a1868f7eb29e1
Reviewed-on: https://gerrit.libreoffice.org/35704
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-03-26 05:05:14 +00:00
Ashod Nakashian
bd00aa4057 wsd: assert isCorrectThread
Change-Id: I90bfa9ba6b47e657db28a3680fa8a13ef2553a6e
Reviewed-on: https://gerrit.libreoffice.org/35703
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-03-26 05:04:54 +00:00
Ashod Nakashian
a57b9e6917 wsd: const correctness
Change-Id: I2bba04ccba9fd97e10ecc56f7db1f62a66a8f5f0
Reviewed-on: https://gerrit.libreoffice.org/35702
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-03-26 05:04:24 +00:00