Commit graph

399 commits

Author SHA1 Message Date
Ashod Nakashian
cd4e8205cf wsd: add getTokenInteger to Message
Change-Id: I2c145aa088082ef056b92c9864b34d8cc2f737cd
Reviewed-on: https://gerrit.libreoffice.org/33861
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-02-03 07:08:16 +00:00
Ashod Nakashian
cd85d8a7f1 wsd: improved protocol helpers
Change-Id: I434fd9d6bb3248a8b9c27bb6c8565369c95786b5
Reviewed-on: https://gerrit.libreoffice.org/33860
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-02-03 07:07:38 +00:00
Ashod Nakashian
c22e69e9e6 wsd: correct logging of thread ID in log entries
Change-Id: I10aaeeea8df2757362482a405b7525542d150178
Reviewed-on: https://gerrit.libreoffice.org/33857
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-02-03 07:05:06 +00:00
Ashod Nakashian
0d4d506ea3 wsd: faster jail directory cleanup
Around 1.5x faster than Poco,
which first enumerates files into
a container, then iterates over
them and stats before unlinking.

Here we enumerate and unlink in
a single pass.

Change-Id: I79d1c0f1b5ec557ccc4f0e2ec7a0609051d8d212
Reviewed-on: https://gerrit.libreoffice.org/33680
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-30 05:10:09 +00:00
Ashod Nakashian
1ba7c0209a wsd: cosmetics
Change-Id: I58a9e579e228d7b4a1e1b5686988aeff8da9922f
Reviewed-on: https://gerrit.libreoffice.org/33674
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-30 02:11:13 +00:00
Jan Holesovsky
9d4eab1aba Re-introduce the TileQueue depth logging.
Change-Id: I025aa9745d1b0a3306930323764957c6d84a0966
2017-01-27 18:32:01 +01:00
Jan Holesovsky
545e2a2abe Fix a size check.
Change-Id: I509d12dcde6f56a2a7a9ee244e721d8028dec501
2017-01-26 11:49:29 +01:00
Jan Holesovsky
c44f7b8a76 Revert "loolwsd: improved MessageQueue"
Now we don't get a situation where there would be a tremendous amount of
invalidates & tile render requests piled in the queue, so we can do it
deterministic again.

The only thing that could potentially pile in the queue are the keypresses
events sent from the clients, but that is a different problem anyway.

This reverts commit c326228774.

Change-Id: I98e199eab0187bf5f47ce322ac1b1b2e3b976b85
2017-01-26 11:49:29 +01:00
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
Jan Holesovsky
f77253f4f8 Deduplicate the .uno: command state changes too.
Change-Id: Iaf9204d39d90cb9289d279e35a4609fa68c2cce8
2017-01-26 11:49:29 +01:00
Jan Holesovsky
1b9e34a3f9 Squash the invalidation messages coming from various view into one.
Change-Id: I65f7e4eb0b82a8c76eef372548ad3298ac70bdd7
2017-01-26 11:49:29 +01:00
Jan Holesovsky
60a3d717cb Remove obsolete cursor positions from the message queue.
Change-Id: Ie54aa4a475f0a55baaf6a40a99ed341c8f941a04
2017-01-26 11:49:29 +01:00
Ashod Nakashian
9fe2d93228 wsd: Message now supports parsing forwarding prefix
Change-Id: I2826a2df5136628b86421afb93e3b95fbc3ba45a
Reviewed-on: https://gerrit.libreoffice.org/33438
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-26 02:10:07 +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
Pranav Kant
8c5028de05 fix build for poco 1.7.5
Change-Id: I9636a7dd63c714bdd375d19af3eec0677c6d47fc
2017-01-23 13:04:03 +05:30
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
27e1428088 wsd: batched user-input processing
User input is batched together to reduce
overheads. This initial implementation
will batch all input of the same type
together.

