Commit graph

4100 commits

Author SHA1 Message Date
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
Pranav Kant
7f77618f38 Document PostMessage API in reference.html
Change-Id: Ibdd3fc060a99f3b6185362fa3143014710873079
2016-11-10 14:45:20 +05:30
Pranav Kant
1a1792cdc1 loleaflet: Group map getters together
Change-Id: I576f78aaa215b6ba3aff6a5ce8498a3449080927
2016-11-10 14:45:20 +05:30
Pranav Kant
f1f5c4ed66 loleaflet: A more OO approach for WOPI post message API
Abstract all the WOPI related logic in a map handler which is
enabled only if map.options.wopi is set during map
initialization.

Change-Id: I54c5d6eecf33f88e4fd4d2b5ac9e8cf9dd001966
2016-11-10 14:45:17 +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
László Németh
8ef5c5fa36 loleaflet: hide debug control in disabled tile debug mode 2016-11-09 12:16:46 +01: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
Andras Timar
7f80400dea loleaflet: typo: No-with -> No-width 2016-11-09 00:28:27 +01:00
Andras Timar
937d8754b7 Updated Slovenian translation 2016-11-09 00:27:13 +01: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
Andras Timar
127b39d5b6 fix l10n of word count (thousand separator!) 2016-11-08 14:25:18 +01:00
Ashod Nakashian
d978dc83cf loolwsd: minor improvement to logging while running tests
Change-Id: Id602e52ceb42923f19d902f653e2d6477b8b8e1f
Reviewed-on: https://gerrit.libreoffice.org/30676
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-11-08 00:21:53 +00:00
Ashod Nakashian
0164df61a5 loolwsd: alertAllUsersOfDocument must be called while holding lock
Change-Id: I266a61402973c9418eb293d2f66601d00be76754
Reviewed-on: https://gerrit.libreoffice.org/30675
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-11-08 00:21:37 +00:00
Ashod Nakashian
d8c2bb9195 loolwsd: minimize holding locks beyond the necessary point
Change-Id: I379a649469622682d7ebe98b8a7ebe29eddd1dfa
Reviewed-on: https://gerrit.libreoffice.org/30674
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-11-08 00:21:18 +00:00
Andras Timar
7b83a5f90b loleaflet: update pot file 2016-11-07 18:52:50 +01:00
Andras Timar
b4dd01a3c8 loleaflet: update uno command translations 2016-11-07 18:51:25 +01:00
Andras Timar
f6a694716c loolwsd: copy 'debian' dir to tarball, silence tar 2016-11-07 15:20:01 +01:00
Pranav Kant
5f9a9264e4 Fix menubar l10n, set String.locale before requiring loleaflet
Change-Id: Ic5a22f05d0a11bd0485d0c88dfa34dcc6bfe29cf
2016-11-07 17:59:42 +05:30
Pranav Kant
9f65377c42 getViewIdHexColor -> getViewIdColor
This doesn't return a hex value anymore, it returns a rgb
integer.

Change-Id: I2fc234d7ba09e7b750c63dd9cf93356d02707fce
2016-11-07 17:31:15 +05:30
Miklos Vajna
121a471203 loolwsd: clean up unused using declarations
Change-Id: Ib7fc0d2dbc10cbccacde327b29fe70f255d58a05
2016-11-07 08:27:19 +01:00
Ashod Nakashian
ea0e5e9344 loolwsd: echo the unit-test command-line before running
Change-Id: Ib061732bccd18112c5d3842c01e8d20d441816c0
Reviewed-on: https://gerrit.libreoffice.org/30647
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-11-07 06:43:29 +00:00
Ashod Nakashian
2507f7f89c loolwsd: refactor DocumentBroker load and addSession
Change-Id: I01db44561f79280f152bdf802efcbc064b22ab89
Reviewed-on: https://gerrit.libreoffice.org/30646
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-11-07 06:43:12 +00:00
Ashod Nakashian
f3ffd59860 loolwsd: assert ChildProcess doesn't destroy DocumentBroker
Change-Id: Iff20323f809f255557e05652ba08f7688b823fe1
Reviewed-on: https://gerrit.libreoffice.org/30645
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-11-07 06:42:40 +00:00
Ashod Nakashian
f669891892 loolwsd: name the child socket thread
Change-Id: I079d821522b016cbd70a958b6a3e908a32b61f37
Reviewed-on: https://gerrit.libreoffice.org/30644
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-11-07 06:41:22 +00:00
Ashod Nakashian
a1d846b431 loolwsd: correct wsd initialization and preconditions
For unit-tests at least listening to the public port before
having forked forkit, let alone having a single child process
ready, means we could starve and fail tests randomly.

Here we first correct the order of initialization, such that
the public port listening happens last. Second, we wait until
we have at least one child successfully connected and ready.

