Commit graph

262 commits

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

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

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

Change-Id: I14f61f389b114f2cda1f97e5223b31fa2f01b06c
2017-01-26 11:49:29 +01:00
Ashod Nakashian
6fe933b466 wsd: take lock to forward messages to clients
Change-Id: I15888e4a5c35511c21f1e2d2bdd25ecbb16e80b9
Reviewed-on: https://gerrit.libreoffice.org/33568
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-26 02:13:23 +00:00
Ashod Nakashian
b8edc135a7 wsd: use Message object to handle responses back to clients
Change-Id: I5ddb32bbd7290c27308199f40f0ed286a869eafd
Reviewed-on: https://gerrit.libreoffice.org/33441
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-26 02:12:39 +00:00
Ashod Nakashian
f73a17c759 wsd: use Message objects to handle kit responses
Change-Id: Ifc9c53ead8d87e9aebfd8c60442a726de5270cc5
Reviewed-on: https://gerrit.libreoffice.org/33440
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-26 02:12:00 +00:00
Ashod Nakashian
acc029a411 wsd: autodetect message type
Change-Id: I0f3ab61867ea067f24050acb15660fa93fc7bbb5
Reviewed-on: https://gerrit.libreoffice.org/33437
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-26 02:08:23 +00:00
Ashod Nakashian
664f602555 wsd: cleanup ClientSession
Change-Id: Ia5d138ed7baf4c26982e93157d82e332cd049a60
Reviewed-on: https://gerrit.libreoffice.org/33435
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-23 05:57:28 +00:00
Ashod Nakashian
c789fe901b wsd: kill PrisonerSession
Change-Id: I7041f79038c377b107b46285278b70236b87f6ac
Reviewed-on: https://gerrit.libreoffice.org/33434
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-23 05:55:33 +00:00
Ashod Nakashian
e584a51443 wsd: merge PrisonerSession into ClientSession
Change-Id: I8ae924a7afae61b9c6e25e15ace187918d1e006b
Reviewed-on: https://gerrit.libreoffice.org/33433
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-23 05:54:28 +00:00
Ashod Nakashian
c7e2a4cc88 wsd: move headless check in enqueue function
Change-Id: I2a09d2c5e5c1705e5caeb8563babcd939384a583
Reviewed-on: https://gerrit.libreoffice.org/33432
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-23 05:54:15 +00:00
Ashod Nakashian
1f3d9ee457 wsd: ClientSession now encapsulates PrisonerSession
No need to expose PrisonerSession via ClientSession
when the marshalling of messages can be done by
ClientSession directly.

PrisonerSession can now be removed altogether.

Change-Id: I131e41f5d9ae50be7244fb92a6f391a757502111
Reviewed-on: https://gerrit.libreoffice.org/33431
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-23 05:53:36 +00:00
Ashod Nakashian
8c34244285 wsd: forwardToPeer now takes pre-constructed Message
Change-Id: I58acbeb6d27fbc9b99434c2743f69a4faa3a048b
Reviewed-on: https://gerrit.libreoffice.org/33430
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-23 05:53:11 +00:00
Ashod Nakashian
bb4733b6d6 wsd: Message::abbrevation -> abbr
Change-Id: If8cab421808689ba4f5ba6a75a960d6b64755b4b
Reviewed-on: https://gerrit.libreoffice.org/33429
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-23 05:48:15 +00:00
Ashod Nakashian
f1de0d0481 wsd: MessagePayload -> Message
Change-Id: Ie65f7c707785dbbf85a2f98abf082fbc3ee7a64b
Reviewed-on: https://gerrit.libreoffice.org/33428
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-23 05:47:03 +00:00
Ashod Nakashian
6b17f96318 wsd: refactor MessagePayload into own file
Change-Id: Ifc0d2abd2e94d4a1b58915664fb0545dca6e96cc
Reviewed-on: https://gerrit.libreoffice.org/33427
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-23 05:45:23 +00:00
Ashod Nakashian
11d7d8c595 wsd: log the fingerprint of WOPI files
Change-Id: I99bd77c2ae892876d82bab64210bd132f34ed364
Reviewed-on: https://gerrit.libreoffice.org/33439
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-23 05:43:38 +00:00
Ashod Nakashian
cb052c98c7 wsd: DocumentBroker cleanup
Change-Id: I7feadf8c6b14b42e88d4f4eb4de29a77235dd953
Reviewed-on: https://gerrit.libreoffice.org/33436
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-23 05:43:12 +00:00
Ashod Nakashian
16eb196820 wsd: each Message object now has a unique ID for logging purposes
Change-Id: I5f3c3afec57f3d9336e0994a1d87421281028d79
Reviewed-on: https://gerrit.libreoffice.org/33426
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-23 05:42:34 +00:00
Ashod Nakashian
b497fcfac5 wsd: close the socket when shutting down fails
Change-Id: Iea5c6a259272b6af881a5bfb27ffc31d2ad27793
Reviewed-on: https://gerrit.libreoffice.org/33424
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-23 05:40:52 +00:00
Ashod Nakashian
f3a85a7bf0 wsd: MessageQueueBase support no empty items
Throw when empty payload is enqueued
and return empty payload on get timeout
(instead of throwing).