Change-Id: Ia0069de9cf5acecf637941543267f86518c04640
Reviewed-on: https://gerrit.libreoffice.org/33422
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-23 05:36:48 +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
Ashod Nakashian
ffe092f5ce wsd: log cleanup
Change-Id: I569f7a81fa80686810c4d5aa65e03b02be189db7
Reviewed-on: https://gerrit.libreoffice.org/33417
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-23 04:34:38 +00:00
Ashod Nakashian
b9c900d459 wsd: format the time directly in the log prefix
Change-Id: I6ad5faf8fdfa16831863bf4b8fa0568e88d0d0f8
Reviewed-on: https://gerrit.libreoffice.org/33416
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-23 04:33:09 +00:00
Miklos Vajna
4b980530e5 common: remove unused using declaration
Change-Id: I51d4d1f555ed5508370e4b9a7b8f04f266a2ca4a
2017-01-17 09:58:50 +01:00
Tor Lillqvist
32b92dcd91 Bin default values for parameters that were defaulted at just one call site
Change-Id: I965b0be1ad4f706a06d06d5c6c3f940c1b3cc33c
2017-01-16 14:05:10 +02:00
Tor Lillqvist
79e08f3de2 Drop parameter that always was defaulted anyway
Change-Id: I6eee99db120e8a4aeb0e27586390bdc1bad9e219
2017-01-16 12:59:03 +02: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
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
Jan Holesovsky
4416c836d0 Log the time in wall-clock time, instead of since the process start.
Otherwise we are getting completely confused times - various processes start
at various times, so for one process the epoch start can be eg. 20 minutes
later than for the other.

Change-Id: I6d87e98682a5fcd0348a584cf66f7ffa5813ca66
2017-01-13 16:14:13 +01:00
Tor Lillqvist
b8897ea295 Avoid pointless breaking up of the one same Util namespace in parts
Also, indent the nested rng consistently.

Change-Id: I551c8d0faa78446edf6cad746ca0f9193096f3aa
2017-01-13 14:55:01 +02:00
Tor Lillqvist
11ae90cfcb No Hungarian notation please
Change-Id: Ia624de45a792db7e39f2245aaea7d940b30b0db2
2017-01-13 14:52:08 +02:00
Tor Lillqvist
04bdf8d623 Bin unused code
Change-Id: I71b7a5f8d769e033b489ae5ea0fbd4425db2184e
2017-01-13 14:14:36 +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
Tor Lillqvist
29fc49acf2 Bump the message first line abbreviation limit to 500 characters
If we are logging a message, we want to see the first line of it in
its entirety if possible. Especially now with more parameters being
added to tile messages, 120 was not enough to see the added
interesting ones.

Bin the silly test that used knowledge of what the limit is. We should
not test a coindidental arbitrary number that is not a documented part
of an API. If we want to test the default abbreviation functionality,
we need to at least make that default limit (now 500) public in
Protocol.hpp.

Change-Id: Iea59ba46e8331e2a839c792146f123fed9df2b82
2017-01-11 23:25:21 +02:00
Tor Lillqvist
7d7e5a4bfe Remove assert as this function can also be called with a non-empty output vector
Change-Id: Idff29a5bd298ada7b6d8fe3e76fd2e25d8f25c79
2017-01-11 14:02:40 +02:00
Tor Lillqvist
2eb40ab43c Drop an unneeded (and defaulted) parameter
Change-Id: I788080db53507604accd97dacc2d74e614b80641
2017-01-11 13:44:57 +02:00
Ashod Nakashian
09fe0b689a wsd: templatized MessageQueue
Change-Id: Ieb6b6c289d8348cafc82041e6e719409cc329edd
Reviewed-on: https://gerrit.libreoffice.org/32919
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-10 05:40:37 +00:00
Ashod Nakashian
89bd85fbba wsd: put_time is not supported by gcc4.8
Change-Id: Ib3b6a115ba669051474e327944cb4677575d15f3
Reviewed-on: https://gerrit.libreoffice.org/32917
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-10 05:39:48 +00:00
Ashod Nakashian
fe9e95dfa3 wsd: log the time when initializing the logger
Change-Id: I785c2a6a13dedbecf10a96a593f05e13980ea1e6
Reviewed-on: https://gerrit.libreoffice.org/32863
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-09 06:20:08 +00:00
Ashod Nakashian
4580ed4e27 wsd: prefix the test docs with the test name
This makes debugging much easier as one can
readily match WSD logs with a given test.

