Commit graph

2724 commits

Author SHA1 Message Date
Jan Holesovsky
72a5f35f30 LibreOfficeKit.hpp changed meaning of getPart(), update accordingly.
Change-Id: Ia346f4f838856040fa9aea26b3ac9c0b596b9218
2016-11-15 13:06:42 +01:00
Jan Holesovsky
2069650ba6 Get rid of LibreOfficeKit.hpp, it's mostly a copy of LibreOfficeKit.hxx.
Change-Id: I55f9c28a3ac1ef2a36c18c29cc16209bedd48770
2016-11-15 13:06:34 +01:00
Henry Castro
4ea95ff330 loolwsd: add parameter char to render font 2016-11-15 00:07:21 -04:00
Henry Castro
b7d3ea63ff loolwsd: update bundled headers 2016-11-15 00:07:21 -04:00
Ashod Nakashian
8072576424 loolwsd: move signal and process code to SigUtil files
Change-Id: I91c001ef54858d942f8e3fe56d8a6b02cb2bf37e
Reviewed-on: https://gerrit.libreoffice.org/30846
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-11-14 21:20:21 +00:00
Ashod Nakashian
b5dd13c57f loolwsd: wait for kit processes only when killing them
Change-Id: I89ec8c728b53ff1acdf9e8d12137ffc7c13f6ba5
Reviewed-on: https://gerrit.libreoffice.org/30845
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-11-14 21:19:00 +00:00
Ashod Nakashian
01a6274d7c loolwsd: support forced termination in kits as well
Change-Id: I301cf2f36888b7095f8565bc0badcfc5a927518c
Reviewed-on: https://gerrit.libreoffice.org/30844
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-11-14 14:00:15 +00:00
Ashod Nakashian
303d173ae1 loolwsd: gracefully shutdown on first CTRL+C then force termination on second
Change-Id: I1c84663d10de8ece715a296eec284b74cdda69df
Reviewed-on: https://gerrit.libreoffice.org/30834
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-11-14 05:37:06 +00:00
Ashod Nakashian
d36306e347 loolwsd: broadcast that the server is shutting down
Change-Id: Ib94eb991763094cd6fe0ab36636f48f9844586c5
Reviewed-on: https://gerrit.libreoffice.org/30833
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-11-14 05:35:37 +00:00
Ashod Nakashian
d02f677fff loolwsd: support shutdown admin command
Change-Id: Ib87ad2c289d59734c7a7a12e821de89e61c05079
Reviewed-on: https://gerrit.libreoffice.org/30831
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-11-14 05:33:15 +00:00
Ashod Nakashian
853135decd loolwsd: SocketProcessor can be named and name used in logs
Change-Id: I599b6f7308690b49a0e9ed3c23b88dbcb2ed8848
Reviewed-on: https://gerrit.libreoffice.org/30830
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-11-14 05:32:46 +00:00
Ashod Nakashian
03a0347c14 loolwsd: don't make noise on spurious errors while testing
Change-Id: I6ab24367fddc8ab49843289af9bfc2241dc6005f
Reviewed-on: https://gerrit.libreoffice.org/30829
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-11-14 05:31:59 +00:00
Ashod Nakashian
18fd7b7f75 loolwsd: SocketProcessor cleanup
Change-Id: I120574dce169e1e8149aeba9d982b8235fa034fb
Reviewed-on: https://gerrit.libreoffice.org/30828
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-11-14 05:31:45 +00:00
Ashod Nakashian
92ca5225a5 loolwsd: logs and consistent formatting
Change-Id: If32bb829b125678c6e8f83c39a3812098f3b38a3
Reviewed-on: https://gerrit.libreoffice.org/30827
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-11-14 05:30:47 +00:00
Ashod Nakashian
47d040f345 loolwsd: handle SIGINT in WSD only
CONTROL-C is now handled by WSD only to
have full control over server shutting down.

Also set signal handlers first thing to trap
any early failures.

