Commit graph

126 commits

Author SHA1 Message Date
Pranav Kant
c1ca746f66 loolwsd: Make notify pipe accessible from child processes
Change-Id: Id91a38c2997cfb359aff0a42d000e9659653598b
Reviewed-on: https://gerrit.libreoffice.org/22830
Reviewed-by: Tor Lillqvist <tml@collabora.com>
Tested-by: Tor Lillqvist <tml@collabora.com>
2016-03-03 18:28:40 +00:00
Tor Lillqvist
2103fe2515 Revert "We use a recursive mutex, so no need to drop and re-take around documentLoad()"
Turns out the callbacks from documentLoad() are in general done on
another thread, not necessarily the same one that did the
documentLoad() call. Not sure why it happened to be the same thread
for me, but oh well. Need to fix the problem described in
3671abf89b in some other way then.

This reverts commit 2fab757462.
2016-03-03 18:37:23 +02:00
Tor Lillqvist
2fab757462 We use a recursive mutex, so no need to drop and re-take around documentLoad()
The callbacks from documentLoad() are made in the same thread.

Sure, as such it is not a good thing to use recursive mutexes. If we
switch back to non-recursive mutexes, we will have to stop taking the
lock in callbacks from documentLoad(), i.e. make sure we know those
functions aren't used elsewhere, in places where a lock would be
needed. Or something.
2016-03-03 17:14:15 +02:00
Tor Lillqvist
bf63df227b The payload can be null
It is always null at least for LOK_CALLBACK_STATUS_INDICATOR_FINISH.
2016-03-02 16:41:49 +02:00
Tor Lillqvist
38ddcf5243 Don't log the CR LF at the end of a response 2016-03-02 13:12:27 +02:00
Tor Lillqvist
02913dcbfc Use std:: consistently for cstdlib functions 2016-03-02 08:47:13 +02:00
Tor Lillqvist
d5292541bd Revert "Also chown the random devices to root:root and chmod to 666"
Not needed after all. It was a red herring. The device files work fine
even if not owned by root:root and with mode 664. The actual problem
was that I used a file system mounted with nodev when testing loolwsd.

This reverts commit 509314d559
2016-03-01 18:24:55 +02:00
Tor Lillqvist
4f701d5d84 Avoid aligning equal signs on sequential lines in a few arbitrary places
If we would use such style, we would need to do it consistently.
2016-03-01 17:28:47 +02:00
Tor Lillqvist
ec33f7b96a Don't use pre-increment when there is no need
We are not interested in the variable being assigned an incremented
value. Its value is not used any more. We are just interested in the
value of the variable plus one. Using pre-increment gives the wrong
impression.

Sure, this is nit-picking.
2016-03-01 15:53:35 +02:00
Tor Lillqvist
673b08bb81 We know that there is a = in the arg as we found a string that includes it
No need to to test again whether it is found. Also, std::strchr()
works fine.
2016-03-01 15:50:39 +02:00
Tor Lillqvist
f8aad3d31f Use the std:: versions of C standard library functions
As mentioned in the coding style part of README.
2016-03-01 15:44:22 +02:00
Miklos Vajna
f46a43b5f5 loolwsd: fix -Werror,-Wunused-parameter 2016-03-01 09:53:37 +01:00
Tor Lillqvist
9d655cbcc0 Don't pretend this will work on anything except Linux 2016-02-29 14:25:12 +02:00
Tor Lillqvist
509314d559 Also chown the random devices to root:root and chmod to 666
Otherwise they won't work. Not that I know whether this helps
anything, really. At least the NSS crypto initialization still takes a
long time.
2016-02-29 12:15:22 +02:00
Tor Lillqvist
ab3169ecdc Add some more Log::info() calls
We want to be able to see exactly when document loading and password
management is done and how long it takes.
2016-02-25 16:43:51 +02:00
Tor Lillqvist
32dc0a3c87 Don't ever attempt to handle the payload of CLOSE frames 2016-02-23 20:03:52 +02:00
Miklos Vajna
7552fcd806 loolwsd: work around -Werror,-Wunused-private-field 2016-02-23 09:35:46 +01:00
Tor Lillqvist
00e3d6ca20 Cosmetics: add a space 2016-02-22 17:09:59 +02:00
Tor Lillqvist
b4387a535a Bin some superfluous using declarations and includes, and actually use others
Sorry, could not resist. Obviously not very important.