Change-Id: I8f2c83d67189038699af3f24dee205bc7efb5c28
Reviewed-on: https://gerrit.libreoffice.org/32860
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-09 06:17:43 +00:00
Tor Lillqvist
c8d3f90e56 Add an assert to make sure assumptions I am about to make will hold
Change-Id: Ifc1eeb61aa345cf177e3c5996ed7bc48f6aeb07c
2017-01-04 17:10:58 +02:00
Tor Lillqvist
ae6f0e3df9 Make it possible to use the LOG_* things as statements
Use the usual do { ... } while (false) idiom. (See
http://stackoverflow.com/questions/4674480/do-whilefalse-pattern for
instance.)

Change-Id: I1fb00c331ab4eab3ebbff1d58a8ed36e59d2646c
2017-01-04 16:48:16 +02:00
Tor Lillqvist
b837f58814 Bin superfluous assert()
Change-Id: Ie50b44e0681e9fd7c33e125476e1aafda1010f34
2017-01-04 14:37:05 +02:00
Tor Lillqvist
a36d4b0fc3 Reanme png namespace to Png for consistency
As far as I see, we tend to use the same namespace name as the
basename of the corresponding include file, and this stuff is defined
in a file called Png.hpp.

Change-Id: Id859e13e94568abd9f1d5b4ef3bfbbb0c156db11
2017-01-04 13:35: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
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
7f08cf5387 wsd: cleanup TileQueue accessing in Kit
Change-Id: I50ff5bea0e0b193baef2abfaa1a866a7e20f9ab8
Reviewed-on: https://gerrit.libreoffice.org/32616
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-02 06:05:45 +00:00
Ashod Nakashian
1a6098b925 wsd: TileQueue should be fully threadsafe
There should be no need to take a lock to
access it. However there were cases where it
wasn't thread-safe. Now we can remove unncessary
locking before invoking it.

Change-Id: I90d2c6940610a59aa6c749491ea85fb80b0acbcd
Reviewed-on: https://gerrit.libreoffice.org/32615
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-02 06:04:18 +00:00
Ashod Nakashian
92bbe0b774 wsd: log bools as text
Change-Id: I0d520671704881bf1aaeb090ce452be74e43fd0c
Reviewed-on: https://gerrit.libreoffice.org/32561
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-01 04:20:15 +00:00
Ashod Nakashian
3a5be2926b wsd: log WS incoming messages only once
Change-Id: Iee31bc649ae2d194b6418367f0e9ab8561099b17
Reviewed-on: https://gerrit.libreoffice.org/32551
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-01 03:55:19 +00:00
Ashod Nakashian
9e677e268f wsd: new LOG_CHECK_RET to log failure and return
This is to replace assertion for non-fatal cases.

Change-Id: I6f8aedea52fb861309d0bc8f8f9cd43395da0805
Reviewed-on: https://gerrit.libreoffice.org/32550
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-01 03:54:51 +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
d6b767b840 loplugin:cstylecast
Change-Id: I5a0524aca89b16ba336d69028faf76cccab22d59
Reviewed-on: https://gerrit.libreoffice.org/32371
Reviewed-by: Tor Lillqvist <tml@collabora.com>
Tested-by: Tor Lillqvist <tml@collabora.com>
2016-12-27 10:46:57 +00:00
Noel Grandin
05f88bf9a5 loplugin:redundantcast
Change-Id: I14945f34d3ab6d3c148b40e95069159bf40bd99e
Reviewed-on: https://gerrit.libreoffice.org/32370
Reviewed-by: Tor Lillqvist <tml@collabora.com>
Tested-by: Tor Lillqvist <tml@collabora.com>
2016-12-27 10:45:42 +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
Tor Lillqvist
6a9e733118 Indentation fix
Change-Id: I7ac537049995356dc33377311ef82e9916dbd98a
2016-12-27 12:35:21 +02:00
Noel Grandin
6c0022fb10 loplugin:staticmethods
Change-Id: Idf9596cfbbd6eef77e6271a1108d64dae864ed27
Reviewed-on: https://gerrit.libreoffice.org/32366
Reviewed-by: Tor Lillqvist <tml@collabora.com>
Tested-by: Tor Lillqvist <tml@collabora.com>
2016-12-27 10:34:20 +00:00
Noel Grandin
f53669cf9d loplugin:unreffun
Change-Id: I06b13a5c035f6ae4dd4b414f49a0987c019feea5
Reviewed-on: https://gerrit.libreoffice.org/32365
Reviewed-by: Tor Lillqvist <tml@collabora.com>
Tested-by: Tor Lillqvist <tml@collabora.com>
2016-12-27 10:26:23 +00:00
Noel Grandin
0caeab803b loplugin:loopvartoosmall
Change-Id: I32f75fac7626b9ae56fa3f898bfa50051a22677f
Reviewed-on: https://gerrit.libreoffice.org/32362
Reviewed-by: Tor Lillqvist <tml@collabora.com>
Tested-by: Tor Lillqvist <tml@collabora.com>
2016-12-27 10:15:38 +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
4ed820d3d5 add a configure option for using clang compiler plugins
and apply the nullptr plugin.