Change-Id: I7a31ad1ca4b30746f3cbf9c6b315670207cb7716
Reviewed-on: https://gerrit.libreoffice.org/30643
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-11-07 06:40:43 +00:00
Ashod Nakashian
86fb4dc03b loolwsd: extend the lifetime of lokit to avoid destroying
Lokit's destroy is prone to throw (at least in dbgutil).

This exception brings the binary down with a core-dump.

To avoid this, we extend the lifetime of lokit to the end
of the process, where we invoke std::_Exit to promptly
kill the process and exit.

For reference, the exception is thrown as follows:
 #0  0x00007f0ba5a43bcd in __cxa_throw () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
 #1  0x00007f0b76303248 in (anonymous namespace)::ModuleManager::identify (this=0x7f0b5328e6d0, xModule=empty uno::Reference) at /home/ash/prjx/cp51/framework/source/services/modulemanager.cxx:198
 #2  0x00007f0b762606dc in (anonymous namespace)::JobExecutor::notifyEvent (this=0x7f0b77176b30, aEvent=...) at /home/ash/prjx/cp51/framework/source/jobs/jobexecutor.cxx:274
 #3  0x00007f0ba13ea455 in (anonymous namespace)::SfxGlobalEvents_Impl::implts_notifyJobExecution (this=0x7f0b77176a30, aEvent=...) at /home/ash/prjx/cp51/sfx2/source/notify/globalevents.cxx:397
 #4  0x00007f0ba13e9346 in (anonymous namespace)::SfxGlobalEvents_Impl::documentEventOccured (this=0x7f0b77176a30, _Event=...) at /home/ash/prjx/cp51/sfx2/source/notify/globalevents.cxx:241
 #5  0x00007f0ba0fe5717 in SfxTerminateListener_Impl::notifyTermination (this=0x7f0b772462c8, aEvent=...) at /home/ash/prjx/cp51/sfx2/source/appl/appinit.cxx:125
 #6  0x00007f0b762ebc39 in framework::Desktop::terminate (this=0x7f0b7721d530) at /home/ash/prjx/cp51/framework/source/services/desktop.cxx:330
 #7  0x00007f0ba47940ce in lo_destroy (pThis=0x154de60) at /home/ash/prjx/cp51/desktop/source/lib/init.cxx:2926
 #8  0x0000000000429681 in lok::Office::~Office (this=<optimized out>, __in_chrg=<optimized out>) at LibreOfficeKit.hpp:516
 #9  __gnu_cxx::new_allocator<lok::Office>::destroy<lok::Office> (this=<optimized out>, __p=<optimized out>) at /usr/include/c++/5/ext/new_allocator.h:124
 #10 std::allocator_traits<std::allocator<lok::Office> >::_S_destroy<lok::Office> (__p=<optimized out>, __a=...) at /usr/include/c++/5/bits/alloc_traits.h:285
 #11 std::allocator_traits<std::allocator<lok::Office> >::destroy<lok::Office> (__a=..., __p=<optimized out>) at /usr/include/c++/5/bits/alloc_traits.h:414
 #12 std::_Sp_counted_ptr_inplace<lok::Office, std::allocator<lok::Office>, (__gnu_cxx::_Lock_policy)2>::_M_dispose (this=0xb04f40) at /usr/include/c++/5/bits/shared_ptr_base.h:531
 #13 0x000000000042dfb6 in std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_release (this=0xb04f40) at /usr/include/c++/5/bits/shared_ptr_base.h:150
 #14 0x0000000000425797 in std::__shared_count<(__gnu_cxx::_Lock_policy)2>::~__shared_count (this=0x7ffce7430468, __in_chrg=<optimized out>) at /usr/include/c++/5/bits/shared_ptr_base.h:659
 #15 std::__shared_ptr<lok::Office, (__gnu_cxx::_Lock_policy)2>::~__shared_ptr (this=0x7ffce7430460, __in_chrg=<optimized out>) at /usr/include/c++/5/bits/shared_ptr_base.h:925
 #16 std::shared_ptr<lok::Office>::~shared_ptr (this=0x7ffce7430460, __in_chrg=<optimized out>) at /usr/include/c++/5/bits/shared_ptr.h:93
 #17 lokit_main (childRoot="/home/ash/prj/lo/online/loolwsd/test/../jails/", sysTemplate="/home/ash/prj/lo/online/loolwsd/test/../systemplate", loTemplate="/home/ash/prj/lo/instdir", loSubPath="lo", noCapabilities=<optimized out>, queryVersion=queryVersion@entry=true, displayVersion=false) at LOOLKit.cpp:1441
 #18 0x000000000041df41 in createLibreOfficeKit (childRoot="/home/ash/prj/lo/online/loolwsd/test/../jails/", sysTemplate="/home/ash/prj/lo/online/loolwsd/test/../systemplate", loTemplate="/home/ash/prj/lo/instdir", loSubPath="lo", queryVersion=queryVersion@entry=true) at LOOLForKit.cpp:228
 #19 0x000000000041aea4 in main (argc=7, argv=0x7ffce7431ec8) at LOOLForKit.cpp:389

