Commit graph

545 commits

Author SHA1 Message Date
Henry Castro
e684089c89 loolwsd: force websocket close if client does not want to close
Even if sever send a close frame, the client could still send
more messages, but no close frame.
2016-10-03 14:36:02 -04:00
Pranav Kant
3fa2115fa1 loolwsd: security: Cleanup HTTP download request
Sanitize for some funny inputs.

Change-Id: I450cb5ed6e03e9809308e8f763af2c2a66fcecb0
2016-10-03 11:16:32 +05:30
Pranav Kant
700a310d35 loolwsd: Fix incorrect log messsage
This can be a POST request too.

Change-Id: I673fb94fc8a4b0cc09ed166f04dbad94ca2a041a
2016-10-03 11:16:32 +05:30
Henry Castro
2a6a5eab2e loolwsd: error message is localizable 2016-10-01 11:35:19 -04:00
Tor Lillqvist
5b08fe6477 Add handling of dangerously low storage space for local files
Sends the same 'error: cmd=internal kind=diskfull' message as when
disk space for LOOL's own needs is getting full, but only to the
user(s) of that document. We can't in general know whether one
document in the Storage abstraction is located even close to another.
2016-09-30 16:12:16 +03:00
Tor Lillqvist
9511bbda71 Re-factor Util::checkDiskSpace() into separate parts
We will later want to just to a disk space check for the file system a
file is on, without registering that file system for periodic checks.

Adapt callers to keep working like before.
2016-09-30 13:54:51 +03:00
Henry Castro
6f7d67a204 loolwsd: control frames must have a payload of 125 bytes 2016-09-29 17:36:43 -04:00
Pranav Kant
d5f8c5b2e6 Change main websocket url for consistency with other urls
From
/lool/ws/docurl
to
/lool/docurl/ws

The main purpose behind changing this and other related urls is
to help in load-balancing. The first two parts of the URL can now
be used in a hash-based load-balancing algorithm which decides which
slave gets to serve the requests. Requests such as insertfile,
downloadas need to end up in the same slave in which document was opened.
/lool/docurl/ i.e first two parts of the URL are constant for all
the requests that should be served by a single slave.

Change-Id: Ibc605ca1251957b8b32b376cf19b78f6178fadfa
2016-09-30 00:50:57 +05:30
Pranav Kant
8330341a8a Include docurl in document download requests
From
/lool/jailid/randomdir/filename
to
/lool/docurl/jailid/randomdir/filename

Change-Id: I4d58e733768c62f2951ecfdcfcb604d99772862d
2016-09-30 00:33:58 +05:30
Pranav Kant
8c61ee3c94 Change insertfile URI to include doc key in it
From
/lool/insertfile
to
/lool/<docUrl>/insertfile

Change-Id: I63864673bc1d92a737a95b484c2f440cb5ce6605
2016-09-30 00:33:58 +05:30
Tor Lillqvist
86bd8426d0 More work on disk space monitoring
Monitor the disk space on important file systems: The ones where
cached tiles are stored and where the chroot jails are created. Those
might be the same file system of course, the code checks and doesn't
do needless work.

The check is done whenever a new loolkit process is taken into use and
a new chroot jail it constructed, and whenever a new client session
connects to a document. We don't check more often than once a minute,
though.

Still need to add code to guard against running out of diska space
when saving documents back to where they were opened from. For that
presumably need to enhance the Storage abstraction.
2016-09-29 17:54:40 +03:00
Henry Castro
7a1d02a7ce loolwsd: MAX_CONNECTIONS, should send HTTP status code
It is not necessary to throw a WebSocketException
2016-09-28 18:12:01 -04:00
Tor Lillqvist
96e6ad7502 Re-think disk full handling
Instead of trying to inform the sysadmin (which we did not yet try to
do in any meaningful way), inform all connected clients (even those
editing other documents).

We use 'error: cmd=internal kind=diskfull' as the message to the
clients. The loleaflet code needs to be updated to handle that
carefully by displaying a very prominent message that tells the user
that all bets are off.

Also add a unit test for the functionality.

Document the new protocol details.

The code for this alert functionalty became a bit less elegant than I
like because of the way we include Util.cpp in the unit test 'test'
program.