Lots of hacking in my LO tree required to make this work, will probably
end up needing to add an extra parameter to the LO side.

Change-Id: I02ae1dcdece9d9ddf05f7757f6696e3a5d7d1f14
Reviewed-on: https://gerrit.libreoffice.org/32339
Reviewed-by: Tor Lillqvist <tml@collabora.com>
Tested-by: Tor Lillqvist <tml@collabora.com>
2016-12-22 14:23:42 +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
1376856107 wsd: logging updates
Change-Id: Icbee0349a3cfda5a56f8d681c779484e18b98ab6
Reviewed-on: https://gerrit.libreoffice.org/32287
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-12-21 15:01:20 +00:00
Ashod Nakashian
2428a4e3a1 wsd: more Protocol unittests
Change-Id: I72742f767d9dcfcf1edbfaed4fada628ebef156f
Reviewed-on: https://gerrit.libreoffice.org/32159
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-12-19 05:57:03 +00:00
Ashod Nakashian
7e1529af31 loolwsd: add tokenization to MessagePayload
Change-Id: I39135b2ad65da5abce93848a68faffc93906a0c0
Reviewed-on: https://gerrit.libreoffice.org/32157
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-12-19 05:51:49 +00:00
Ashod Nakashian
32271b8d5c loolwsd: string trimming helpers
Change-Id: I5e47f92b624890421bd7022084063cdea77da12b
Reviewed-on: https://gerrit.libreoffice.org/32155
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-12-19 05:46:15 +00:00
Pranav Kant
0e043853ea tdf#104695: Unit test for missing tiles due to low socket buffer size
Change-Id: I278c5d532cb9b6340dee71a4b66410b32a164704
Reviewed-on: https://gerrit.libreoffice.org/32072
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Tested-by: Michael Meeks <michael.meeks@collabora.com>
2016-12-16 10:25:15 +00:00
Tor Lillqvist
0bdac17fa6 Add 'userinactive' to messages that don't indicate user interaction
In fact, it is more or less the opposite;)

Change-Id: I34eca0ed6b7d4ce369ae803eac542f0996d193eb
2016-12-14 18:24:38 +02:00
Ashod Nakashian
4bc318fb88 loolwsd: LOG_CHECK to replace assertion when logging suffices
Change-Id: I077c6394579f432c0aa9da053d20ccb9c6d31907
Reviewed-on: https://gerrit.libreoffice.org/31934
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-12-13 04:37:05 +00:00
Ashod Nakashian
6b8ed0dac6 loolwsd: handle socket error and close better
If the socket is in error, SELECT_READ returns
immediatly as failure. In this case we sit
in a tight loop polling read over and over.
We now check for SELECT_ERROR when SElECT_READ
fails to properly close the socket and break.

When receiveFrame returns -1, we should first
check the flags for socket close, as that
is a legitimate case of returning -ve.