194         {
195             throw css::lang::IllegalArgumentException(
196                     OUString("Given module is not a frame nor a window, controller or model."),
197                     static_cast< ::cppu::OWeakObject* >(this),
198                     1);
199         }

Change-Id: Idaef5e0a28021a73f4c03ee3bee80968d9c57bd5
Reviewed-on: https://gerrit.libreoffice.org/30642
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-11-07 06:39:22 +00:00
Ashod Nakashian
8cd8ca27a6 loolwsd: new 'exit' command to request child process termination
Change-Id: Id3f9bc67096b422630e04f59ed4ccbca012ddd4a
Reviewed-on: https://gerrit.libreoffice.org/30641
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-11-07 06:38:39 +00:00
Ashod Nakashian
f1f1ff7057 loolwsd: correct document loading and error handling
Change-Id: I7529c8584356f5eea3c91b5d5ffdd6a956710241
Reviewed-on: https://gerrit.libreoffice.org/30640
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-11-07 06:37:36 +00:00
Ashod Nakashian
71f2f4921d loolwsd: better use named variable than it->second
Change-Id: Ia336b9001911dfd2cf1c19c1536f52bed7684a2a
Reviewed-on: https://gerrit.libreoffice.org/30639
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-11-07 06:36:52 +00:00
Ashod Nakashian
11a0d016ca loolwsd: inline and simplify connectPeers
Change-Id: I64fbeefa59573eb9e467dc18ecbf75ebd72b3be4
Reviewed-on: https://gerrit.libreoffice.org/30638
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-11-07 06:36:24 +00:00
Ashod Nakashian
4e13f1b37c loolwsd: cleanup document and storage loading in WSD
Change-Id: I4d6bdda131efb6270fbd5864034ac619cf86ef3d
Reviewed-on: https://gerrit.libreoffice.org/30637
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-11-07 06:36:04 +00:00
Ashod Nakashian
a5f1597e0f loolwsd: LOOLKit logs updated
Change-Id: I003d060ac2fd5673d57f7c175837ac3daf335f17
Reviewed-on: https://gerrit.libreoffice.org/30636
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-11-07 06:34:59 +00:00
Ashod Nakashian
e329f3595f loolwsd: UnitStorage logs updated
Change-Id: Ie5e9bed6d6ab56039d357dea09470953ca49d458
Reviewed-on: https://gerrit.libreoffice.org/30635
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-11-07 06:34:41 +00:00
Ashod Nakashian
10659d970b loolwsd: UnitPrefork logs updated
Change-Id: I7cc37295459aceac6ba38af4fb274c39f55885a4
Reviewed-on: https://gerrit.libreoffice.org/30634
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-11-07 06:34:31 +00:00
Ashod Nakashian
ca17fc74c7 loolwsd: Unit logs updated
Change-Id: Ic60e59f21bdb426997808d14a4e0375e38362161
Reviewed-on: https://gerrit.libreoffice.org/30633
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-11-07 06:34:16 +00:00
Ashod Nakashian
9bb6d73fda loolwsd: DocumentBroker logs updated
Change-Id: I64bd10c05a24f1b6716241cf1048af157282fa18
Reviewed-on: https://gerrit.libreoffice.org/30632
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-11-07 06:33:33 +00:00
Ashod Nakashian
f4c7d67d26 loolwsd: LOOLWSD logs updated
Change-Id: I0a139ed4f27be4949c15949a10d461784aa510e0
Reviewed-on: https://gerrit.libreoffice.org/30631
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-11-07 06:33:12 +00:00
Ashod Nakashian
f3d5b73c4e loolwsd: sleep more with LOOL_DEBUG after dumping stacktrace
Change-Id: I52d764634af3faa0b08d7c4ff7483e0dcc1db312
Reviewed-on: https://gerrit.libreoffice.org/30630
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-11-07 06:32:34 +00:00
Ashod Nakashian
800e711321 loolwsd: proper ChildProcess cleanup
Change-Id: If9be827aa50471b7d1d922402414d028ccdcff8b
Reviewed-on: https://gerrit.libreoffice.org/30629
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-11-07 06:32:10 +00:00
Ashod Nakashian
3993757ee8 loolwsd: fix race while creating new documents
This fixes the race rather than trying to patch it.
It still minimizes the locking necessary to a minimum
to maximize parallelism.

The approach is to have at least the DocBrokers lock
or the DocumentBroker lock (if we already have a doc)
while creating new document views.

Change-Id: I96b4f17b3be3d03cd5e6f4d17d39e2165fe008a7
Reviewed-on: https://gerrit.libreoffice.org/30628
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-11-07 06:31:26 +00:00