Still need to add code to check for disk full in more places, not just
when saving a cached tile or font. Probably we should even actually
check for disk space on the file system(s) we use getting alarmingly
low, not just check for file writing operations that fail. Later.
2016-09-29 00:23:14 +03:00
Henry Castro
0729a38277 loolwsd: restore MAX_CONNECTIONS
Let's do another unit test with http request connections
2016-09-28 17:03:36 -04:00
Henry Castro
fe2004a06f loolwsd: rework bccu#2022, User warning on hitting limit 2016-09-28 16:01:53 -04:00
Jan Holesovsky
0409243683 Log either to file or the console, not to both.
Change-Id: Iac1e74d0624c2bbac4ffaf99b11488f02e626a2a
2016-09-27 14:36:39 +02:00
Jan Holesovsky
0467f84a6f Actually move the check for tty where we check for various envvars etc.
Change-Id: Ib05208770f9e1865fd322302b861108f351607da
2016-09-27 14:34:41 +02:00
Tor Lillqvist
db1733e70d We don't need to check LOOL_NO_LOGCOLOR any more
Since 429cc9d49b, we use colour only
when stderr is going to a terminal.
2016-09-27 12:38:43 +03:00
Miklos Vajna
2076bc54ff LOOLWSD: remove unused using decl
Change-Id: Ia3dbbb83a65485da67bede1e70a1fded2a1ade25
2016-09-22 09:12:26 +02:00
Ashod Nakashian
b8317e7b34 loolwsd: lokit process logs to file if configured
Pass the log-to-file config to the kit processes
using envars.

Change-Id: Ida79c35ab02d8038685153805be780359bfbe97e
Reviewed-on: https://gerrit.libreoffice.org/29161
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-09-22 03:33:26 +00:00
Ashod Nakashian
e7272019dc loolwsd: remove tile queue and simplify tile response
Tile queue was used to process canceltiles commands.
Since those are handled by TileCache, there is no need
for queues and the threads that pump them.

But because these queues were also used to buffer between
WSD internals and clients, such that a slow client wouldn't
block WSD while sending back tiles, it is necessary
to reword that logic.
In subsequent commits that will change as well.

With this change not only do we save a thread per client,
but we also reduce latency of tile, and improve typing
responsiveness, by almost 3x or more! Latencies are
down to ~15ms from almost 50ms.

Reviewed-on: https://gerrit.libreoffice.org/28575
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
(cherry picked from commit 59eaacd2f8)

Change-Id: I77813267a95a724491165792ec020ae00953c05e
Reviewed-on: https://gerrit.libreoffice.org/29066
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-09-20 03:30:43 +00:00
Ashod Nakashian
53ba8a1307 loolwsd: use std sleep_for rather than POSIX or Poco
Change-Id: Icce28f2ee61035534431bb8b5d7df93b00ad2fc3
Reviewed-on: https://gerrit.libreoffice.org/29062
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-09-20 03:23:00 +00:00
Ashod Nakashian
f0c09238ce loolwsd: fail fast rather than catch all
Change-Id: Ib38924bf823315d211eb467d90f364fdc225ba2e
Reviewed-on: https://gerrit.libreoffice.org/29005
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-09-19 11:59:23 +00:00
Jan Holesovsky
a6f70aad79 bccu#2005 follow-up: Another place where we need the dummy document broker.
I think this is another potential race condition...
2016-09-15 17:48:01 +02:00
Jan Holesovsky
10392f9ba6 Decrease the level of indentation. 2016-09-15 17:22:28 +02:00
Jan Holesovsky
d1e0b978d6 bccu#2005 follow-up: If the document appearead in the meantime, finish early. 2016-09-15 16:36:29 +02:00
Jan Holesovsky
27bed804d5 bccu#2005: Make sure we don't create 2 jails for the same document.
When 2 users opened the document at the very same time, it happened that new
jails / instances were created for the document twice.

As a solution, insert a dummy (marked to destroy) document into the map of
DocumentBrokers, which will lead into synchronization between the two
instances.

[I suppose the synchronization did not work previously either, as emplace()
does not seem to modify the value when the key is already in the map.]
2016-09-15 12:50:26 +02:00
Jan Holesovsky
e41e107500 Fix --disable-ssl case. 2016-09-01 16:24:35 +02:00
Ashod Nakashian
77a693c353 Revert "loolwsd: remove tile queue and simplify tile response"
This reverts commit 59eaacd2f8.

Change-Id: Ieba9bbaaa6406e3e685b46ce12a44a0766127815
Reviewed-on: https://gerrit.libreoffice.org/28594
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-09-01 12:37:38 +00:00
Ashod Nakashian
9b3343aad4 loolwsd: Don't block on client sockets and timeout in 1 second
Change-Id: I7fec1054cef25704f898a7a5211abfb398d61bee
Reviewed-on: https://gerrit.libreoffice.org/28576
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-09-01 04:00:17 +00:00
Ashod Nakashian
59eaacd2f8 loolwsd: remove tile queue and simplify tile response
Tile queue was used to process canceltiles commands.
Since those are handled by TileCache, there is no need
for queues and the threads that pump them.

