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
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
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
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>
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>
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>
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>