Change-Id: Ifc5c93b9dd2aef288eed0ed36c600a639dbc6a44
Reviewed-on: https://gerrit.libreoffice.org/30826
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-11-14 05:30:07 +00:00
Ashod Nakashian
6ad3b64d30 loolwsd: kill children using SIGTERM from via a helper function
Change-Id: I901183fc59725681208a5c0f23f0916e158e5654
Reviewed-on: https://gerrit.libreoffice.org/30825
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-11-14 05:29:24 +00:00
Ashod Nakashian
7b87e4ab78 loolwsd: kill superfluous shutdownPeer
Change-Id: I50880e15b5e36f7701bafbfa59be57ed6bd856c1
Reviewed-on: https://gerrit.libreoffice.org/30824
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-11-14 05:28:28 +00:00
Ashod Nakashian
71c5f6c303 loolwsd: simplify PrisonerSession
Change-Id: If626b9e5ceb206480f29d4b4b70eeffca55a83c2
Reviewed-on: https://gerrit.libreoffice.org/30823
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-11-14 05:27:52 +00:00
Ashod Nakashian
b7df3b50a9 loolwsd: Log::syserror and Log::sysfatal now supported as macro
Change-Id: Ic07e7fb46e0b3e01db164e5812ef9256f149e5d9
Reviewed-on: https://gerrit.libreoffice.org/30822
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-11-14 05:24:04 +00:00
Ashod Nakashian
41e0902cdf loolwsd: cleanup LOOLStress
Change-Id: I8161488d30f8e173db47ccae5544b6d8b9f21f02
Reviewed-on: https://gerrit.libreoffice.org/30821
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-11-14 05:23:18 +00:00
Ashod Nakashian
ad70138fc9 loolwsd: move file utilities into FileUtil files
Change-Id: Ib0c0bc66adabe6885f7ac16414a3d5af13d72893
Reviewed-on: https://gerrit.libreoffice.org/30820
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-11-14 05:23:01 +00:00
Ashod Nakashian
2906442f03 loolwsd: cleanup LOOLWebSocket
Change-Id: Iad16918a5e0bc239ba969bbe596c1d2c4c01cebb
Reviewed-on: https://gerrit.libreoffice.org/30819
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-11-14 05:21:27 +00:00
Ashod Nakashian
3cff799301 loolwsd: Log error when not sending full frame
... and timeout when receiving frame.

Change-Id: I5bb085f494fc146f7fbd75be3f3bb86597029369
Reviewed-on: https://gerrit.libreoffice.org/30818
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-11-14 05:20:54 +00:00
Ashod Nakashian
b6926c2f4c loolwsd: proper retrying in connectLOKit
Change-Id: Ib99a6012510457876f422767cf42b92f412df1f5
Reviewed-on: https://gerrit.libreoffice.org/30817
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-11-14 05:19:49 +00:00
Ashod Nakashian
0506cbb5c4 loolwsd: move reveiveFrame from IoUtil to LOOLWebSocket
Change-Id: I82b64d16e496f104c34eeddce1ef9a1e57bc03bc
Reviewed-on: https://gerrit.libreoffice.org/30816
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-11-14 05:19:22 +00:00
Ashod Nakashian
5d69d0abd6 loolwsd: log only abbreviated messages
Change-Id: I3328a9171f8b85a802dc888de009bdbb8658cead
Reviewed-on: https://gerrit.libreoffice.org/30815
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-11-14 05:18:43 +00:00
Ashod Nakashian
d2d3bb19e0 loolwsd: new unittest to test forkit crash recovery
Change-Id: I61c79cce83af1fface2f54294d418c67eb6d398e
Reviewed-on: https://gerrit.libreoffice.org/30814
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-11-14 05:18:12 +00:00
Ashod Nakashian
ae3055c19a loolwsd: don't ignore zombies when counting loolkit processes
During tests we need to count the number of
oustanding loolkit processes. Since once a process
dies its parents must first reap it to get removed
from the proc table, we can't assume the process
is fully removed until and unless it's reaped.