Change-Id: I7bbc948638a8395d28990ba92eddb9a1a9f1e6f2
Reviewed-on: https://gerrit.libreoffice.org/31932
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-12-13 04:35:50 +00:00
Ashod Nakashian
477ca6f414 loolwsd: cleanup the Sessions
Change-Id: I3cd065ab84e17f943fa7de7e094db574ff6fde07
Reviewed-on: https://gerrit.libreoffice.org/31931
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-12-13 04:35:00 +00:00
Ashod Nakashian
e60bc28a00 loolwsd: LOOLSession -> Session
Change-Id: I94369480fb0a6789375dfe5610ada300e94b80eb
Reviewed-on: https://gerrit.libreoffice.org/31930
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-12-13 04:34:19 +00:00
Ashod Nakashian
d8c8737597 loolwsd: move forwardToPeer into PrisonerSession
Change-Id: I771af0ea066d3d7cb16173861ae70dcc052122aa
Reviewed-on: https://gerrit.libreoffice.org/31888
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-12-12 05:25:51 +00:00
Ashod Nakashian
0b42af6d8d loolwsd: move SenderQueue to wsd
Change-Id: I33af4d1b2bbf0305cbc5fa6f05266d126f1bb803
Reviewed-on: https://gerrit.libreoffice.org/31884
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-12-12 05:20:43 +00:00
Ashod Nakashian
233cb94eff loolwsd: SenderQueue to hold messages to send to clients
This adds SenderQueue and a wrapper of messages to
send back to clients.

Currently no threading takes place, but the messages
are pumped through the queue nonetheless.

Change-Id: Id9997539c0a2a351cbf406f649c268dd3643e88e
Reviewed-on: https://gerrit.libreoffice.org/31883
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-12-12 05:19:04 +00:00
Michael Meeks
7cf77c26f7 Improved fuzzer - to fuzz input.
Pass --unitlib=test/.libs/unit-fuzz.so to loolwsd to enable.
2016-12-08 14:53:01 +00:00
Miklos Vajna
6a08b44433 Png: avoid multiplication at int precision, then converting to long
Change-Id: Id05d1db07ae7e8978b2a6b989b6366ae66d0e9de
2016-12-05 11:56:46 +01:00
Michael Meeks
67fcc2f99c Turn termination off for Unit tests. 2016-12-03 23:02:29 +00:00
Tor Lillqvist
7451a48511 Handle return value -1 from our LOOLWebSocket::receiveFrame()
It doesn't mean anything is wrong or that the connection would be in
some invalid or closed state, but just that we didn't actually receive
any "interesting" frame that could be handled in the caller.
2016-12-02 17:01:38 +02:00
Tor Lillqvist
2a307c3ef3 Show also the contents of PING and PONG frames in getAbbreviatedFrameDump() 2016-12-02 16:52:48 +02:00
Miklos Vajna
dd1dbaa737 common: clean up redundant initializers for members
Change-Id: I7ee177acdc2521bc5b2d9fd0b0d3fa4947d6f2e2
2016-12-02 08:16:40 +01:00
Miklos Vajna
721003512e IoUtil: avoid multiplying at int precision, then comparing to long
Here:

if (payload.capacity() > READ_BUFFER_SIZE * 4)

Change-Id: I12e090d03b471b7394a4898d5e1a74992182051e
2016-12-01 18:15:58 +01:00
Ashod Nakashian
c326228774 loolwsd: improved MessageQueue
Tiles no longer hog the queue ahead of all else.

We now give priority to callback events, so clients
get to know the document state sooner.

Since tiles take long to render, an equal time
is given to non-tiles (capped at 100ms).

Finally, Impress preview tiles are given
the lowest priority and rendered only when
the queue is drained.

Change-Id: I922c1e11200e5675f50d86b83baee1588cbbf66f
Reviewed-on: https://gerrit.libreoffice.org/31394
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-11-30 04:42:40 +00:00
Ashod Nakashian
7a4250b90e loolwsd: terminate forkit when wsd dies
When we the pipe with wsd is closed we
assume wsd has died and we terminate too.

WSD can fork us anew, if it's still alive.

Change-Id: I669ed717db973b50498a6bc08e1fca59c6563443
Reviewed-on: https://gerrit.libreoffice.org/31337
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-11-29 02:42:46 +00:00
Ashod Nakashian
21b1287444 Revert "IoUtil: remove never read write of 'n'"
Setting 'n = -1;' helps to detect where the failure happened
when receiveFrame throws. At the bottom of the function we log
partially processed data by checking n (among others).

This reverts commit 752372a2b0.