Change-Id: Iab5df775caa46d5c212d0850645cda6cca16f20b
Reviewed-on: https://gerrit.libreoffice.org/33421
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-23 04:39:28 +00:00
Ashod Nakashian
25be7f0ab6 wsd: use own tokenizer
Change-Id: Ia6e58767e3a138d086d4e0ae287782d3ed558076
Reviewed-on: https://gerrit.libreoffice.org/33418
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-23 04:37:21 +00:00
Tor Lillqvist
55010980aa Avoid misleading logging
If Poco::Bet::WebSocket::receiveFrame() returns 0 or -1, flags is
likely meaningless.

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

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

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

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

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

Change-Id: Ie2a441a2479db98a54f7fb9b9c8e98cda2f07c1c
Reviewed-on: https://gerrit.libreoffice.org/33128
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-16 02:04:21 +00:00
Ashod Nakashian
bc36241d89 wsd: cosmetics
Change-Id: I250590b105dbfdd6a0589327fece752481253863
Reviewed-on: https://gerrit.libreoffice.org/33127
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-16 01:59:15 +00:00
Ashod Nakashian
05620be4c5 wsd: autosave on disconnecting based on loaded sessions only
When a client disconnects, we autosave only when there
are no other sessions. The idea being that it'd be
wasteful to save on every client disconnect, so long
that we have a later chance of saving.

This doesn't hold, however, when the only other
remaining session is one that had just connected
and hasn't loaded a view yet. WSD wouldn't
know about this, but when unloading the
disconnecting session, Kit will exit the process
as the last view is gone, losing all unsaved changes.

This patch tracks the sessions in WSD that have
loaded a view and takes that into account when
deciding to autosave on disconnect or not, thereby
fixing this corner case that may result in data loss.

Change-Id: I699721f2d710128ed4db65943b9357dff54380f5
Reviewed-on: https://gerrit.libreoffice.org/33126
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-16 01:58:54 +00:00
Ashod Nakashian
a31e606a98 wsd: retry loading DocumentBroker and adding session
In some cases when the last session is destroying
and we expect the DocumentBroker to be removed,
while waiting for autosave, a new client might
connect to the very same document.

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

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

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

Thanks to Kendy for the idea.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Change-Id: I1beac94571f6d8d96136d32c81310bea6547242b
Reviewed-on: https://gerrit.libreoffice.org/32622
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-02 06:09:54 +00:00
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
401c7e54c7 wsd: cleanup document saving logs and include the DocKey
Change-Id: I17100ef2115c1953779fe9dda9568c8ae4d6326e
Reviewed-on: https://gerrit.libreoffice.org/32618
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-02 06:06:52 +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
3844f5934e wsd: use isAlive before sending message to child
Change-Id: Ie463f89226bc0391102a3a4ae700e90cd3993271
Reviewed-on: https://gerrit.libreoffice.org/32612
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-02 06:02:30 +00:00
Ashod Nakashian
f3a90ef77a wsd: always notify threads waiting on save
And check for save-failed first before finding
the session, as otherwise the session is useless.

Change-Id: I3eb45e54872547eb36765b2c8409e1aa51aee589
Reviewed-on: https://gerrit.libreoffice.org/32611
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-02 06:02:04 +00:00
Ashod Nakashian
38bf731a98 wsd: simplify logging during save
Change-Id: Icdd790a555c301e285c9fa3a4eeff87aae2aec3e
Reviewed-on: https://gerrit.libreoffice.org/32610
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-02 06:01:18 +00:00
Ashod Nakashian
df32077005 wsd: read message payload from correct source
Change-Id: I9333b4ecb3aae7c22e93f0b92a3e6eed59bb875f
Reviewed-on: https://gerrit.libreoffice.org/32600
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-02 05:53:31 +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