In crash tests this becomes critical, since if
we load docs right after intentionally killing
loolkits, we will trick wsd into using a zombie
process. It will then fail at first communication
with the child. While this excercise early failure,
in practice this is unrealistic and will force
handling cases that in practice should not happen
(or when they do, nothing too horrible will happen).

By not counting zombies we can now wait in the crash
tests until forkit reaps the kits, then we test
the scenario where there are no ready children
when documents are loaded.

Change-Id: I0e5ca9a02d215ceca36d80071ba57e9a9c9c3240
Reviewed-on: https://gerrit.libreoffice.org/30813
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-11-14 05:14:36 +00:00
Pranav Kant
224e6fc8e7 loolwsd: Only warn about mis-spells, don't accept them
Change-Id: Iace494139eee8ff7dececf203c9fd51a98c6bd46
2016-11-11 22:54:46 +05:30
Jan Holesovsky
de9ec63e4f Turns out that setting 'blocking' is the right thing to do.
Unfortunately it turns out that POCO's handling of the non-blocking case is
wrong when EWOULDBLOCK is returned from ::send().  This leads to a situation
when part of the data has been sent, but it is impossible to send only the
rest of it, because of too high-level api for the websockets.

We could essentially re-implement the POCO's websockets and use just the lower
levels of POCO - but then it's a question whether it is actually easier to use
the Linux system calls right away :-)

Change-Id: Ied08f68d5037d0ab9ca8266cd20e1084bcebfd14
2016-11-11 17:39:13 +01:00
Pranav Kant
bde2b14679 loolwsd: Use Levenshtein distance to tolerate mis-spells
... case sensitiveness and wrong types.

Change-Id: I3ce59c551722138f7e5cb0f00ebcdcb8682e7d0b
2016-11-11 20:07:29 +05:30
Pranav Kant
dacf16f2d8 tdf#103671: 'true' -> true
Treat booleans as booleans, not string

Change-Id: Id0d3bee44b42461671379754e64e5e2f9b318045
2016-11-10 23:06:15 +05:30
Pranav Kant
2168617d60 tdf#103641: Implement ability to hide save, print, export options
Add more WOPI extensions for this - HidePrintOption,
HideSaveOption, HideExportOption. Setting HideExportOption to
'true' in WOPI CheckFileInfo response would hide the 'Download
as' option from the File menu.

Change-Id: Ia2259ee9525cc6c4331a52e2221af4df188eab07
2016-11-10 22:03:17 +05:30
Pranav Kant
9c5928a87b tdf#103641: Convert 'wopi:' message to JSON formatted message
... to accomdate other WOPI properties easily in future.

Change-Id: Ic92364f06f4f16ebe8f9f128cd49087f6d72a4d1
2016-11-10 22:03:17 +05:30
Jan Holesovsky
b8b469c9b2 Block when working via http.
It looks like that the implementation details of POCO are thread-unsafe when
in non-blocking mode, and that is even when the actual sending of the frames
is guarded by a mutex.

Needs more research; but for the moment, enable non-blocking mode for HTTP.

Change-Id: Idcce3fb55bae73c17d9fc321a2273256c0396664
2016-11-10 13:12:56 +01:00
Pranav Kant
b1cec28cc3 This was only meant for debugging.
Change-Id: Ia31847ab45c1aa18b5d9d4187ac552d7486331e7
2016-11-10 16:30:38 +05:30
Andras Timar
4526d54d58 add LOOLWebSocket.hpp to dist tarball 2016-11-10 11:01:33 +01:00
Jan Holesovsky
0674e87831 Implement a thread-safe websocket inherited from Poco::Net::WebSocket.
sendFrame() implemented in LOOLWebSocket is thread safe, and also deals with
large messages - sends the "nextmessage: size=..." frame before the actual
large frame.

The problem this is attempting to solve was that when sending a large frame,
it was split to multiple packets.  During that, another frame was sent from a
different thread; which lead to confusion, and the resulting frame was
corrupted (because it ended up composed from unrelated packets).

