Commit graph

1934 commits

Author SHA1 Message Date
Pranav Kant
e7f75a3e56 loolwsd: Wait for all admin client threads to finish
Otherwise the process could terminate while admin sessions are still
being served.

Change-Id: Id91d0989e264e8294827e8e2ad8dd2d44b6006ec
Reviewed-on: https://gerrit.libreoffice.org/23021
Reviewed-by: Tor Lillqvist <tml@collabora.com>
Tested-by: Tor Lillqvist <tml@collabora.com>
2016-03-08 09:08:16 +00:00
Tor Lillqvist
e8a5ba1b29 _bShutdown is always false 2016-03-08 09:45:23 +02:00
Tor Lillqvist
e7e1ef58ae Cosmetics: Sort and prune #include and 'using' lines 2016-03-08 09:44:04 +02:00
Tor Lillqvist
61ee1ae842 Use std::getenv() instead of Poco::Environment::get()
Much simpler.

Also, don't duplicate the code informing that LD_BIND_NOW or
LOK_VIEW_CALLBACK are not set. Not that I understand why we need to
inform about that? If the "normal" thing should be that they are set,
why don't make it so by default then?
2016-03-08 09:16:01 +02:00
Tor Lillqvist
7d89cfa6f0 Clean up #includes and usings.
Include and use 'using' only for what is actually used. Sort the
include and 'using' lines.
2016-03-07 20:00:35 +02:00
Tor Lillqvist
9947633550 Catch IOException from sendTextFrame() in LOOLSession::disconnect()
Otherwise the uncaught exception will terminate the loolkit process
unexpectedly, which surely messes things up.
2016-03-07 20:00:35 +02:00
Tor Lillqvist
06c6a7e1a6 Try harder to avoid deadlock
I occasionally saw a deadlock when running 'make check' where one
thread holds the ChildProcessSession::Mutex and wants the _mutex for a
Document, while another thread holds that _mutex and wants the
Mutex. In particular, it is the Document::onUnload() that wants the
_mutex. So avoid the deadlock by having Document::onUnload() first
take the ChildProcessSession::Mutex.
2016-03-07 20:00:13 +02:00
Tor Lillqvist
9f67eecadd Improve exception logging
Always try to identify *where* we caught the exception. It is not that
useful to have half a dozen places that all just log "Exception:".
2016-03-07 18:36:01 +02:00
Tor Lillqvist
8fc4f1d95f 10 seconds is a bit short 2016-03-07 17:44:54 +02:00
Tor Lillqvist
d27e798e0f It is not only a 'segfault' that is handled here 2016-03-07 17:44:11 +02:00
Tor Lillqvist
80c6a91d5d Don't call setcap on loolkit before we have built it
On the other hand, loolwsd does not need capabilities any more.

Also update the comment to match reality, and explain in more detail
what is going on.
2016-03-07 13:10:45 +02:00
Tor Lillqvist
e96629b371 It is apparently intended that one uses the mocha built here, not a system one
On many/some distros, the system mocha is a much (?) older version,
which uses a wildly different output format, which is confusing.
2016-03-07 13:04:42 +02:00
Tor Lillqvist
636fafa3b6 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.

If a client session closes just after sending a load message to load a
document, and another session then fairly immediately connects and
sends a load message for the same document, the latter session gets
handled by the same kit process. Also, the same Document object is
apparently used. In that kit process, the first documentLoad() might
easily still be in progress. The handler for the new session still
calls onLoad(), too, and as the first onLoad() had dropped the lock
for the duration of the documentLoad() call, the new onLoad can take
the lock and call documentLoad(), too, while the first documentLoad()
call in the other thread still is in progress. This leads to
interesting problems.
2016-03-07 12:57:18 +02:00
Tor Lillqvist
0194e8d577 Use assert()
It is loolwsd that spawns loolbroker so we control what arguments it
gets, so no need to give verbose errors if our own code is
inconsistent. That is what assert() is for.
2016-03-07 12:57:18 +02:00
Pranav Kant
cd58f2a491 loleaflet: Better design for Admin console JS files
Lets have a new websocket class for each websocket type we want
in admin console inheriting from single abstract base class.

This, hopefully, would provide us with extensibility and ease of
managing files in future. Right now, there is only one class with
very less complexity, hence all the code is in one file.
As the complexity increases, we would need to separate all these
classes in different files, concat and compress them before moving
to dist/

Also rename dashboard.html to admin.html