Change-Id: I3294329c3d95b38d72c3fc824ab2eb7f2339adee
Reviewed-on: https://gerrit.libreoffice.org/31339
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-11-29 02:42:10 +00:00
Jan Holesovsky
e15ec1d33b These constants are not needed any more.
Change-Id: I5e73d4eacdf5e88f11bc3755162fe601a65417fe
2016-11-28 11:33:20 +01:00
Miklos Vajna
752372a2b0 IoUtil: remove never read write of 'n'
Change-Id: I2dfd85696b39ae1f1c7bbc33cec544bc04f980ac
2016-11-28 09:11:11 +01:00
Ashod Nakashian
2239f25684 Renamed 'shutdown' to 'shuttingdown'
Change-Id: Idae53a59af13eb54b1f18f1a8cd1dde06421b426
Reviewed-on: https://gerrit.libreoffice.org/31295
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-11-28 05:03:54 +00:00
Ashod Nakashian
b35725ab70 loolwsd: support more efficient full-buffer hashing
Change-Id: Ie30929ad4665b51e280c1126adde645742814dad
Reviewed-on: https://gerrit.libreoffice.org/31294
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-11-28 05:03:17 +00:00
Ashod Nakashian
47fa3b1b10 loolwsd: use a better hash function for png caching
We need a fast and good (high avalanche properties)
hash function for the png caching to avoid collissions
(even in the very limited samples we have, since tiles
are likely to have patters, such as all 0's and all 1's
etc.).

Bob Jenkins's public domain SpookyV2 is used here.
It has great avalanache properties and is fast at
~3-bytes / cycle for large messages.

Only trailing whitespace was removed from original
sources and 4 tabs converted to spaces.

Change-Id: Ife57237321625c836d85c894d939fd04a8f577bb
Reviewed-on: https://gerrit.libreoffice.org/31292
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-11-28 05:00:37 +00:00
Ashod Nakashian
f4dd9c1e11 loolwsd: use vector instead of deque for MessageQueue
Change-Id: I879d248e54748916b30c64874ddc237fb662ac11
Reviewed-on: https://gerrit.libreoffice.org/31289
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-11-28 04:57:10 +00:00
Ashod Nakashian
b16fb68ec6 loolwsd: shrink SocketProcessor buffer when too large
When receiving large messages the dynamic socket buffer
is resized to accomodate the incoming large message.

This buffer was previously never reduced in size.
This is an obvious leak that is now avoided.

When the buffer grows beyond quadruple the default
size, it is shrunk back to the default. This gives
a decent balance between memory waste and unnecessary
resizing up and down after each large message received.

Change-Id: Ic3996c80e96592af6f12c4abd1dd737bdc07b814
Reviewed-on: https://gerrit.libreoffice.org/31287
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-11-28 04:56:11 +00:00
Ashod Nakashian
6ab32e0aa9 loolwsd: use larger threshold to large messages
Messages larger than a certain size are preambled
with a 'nextmessage' message that hold the size
of the subsequent message.

This is a workaround to a limitation the Poco
WebSocket API where if the buffer size is
smaller than the received frame the socket
ends up in a bad state and must be closed.
Unfortunately the new API that avoids this
workaround is not yet released by Poco.

Here we minimize the need for 'nextmessage'
to truely large messages. The limit is now
raised from above 1KB to over 63KB.

We may raise this limit further, but that will
cost each socket that much dedicated buffer size.

Change-Id: I01e4c68cdbe67e413c04a9725152224a87ab8267
Reviewed-on: https://gerrit.libreoffice.org/31286
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-11-28 04:54:37 +00:00
Ashod Nakashian
a8f3263132 loolwsd: use more efficient matchPrefix
Change-Id: I6f34b314295335270ff4da2827517d818c6a62ab
Reviewed-on: https://gerrit.libreoffice.org/31285
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-11-28 04:53:04 +00:00
Ashod Nakashian
86b38a29de loolwsd: fast in-place getTokenStringFromMessage
Change-Id: I5a7a7402c9394ac72aca907fc8b1072f6d2df5ad
Reviewed-on: https://gerrit.libreoffice.org/31284
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-11-28 04:50:57 +00:00
Michael Meeks
85583f0a89 Avoid PNG compression for un-changed tiles. 2016-11-25 15:48:56 +00:00
Michael Meeks
c1a398977f Adapt makefiles, includes etc. to new locations. 2016-11-25 09:58:57 +00:00
Michael Meeks
cca657c8f2 Apply the pre-branch rename script to re-organize the source. 2016-11-25 09:58:48 +00:00