Change-Id: Ie85952e431b1cad2fdc6e3c64df8a444ea0ae971
2016-11-10 10:44:48 +01:00
Pranav Kant
b0933b063e tdf#103640: Implement OwnerTermination; send application-level close frame
This implements a new feature 'OwnerTermination' for WOPI based
hosts. WOPI hosts now have to enable this feature by mentioning
'EnableOwnerTermination' as 'true' in their CheckFileInfo
response. If the OwnerId of the file matches that of the UserId
of the session, this session would be able to terminate all other
sessions currently editing the same document.

The reason for this kind of document termination is sent to all
sessions in a new application-level 'close:' message. This new message is
similar to the CLOSE frame of WebSocket protocol which doesn't
seem to work across all browsers as of now. Eg: Chrome -
https://bugs.chromium.org/p/chromium/issues/detail?id=426798
After receiving this 'close: ' message, loleaflet acts
accordingly and tells the WOPI host why the websocket was closed
via post message API.

Change-Id: I997aa2e7805157ed599a3946a877fd32477cee1b
2016-11-10 15:04:21 +05:30
Pranav Kant
410936b600 loolwsd: This is not used anymore
Change-Id: I7a0405faad5a2c1e15788c084d51bb6a4a39f82f
2016-11-10 14:45:20 +05:30
Pranav Kant
a6d2fe80a1 loolwsd: Read and store session owner ids
Change-Id: If905344475eb6d9585eaa5a1df6882dc3a7bdb2b
2016-11-10 14:45:20 +05:30
Ashod Nakashian
8b5f112ebf loolwsd: recover when forkit dies
Change-Id: Idc1e08fb496d3c68b22e1d8eab2da9a9064ef070
Reviewed-on: https://gerrit.libreoffice.org/30743
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-11-10 05:17:15 +00:00
Ashod Nakashian
4c6aae20d5 loolwsd: don't error when killing a dead child process
Change-Id: I615911fb40a5218a6d1992dd94b63bff428699ee
Reviewed-on: https://gerrit.libreoffice.org/30742
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-11-10 05:16:23 +00:00
Ashod Nakashian
c5bff2b6e6 loolwsd: IoUtil logs updated
Change-Id: I632968753673089e8199b37a11f73286f88b20f4
Reviewed-on: https://gerrit.libreoffice.org/30741
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-11-10 05:15:38 +00:00
Ashod Nakashian
d5d31055c7 loolwsd: Admin formatting and cleanup
Change-Id: I0c0a9800bdd0a8ad1b652f8c5c05dc529ef04fe4
Reviewed-on: https://gerrit.libreoffice.org/30740
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-11-10 05:07:21 +00:00
Ashod Nakashian
793e00e134 loolwsd: use ostringstream when concatinating many strings
Change-Id: I55d4d0a14c81977568032d8a7dd1655b2f69ae67
Reviewed-on: https://gerrit.libreoffice.org/30739
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-11-10 05:02:02 +00:00
Ashod Nakashian
462f71a632 loolwsd: no need to ping to check for live socket
Ping message needs to be echoed and that messes
up reading large messages that come in two parts.

Luckily, it's not necessary to do so as it's
sufficient to poll the state of the socket.

It's true polling is less accurate as there is
a timeout when a socket is disconnected, but
that doesn't seem to be an issue in practice.

Change-Id: I7a5744a621c4416b8f9d003871f6d613cc6ca7dc
Reviewed-on: https://gerrit.libreoffice.org/30705
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-11-09 06:07:38 +00:00
Jan Holesovsky
024a6048a0 Move sendLargeFrame() from Util to IoUtil.
Change-Id: Id5db865b0bcf936651e3c89a0333a101e58ace92
2016-11-08 19:57:03 +01:00
Jan Holesovsky
5f6858f782 Factor out creation of nextmessage: and improve its logging.
Change-Id: I552bc2599835b4f6c9d4ef423889b464c5701221
2016-11-08 18:25:46 +01:00
Jan Holesovsky
66053621bd Make sure we resize the payload to the amount of read bytes.
Change-Id: I33f032182912b4f03d073258c91974518db327fd
2016-11-08 14:54:15 +01:00