Change-Id: I34b9b2817fe4a0e6ee2913c017d2694a17ab978c
Reviewed-on: https://gerrit.libreoffice.org/22904
Reviewed-by: Andras Timar <andras.timar@collabora.com>
Tested-by: Andras Timar <andras.timar@collabora.com>
2016-03-07 10:56:59 +00:00
Pranav Kant
1ab3caa192 loleaflet: Make SearchSpec work again
This broke after we changed 'searchAll' to 'highlightAll'.

Change-Id: I257b20a458a9ad3334b5e20fc110d0932eb63733
Reviewed-on: https://gerrit.libreoffice.org/22508
Reviewed-by: Andras Timar <andras.timar@collabora.com>
Tested-by: Andras Timar <andras.timar@collabora.com>
2016-03-07 10:09:07 +00:00
Pranav Kant
a6f9cd430b loleaflet: Wait for 'partpagerectangles' before starting search
This is required because we want to test on which page search is
found, and we can not do it before we get results for
partpagerectangles.

Change-Id: I6f927ae27b91e62d86a8e46dc9c21ee9aa913894
Reviewed-on: https://gerrit.libreoffice.org/22507
Reviewed-by: Andras Timar <andras.timar@collabora.com>
Tested-by: Andras Timar <andras.timar@collabora.com>
2016-03-07 10:07:52 +00:00
Miklos Vajna
0fc711c9a1 loolwsd: fix -Werror=maybe-uninitialized 2016-03-07 09:51:22 +01:00
Miklos Vajna
6ef8312357 loolwsd: fix -Werror,-Wshadow 2016-03-07 09:09:32 +01:00
Pranav Kant
10ba772006 loleaflet: Basic template for Admin console
Work based on bootstrap: http://getbootstrap.com/
License: MIT

Change-Id: I6a114e8dd688339c809ff27d97d0065647700971
Reviewed-on: https://gerrit.libreoffice.org/22824
Reviewed-by: Jan Holesovsky <kendy@collabora.com>
Reviewed-by: Andras Timar <andras.timar@collabora.com>
Tested-by: Andras Timar <andras.timar@collabora.com>
2016-03-04 13:28:01 +00:00
Pranav Kant
ea35385e18 loleaflet: Special handling for Impress docs on state change
State changed event from LOK for impress documents is
prefixed with the template name followed by the style name. Lets
strip the template name for the time being till we support it in
the UI.

Also LOK emits some form of internal names in state change event
which is different from the internal names supplied to us in
intial .uno:StyleApply. For consistency, convert these names to
our original form of internal names.

Change-Id: I95d3d8aa29238fc326887cdfc9b22eb4e429d1bb
Reviewed-on: https://gerrit.libreoffice.org/22814
Reviewed-by: Andras Timar <andras.timar@collabora.com>
Tested-by: Andras Timar <andras.timar@collabora.com>
2016-03-04 13:27:16 +00:00
Pranav Kant
9d7aea26b9 loleaflet: Add programmatic -> UI names mapping to l10n framework
Since the data scraped from the LO translation module is a
mapping between the UI names (not internal ones) to different
languages, the plan is to first set the locale explicitly to
'libreoffice' so that l10n framework gives us corresponding UI
names from programmatic names, and then to use the specified locale to
translate these UI names to respective languages.

Change-Id: I64f7c9b4927e5effe328cb7b42582b45d44167d9
Reviewed-on: https://gerrit.libreoffice.org/22813
Reviewed-by: Andras Timar <andras.timar@collabora.com>
Tested-by: Andras Timar <andras.timar@collabora.com>
2016-03-04 13:26:43 +00:00
Tor Lillqvist
80d9610432 Update from LO master 2016-03-04 12:09:14 +02:00
Tor Lillqvist
6859c85543 Factor out function to get the symbolic name for a LibreOfficeKitCallbackType 2016-03-04 11:49:46 +02:00
Tor Lillqvist
28fd1ace0c Make it clearer in the logging which callback is which 2016-03-04 11:32:25 +02:00
Pranav Kant
87a3b5d3ac loleaflet: Fix JS errors
Change-Id: I9740e0a223c43449ce9f40f91b8c90250d1b7560
2016-03-04 13:17:23 +05:30
Ashod Nakashian
743311af21 loolwsd: added wopi storage manager
Change-Id: Ia28fb3d42c43387432e0b183a1bcf6b0924da820
Reviewed-on: https://gerrit.libreoffice.org/22885
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-03-04 03:06:28 +00:00
Ashod Nakashian
c980ece8bc loolwsd: preparing for wopi storage
Change-Id: Iae1bd042d84603cf81115789df40f50e8dc20d16
Reviewed-on: https://gerrit.libreoffice.org/22884
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-03-04 03:04:43 +00:00
Pranav Kant
ada6a74dc0 loolwsd: Basic layout and interaction with AdminModel
Admin web sessions are added as subscribers to AdminModel. Live
notification fill up the AdminModel, and notifies to
subscribers, if present any. AdminModel can also be queried to
fetch any previous data since the start of the server including
expired documents/views with timestamps for analysis.