In retrospect, maybe it would have been better to have as policy to
*not* use any 'using Poco::Foo'. Now there is an inconsistent mix of
writing out the complete type and using a 'using'. Plus copy-pasted
long lists of 'usings'. And of course, one should never have 'using'
in an include file. Oh well.
2016-02-22 11:37:47 +02:00
Henry Castro
730ec99194 loolwsd: ensure lokit process exited successfully after close the document and views 2016-02-21 08:10:30 -04:00
Henry Castro
b646fca95d loolwsd: add lokit iddle maintenance time out 2016-02-21 08:02:31 -04:00
Pranav Kant
f729156806 loolwsd: Fix misplaced break statement
Probably due to merge conflicts, it ended up in a wrong place.

Change-Id: Ia32e18149d99e901ceaa47a4e984f9ca818d0619
2016-02-21 14:08:00 +05:30
Pranav Kant
b71ebb8dfc loolwsd: Ask for password for multiple views also
This is possible by moving all the password handling logic to
Document container class. When a user opens a password protected
document the first time, it saves all possible data such as
password, password type etc. Upon opening the same document
again, password is matched with the cached password saved in the
document container class before allowing the new view access to
this document.

Change-Id: Id1f2b6e06de806564bf865e83fed51b01c9a0fbc
Reviewed-on: https://gerrit.libreoffice.org/22208
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-02-19 22:00:46 +00:00
Pranav Kant
631ae0f11f loolwsd: Get the first *live* connection
Sometimes there are situations when `connection` map is filled
with dead sessions. We don't want to deal with those dead ones.

Change-Id: I00dda77c39b5adbba69421eace0be0159e02505c
Reviewed-on: https://gerrit.libreoffice.org/22207
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-02-19 21:57:10 +00:00
Pranav Kant
10db02c208 loolwsd: Move document related callback logic to Document class
There are 5 LOK callbacks currently that are triggered on LOKit,
and not on LOKitDocument. These include status indicators, and
document password callbacks during document load. Lets move all
the callbacks called during document load in the Document container
itself, and keep the callbacks called after document load in the
Child session.

Change-Id: I8e43c2baaa12023b34822954dd494780ee6dd7ca
Reviewed-on: https://gerrit.libreoffice.org/22206
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-02-19 21:56:50 +00:00
Pranav Kant
7ecde23422 loolwsd: Remove superfluous registration of callback
Our DocumentCallback is smart enough which checks all the
running connections, and send the callback notification to all of
them. Registering the callback only during the first loadDocument
call should be enough.

Change-Id: I82bcb9525814dae14def3bfb6c088337d0d0ea3c
Reviewed-on: https://gerrit.libreoffice.org/22202
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-02-19 21:55:50 +00:00
Pranav Kant
3667bef9a6 loolwsd: Handle password protected documents
Change-Id: Iceb5bb598ef1517bf640994c27bad4ca36bd72c1
Reviewed-on: https://gerrit.libreoffice.org/21894
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-02-19 21:49:45 +00:00
Tor Lillqvist
7a97e1a1bc Remove pointless duplicated information from a log line
The log lines automatically have information telling which process
they come from.
2016-02-18 18:37:02 +02:00
Henry Castro
10070b11a9 loolwsd: fixes coding style naming convention in LOOLKit.cpp 2016-02-18 12:22:30 -04:00
Henry Castro
76f405af98 loolwsd: add Log::info Preinit stage OK 2016-02-17 23:56:30 -04:00
Tor Lillqvist
446035ca69 Make the loTemplate path work inside the chroot, in the preinit case
Create a corresponding symlink inside the chroot.