But because these queues were also used to buffer between
WSD internals and clients, such that a slow client wouldn't
block WSD while sending back tiles, it is necessary
to reword that logic.
In subsequent commits that will change as well.

With this change not only do we save a thread per client,
but we also reduce latency of tile, and improve typing
responsiveness, by almost 3x or more! Latencies are
down to ~15ms from almost 50ms.

Change-Id: I9bb5856efed28caea9d4e6f94f77b093779e5241
Reviewed-on: https://gerrit.libreoffice.org/28575
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-09-01 03:59:31 +00:00
Michael Meeks
f56d96229d Avoid profiling CL devices during jail setup. 2016-08-31 22:05:02 +01:00
Tor Lillqvist
b57ddcd173 Sort #includes of C++ headers 2016-08-31 17:02:29 +03:00
Tor Lillqvist
a5e5d3cdf6 Introduce LOOL_NO_LOGCOLOR to enable turning off the annoying colours again 2016-08-31 16:59:43 +03:00
Ashod Nakashian
a674fc7e8f loolwsd: logs and formatting
Change-Id: Ic3ec268cdc1962814654c7be676da62375494f66
Reviewed-on: https://gerrit.libreoffice.org/28524
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-08-31 04:41:31 +00:00
Pranav Kant
67444eeb80 loolwsd: Pass sessions' usernames to core
Change-Id: I8c81c02fafd2cb9d0048729401e082bb422e299b
Reviewed-on: https://gerrit.libreoffice.org/28481
Reviewed-by: pranavk <pranavk@collabora.co.uk>
Tested-by: pranavk <pranavk@collabora.co.uk>
2016-08-30 07:45:37 +00:00
Miklos Vajna
e4bbc15132 Avoid inclusion of deprecated C++ headers
Change-Id: I29abf3feeb8419f4e15ccb8dc7c34c086696ce07
2016-08-30 09:06:47 +02:00
Pranav Kant
f8ebb54af0 loolwsd: Receive WOPI userid, username
Change-Id: I0bd5e5a155b8f8486fbeffb1c1413d5e9c177fc3
2016-08-29 19:39:50 +05:30
Andras Timar
274d68644d loolwsd: handle HTTP HEAD request for / 2016-08-28 23:06:30 +02:00
Andras Timar
b0619d387b loolwsd: add support of SSL termination 2016-08-28 23:06:30 +02:00
Andras Timar
a5aa138774 loolwsd: response to HTTP GET / (e.g. for checking if server is alive) 2016-08-26 13:40:20 +02:00
Andras Timar
619ddb4c2f loolwsd: add favicon 2016-08-26 12:57:33 +02:00
Ashod Nakashian
76ad9b3451 loolwsd: cleanup of LOOLSession
Change-Id: Ib65e65c44b258c7ae4d4fbe68555f664900d21c9
Reviewed-on: https://gerrit.libreoffice.org/28305
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-08-22 05:48:00 +00:00
Ashod Nakashian
716b28f4de loolwsd: forward declare TraceFileWriter and move out of header
Change-Id: Id1be0eec0d8a3e9963f986b05ad5426ddb6866c4
Reviewed-on: https://gerrit.libreoffice.org/28288
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-08-22 04:24:22 +00:00
Andras Timar
6380deb5a8 loolwsd: disable command trace when it's missing in config file 2016-08-16 11:24:22 +02:00
Ashod Nakashian
08909b2a3d loolwsd: doxygen comments added to all classes
Change-Id: Ia485c2dcec20a6840d46836a61f75a8e7e8762ed
Reviewed-on: https://gerrit.libreoffice.org/28128
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-08-15 03:12:31 +00:00
Henry Castro
c7bef135c5 loolwsd: fix -Werror=shadow 2016-08-13 08:59:14 -04:00
Miklos Vajna
7eaa2bfc87 loolwsd: fix -Werror,-Wparentheses-equality 2016-08-09 09:14:28 +02:00
Ashod Nakashian
0c91e33133 loolwsd: logging to file support
Change-Id: Ie18c6d7c3563078becb9d42e81ef3b6a14288e98
Reviewed-on: https://gerrit.libreoffice.org/27976
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-08-08 03:58:08 +00:00
Ashod Nakashian
807b3c2e55 loolstress: support trace file compression
Compression to .gz is supported and is controlled
via the XML configuration.

Change-Id: If26fad2c0b5f3c4ffd93362608644dc917172a41
Reviewed-on: https://gerrit.libreoffice.org/27975
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-08-08 03:57:35 +00:00