Commit graph

366 commits

Author SHA1 Message Date
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
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
909b5f8ac3 Admin: should be its own socket-poll goodness. 2017-03-15 16:13:13 +00:00
Michael Meeks
d9980e3392 Adjust initial AdminRequestHandler entry point. 2017-03-15 14:40:24 +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
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
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
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
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
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
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
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
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
7b1ed1b4d4 nb: more informative logging of socket activity
Change-Id: I9036c778c195936678c6451ba57cc794d6ba0006
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
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
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
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
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
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
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
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
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
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
f94d4c789d 'Handshake' is one word
Change-Id: Ibef905cc42a74052738a71bd4743431e30b863d1
2017-01-02 13:29:09 +02: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
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
Ashod Nakashian
e55be929b0 wsd: reuse rebalanceChildren in getNewChild
Change-Id: Ib5e2750e3b3f49c649c2d14fb5016e427b535912
Reviewed-on: https://gerrit.libreoffice.org/32621
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-02 06:08:47 +00:00
Ashod Nakashian
78f3a4d9b9 wsd: refactor and reuse child forking
Change-Id: Ie5e5966896a728edf032c046bda65c7c9553c27c
Reviewed-on: https://gerrit.libreoffice.org/32620
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-02 06:08:21 +00:00
Ashod Nakashian
fb1e8eb63a wsd: flag for shutdown when we fail to create forkit
And say 'forkit' in the logs where we recognize it
instead of the generic 'child'.

Change-Id: I7628b064bb6330db145a948640e48b727def3270
Reviewed-on: https://gerrit.libreoffice.org/32619
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-02 06:07:45 +00:00
Ashod Nakashian
d67437735f wsd: cleanup all DocBrokers when one is removed
Change-Id: I1010093185e117f50f56d96e73d0771c52113d90
Reviewed-on: https://gerrit.libreoffice.org/32614
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-02 06:03:11 +00:00
Ashod Nakashian
15a6c02f70 wsd: remove DocumentBroker instances without sessions
Change-Id: I052acba594f0da76332996b25c5349e8fff23606
Reviewed-on: https://gerrit.libreoffice.org/32613
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-02 06:02:49 +00:00
Ashod Nakashian
62371e5f41 wsd: log failure in else and not unconditionally
Change-Id: I24f1ac57f350aa67cc14682d695e1e4a07453c8d
Reviewed-on: https://gerrit.libreoffice.org/32562
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-01 04:20:40 +00:00
Ashod Nakashian
759564368d wsd: reorganize DocBrokers lookup
Avoid unnecessary code under lock
or when DocBrokers is updated,
which requires removal on exception.

Change-Id: Id01aed42cd66616b910b7e16a8a1ed6c1d1e74b9
Reviewed-on: https://gerrit.libreoffice.org/32558
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-01 04:18:22 +00:00
Ashod Nakashian
e4a0402924 wsd: improved logging of DocBrokers and NewChildren activity
And improved some comments.

Change-Id: I00605e7471e4f6354d3ff62e1e3873f7e5a7986d
Reviewed-on: https://gerrit.libreoffice.org/32557
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-01 03:59:15 +00:00
Ashod Nakashian
8481e9c21d wsd: improved logging of child process management
Change-Id: Iaa1f333e3fe427219f244f913834a46a80377032
Reviewed-on: https://gerrit.libreoffice.org/32549
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-12-31 23:23:04 +00:00
Ashod Nakashian
ba9ffb4775 wsd: include cleanup
Change-Id: Id481cfbab6be12a095918bdc7318fb3584345307
Reviewed-on: https://gerrit.libreoffice.org/32548
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-12-31 23:22:15 +00:00
Noel Grandin
08ce0ed2da loplugin:simplifybool
Change-Id: If2de633684eeef572b5fe0a2b675f221f513e3f7
Reviewed-on: https://gerrit.libreoffice.org/32369
Reviewed-by: Tor Lillqvist <tml@collabora.com>
Tested-by: Tor Lillqvist <tml@collabora.com>
2016-12-27 10:44:22 +00:00
Noel Grandin
0bb8ba8307 loplugin:staticaccess
Change-Id: I1abd6c2a28d3a8e4fb0cda2d35be94d787ff67b7
Reviewed-on: https://gerrit.libreoffice.org/32368
Reviewed-by: Tor Lillqvist <tml@collabora.com>
Tested-by: Tor Lillqvist <tml@collabora.com>
2016-12-27 10:43:34 +00:00
Noel Grandin
98c236f9bb loplugin:staticanonymous
Change-Id: I2adf6be69967c163dd6dabbc35e9777589133956
Reviewed-on: https://gerrit.libreoffice.org/32367
Reviewed-by: Tor Lillqvist <tml@collabora.com>
Tested-by: Tor Lillqvist <tml@collabora.com>
2016-12-27 10:42:36 +00:00
Noel Grandin
d425157f53 loplugin:literaltoboolconversion
Change-Id: Ic38256273a8cad001fff6a3d7148a9b272acfa50
Reviewed-on: https://gerrit.libreoffice.org/32361
Reviewed-by: Tor Lillqvist <tml@collabora.com>
Tested-by: Tor Lillqvist <tml@collabora.com>
2016-12-27 10:14:31 +00:00
Noel Grandin
80b0eaa773 loplugin:unnecessaryoverride
Change-Id: Ib077de07e832ae30137f465596961731954d8e62
Reviewed-on: https://gerrit.libreoffice.org/32340
Reviewed-by: Tor Lillqvist <tml@collabora.com>
Tested-by: Tor Lillqvist <tml@collabora.com>
2016-12-22 14:41:10 +00:00
Noel Grandin
4199efc91c convert enums to scoped
Change-Id: Ic3d4c09dbcec28b4638bb8888f812f970f40a1c5
Reviewed-on: https://gerrit.libreoffice.org/32331
Reviewed-by: Tor Lillqvist <tml@collabora.com>
Tested-by: Tor Lillqvist <tml@collabora.com>
2016-12-22 09:51:56 +00:00
Ashod Nakashian
70bbc53d86 wsd: don't reuse DocBrokers iterator to insert
Simplifies the code and makes it less error prone.

Also add more logging on modifying DocBrokers.

Change-Id: I861495912eb4994a32b1ccaccc181fb1aad26e1f
Reviewed-on: https://gerrit.libreoffice.org/32295
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-12-21 15:40:45 +00:00
Pranav Kant
39dd5018e2 browser console logging depending on loleaflet_logging prop.
loleaflet_logging defaults to true with compiled with
--enable-debug otherwise false.

Browser will print additional debug info when this property is
set to true.

Change-Id: Id9fabf134bd8d19fa1a09ca8c0987df46d4f1a4c
2016-12-15 16:52:07 +05:30