Now a LOK_PREINIT=1 loolwsd starts up for me successfully. (Note: I
did not say whether it actually works. I don't know yet.)
2016-02-17 15:26:43 +02:00
Henry Castro
45754cc36c loolwsd: remove unused TerminationState 2016-02-14 23:08:59 -04:00
Pranav Kant
93fdcb34c4 loolwsd: Do not unload without a successfull load
A load document operation may fail, for example, when user enters
a wrong password or no password. In such cases ToPrisoner sends a
disconnect to child. Child do not need to take any steps in this
case, such as, decrementing the view counter, because nothing was
loaded.

Change-Id: Ib71f871aa1728c6355563362987800dece1679d3
Reviewed-on: https://gerrit.libreoffice.org/22203
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-02-15 00:31:29 +00:00
Henry Castro
f5c163e6da loolwsd: avoid deadlock with mutex and join 2016-02-14 14:39:02 -04:00
Henry Castro
42abb3b1a7 loolwsd: websocket shutdown receive 2016-02-14 14:32:55 -04:00
Henry Castro
72db8ed63a loolwsd: replace the random jail id for lokit process id 2016-02-13 19:01:03 -04:00
Henry Castro
75b552bf71 loolwsd: create named pipes workspace 2016-02-13 13:22:15 -04:00
Henry Castro
9e3d5c0337 loolwsd: ensure chroot jail every lokit process 2016-02-13 10:15:28 -04:00
Pranav Kant
5a31f99178 loolwsd: Thread name should not be static
... as we can have multiple connections for same document.

Change-Id: Ic213299d6a4ba703f1e27cf252f3a10209f08148
Reviewed-on: https://gerrit.libreoffice.org/22204
Reviewed-by: Henry Castro <hcastro@collabora.com>
Tested-by: Henry Castro <hcastro@collabora.com>
2016-02-08 14:38:02 +00:00
Henry Castro
647d7c7783 loolwsd: first, establish pipe connection 2016-02-02 20:09:26 -04:00
Henry Castro
5fd2be332a loolwsd: use EXIT_SOFTWARE to indicate internal error 2016-02-01 21:53:16 -04:00
Henry Castro
b477f41636 loolwsd: add fatal signals handler 2016-02-01 21:26:19 -04:00
Ashod Nakashian
b596c80e34 loolwsd: simplified child searching
Change-Id: I0d817876f5b83acff69e51c2c64cd6acfa8dc27d
Reviewed-on: https://gerrit.libreoffice.org/21974
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-02-01 05:02:35 +00:00
Miklos Vajna
4b3c5ea8ff loolwsd: doxygenize class comments 2016-01-28 19:16:32 +01:00
Henry Castro
1ff52f2e2c loolwsd: remove unnecessary Poco thread default pool 2016-01-25 11:45:50 -04:00
Ashod Nakashian
65e06c1db7 loolwsd: per ChildProcessSession callback queue and thread
By giving dedicated queue to each session we eliminate
the bottleneck that a slow client will introduce
on every other session on the same document.

Change-Id: I715b80a8cd7bbef1268dc472d0b32e35f3dd6444
Reviewed-on: https://gerrit.libreoffice.org/21763
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-01-24 23:57:54 +00:00
Ashod Nakashian
904bf929f1 loolwsd: throttle traffic for inactive sessions
Sessions that have been inactive for a certain duration,
currently set at 120 seconds, will not receive updates.

A new statistics class tracks the activity of every
session and blocks callback updates from reaching
inactive clients.

Change-Id: I64296488b2c0be0598b218ba89a6d02f057a5f7e
Reviewed-on: https://gerrit.libreoffice.org/21760
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-01-24 21:14:57 +00:00
Ashod Nakashian
55f2105f00 loolwsd: logging improvements
Change-Id: I77844a2b549c1f497c2d44f054169bf11d9227d8
Reviewed-on: https://gerrit.libreoffice.org/21752
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-01-24 21:00:34 +00:00
Ashod Nakashian
4dc9fa7eb7 loolwsd: prevent deadlock when purging sessions
Change-Id: I293e28674ed721741fa0afc57b37a636833d2e0e
Reviewed-on: https://gerrit.libreoffice.org/21750
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-01-24 20:58:09 +00:00
Ashod Nakashian
dd374d8aec loolwsd: disconnect command to gracefully shutdown a socket
Change-Id: I8beb4c14fc95bdb2a98c7e5da44408511bce5e28
Reviewed-on: https://gerrit.libreoffice.org/21683
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-01-21 16:05:55 +00:00