There is lot of stuff that can be added in future. This commit
just lays the foundation of appropriate classes.

Change-Id: Ifcf6c2896ef46b33935802e79cd28240fd4f980e
Reviewed-on: https://gerrit.libreoffice.org/22869
Reviewed-by: Tor Lillqvist <tml@collabora.com>
Tested-by: Tor Lillqvist <tml@collabora.com>
2016-03-03 18:30:33 +00:00
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
Pranav Kant
85c6467344 loolwsd: Move Admin class to separate header
As a test, add command to fetch documents from AdminModel.

Change-Id: I3cb7097ba7dde049f3b2478fe7b6b6c309da1d92
Reviewed-on: https://gerrit.libreoffice.org/22781
Reviewed-by: Tor Lillqvist <tml@collabora.com>
Tested-by: Tor Lillqvist <tml@collabora.com>
2016-03-03 18:26:55 +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
Pranav Kant
1908613951 loolwsd: Factor out pipe reading polling logic
Change-Id: I7c06c68031ea14147130d21376ab348bdc672a7f
Reviewed-on: https://gerrit.libreoffice.org/22820
Reviewed-by: Tor Lillqvist <tml@collabora.com>
Tested-by: Tor Lillqvist <tml@collabora.com>
2016-03-03 16:23:21 +00:00
Tor Lillqvist
3671abf89b Describe what 2fab757462 fixes
I forgot to mention in the commit message of
2fab757462 what error situation the
change fixes... So here goes:

If a client session closes just after sending a load message to load a
document, and another session then fairly immediately connects and
sends a load message for the same document, the latter session gets
handled by the same kit process. Also the same Document object is
apparently used. In that kit process, the documentLoad() can still be
in progress. The handler for the new session still calls onLoad(),
too, and as the onLoad() had dropped the lock for the duration of the
documentLoad() call, the new onLoad gets the lock and calls
documentLoad(), too, while the documentLoad() call in the other thread
still is in progress. This leads to interesting problems.

Actually, now that I think of it, I very much doubt it is sane to have
the same Document object used for several sessions (one or several
already "dead" ones and one "live" one) simultaneously, but at least
the change made the unit test work more reliably.
2016-03-03 17:55:16 +02:00
Tor Lillqvist
69a6167f0e Use better test names 2016-03-03 17:31:13 +02:00
Tor Lillqvist
06f56e646d Test harder 2016-03-03 17:14:15 +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
Jan Holesovsky
2590cd186e loolwsd: LOK_CALLBACK_PARTS_COUNT_CHANGED was removed from the API. 2016-03-03 11:13:34 +01:00
Jan Holesovsky
b442680d90 loolwsd: Update the bundled LOK headers. 2016-03-03 11:08:25 +01:00
Pranav Kant
c5aa122fcb loolwsd: Create notification pipe
... and Admin and AdminModel containing all the required data
that we need to expose to Admin panel.

Admin processor will keep listening to any data on this
notification pipe and update AdminModel accordingly.

Change-Id: I0dd6f07ae60158733c34d17f53a35def70600513
Reviewed-on: https://gerrit.libreoffice.org/22780
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-03-03 03:34:47 +00:00
Tor Lillqvist
d55ba592b4 Log also when the syncChildren() is done
It does quite a lot of work that can produce very many lines of log,
so it is good to be able to quickly find when that is done when
perusing a log file.
2016-03-02 16:51:53 +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
fa0fd3303d Avoid logging \r\n here, too 2016-03-02 14:55:04 +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
73282c50d6 Make preinit the default. Turn off with LOK_NO_PREINIT 2016-03-02 08:26:15 +02:00
Tor Lillqvist
78579b3e57 Don't pretend to support non-Linux here either 2016-03-01 18:30:07 +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
a959e99004 Make declaration of writeFIFO() match definition 2016-03-01 17:17:14 +02:00