Commit graph

333 commits

Author SHA1 Message Date
Tor Lillqvist
735713bfb4 The withColor parameter to Log::initialize() is bool
So passing a char* that never is null meant it will always be
automatically converted to true, which is not useful.
2016-10-07 11:53:07 +03:00
Miklos Vajna
3f0def0b02 Avoid 'auto' for getenv() result
Which is sometimes stored in a bool, but when auto is used, it's char*,
so it helps to have that written explicitly.

Change-Id: I561692e8d5c575b4ff8612fd50e489ad3c60d655
2016-10-07 10:20:13 +02:00
Henry Castro
b60f596a64 loolwsd: avoid getenv() nullptr
what():  basic_string::_S_construct null not valid
2016-10-06 15:02:13 -04:00
Michael Meeks
39b2c725d9 Improve and standardize version details: display on start. 2016-10-06 11:18:50 +01:00
Ashod Nakashian
5b3e5f73a2 loolwsd: trade view creation and assert lock ownership
Change-Id: Ib593bec4d6e6b810d5f6cfb4bdf7d3f1212709b4
Reviewed-on: https://gerrit.libreoffice.org/29549
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-10-06 05:58:11 +00:00
Ashod Nakashian
c542fde244 loolwsd: factor out getViewIds and broadcasting
This minimizes unlocking and relocking
on the LOK Document.

Change-Id: Ibe5045c82008df907dc329c1530cb50138b0c211
Reviewed-on: https://gerrit.libreoffice.org/29545
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-10-06 05:54:54 +00:00
Ashod Nakashian
ce832fbc11 loolwsd: get the invalidated part from the callback directly
By default LOK doesn't provide the part where the invalidated
tile is. The part # is found using API, but due to the fact
that callbacks are processed asynchronously, the part #
may well have changed by the time the invalidation is
processed. This could result in buggy invalidations
where no modification took place.

With the new API flag LOK_FEATURE_PART_IN_INVALIDATION_CALLBACK
the part # is included in the callback, which is parsed
and used to inform the client with the correct part #.

Change-Id: Ibd85764bfdc41ebf1aae490df335bd503284ae91
Reviewed-on: https://gerrit.libreoffice.org/29467
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-10-03 05:32:45 +00:00
Miklos Vajna
38577b74fd Refactor to be able to unit-test Document::ViewCallback()
Change-Id: If07eb89e5d2f45737a8af10803511ab2ee3a07b3
2016-09-30 15:42:50 +02:00
Miklos Vajna
3090981c8a Document repair: expose user names, not only view IDs
Also in leaflet replace the current user with "You" to be consistent
with the statusbar.

Change-Id: If2d76f078eeae3038f8ae17506ae7679f7b23023
2016-09-30 14:21:14 +02:00
Tor Lillqvist
96e6ad7502 Re-think disk full handling
Instead of trying to inform the sysadmin (which we did not yet try to
do in any meaningful way), inform all connected clients (even those
editing other documents).

We use 'error: cmd=internal kind=diskfull' as the message to the
clients. The loleaflet code needs to be updated to handle that
carefully by displaying a very prominent message that tells the user
that all bets are off.

Also add a unit test for the functionality.

Document the new protocol details.

The code for this alert functionalty became a bit less elegant than I
like because of the way we include Util.cpp in the unit test 'test'
program.

Still need to add code to check for disk full in more places, not just
when saving a cached tile or font. Probably we should even actually
check for disk space on the file system(s) we use getting alarmingly
low, not just check for file writing operations that fail. Later.
2016-09-29 00:23:14 +03:00
Miklos Vajna
31867f669d Fix remaining uninitialized members
The missing init of mutexes is probably theoretical, the TraceFile and
the Unit ones were real errors, I think.

Change-Id: If19c23a9c93d34059998346af8d45c26a34043a6
2016-09-28 10:20:48 +02:00
Miklos Vajna
fed97b97a7 LOOLKit: remove unused unsing declarations
Change-Id: I6a0efca4dd87694aaa3d32500a56c3a5d246b028
2016-09-27 09:46:24 +02:00
Tor Lillqvist
fa697d843e Remove reference to non-public bugzilla 2016-09-27 09:29:18 +03:00
Tor Lillqvist
e0c5f26015 bccu#2035: Work around crash by just exiting before it happens 2016-09-26 17:31:49 +03:00
Ashod Nakashian
5daf4ab341 loolwsd: don't process callbacks or queue messages if terminating
Change-Id: I1ff75d01a0f24ba3b9d7ca2003f1633d0aa494e0
Reviewed-on: https://gerrit.libreoffice.org/29288
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-09-26 02:50:51 +00:00
Jan Holesovsky
61b0ad4933 Fix a race between the tile rendering and invalidation callbacks.
Instead of 2 queues and 2 threads, merge those to one - which gives a perfect
ordering of the invalidations and rendering.

Change-Id: I229dfc08b43e6ce7e4f08ea8059d3298d9bf8f8a
Reviewed-on: https://gerrit.libreoffice.org/29282
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-09-26 02:44:19 +00:00
Ashod Nakashian
b8317e7b34 loolwsd: lokit process logs to file if configured
Pass the log-to-file config to the kit processes
using envars.

Change-Id: Ida79c35ab02d8038685153805be780359bfbe97e
Reviewed-on: https://gerrit.libreoffice.org/29161
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-09-22 03:33:26 +00:00
Ashod Nakashian
1641f756b2 loolwsd: improved logging
Change-Id: I1a1559754efcb0614875dc76ae0637ed6dc1ba77
Reviewed-on: https://gerrit.libreoffice.org/29160
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-09-22 03:32:48 +00:00
Pranav Kant
46107dd0c8 loolwsd: Always send the updated view info to clients
This replaces addview/remview/remallview messages in the protocol
with 'viewinfo' message which is sent whenever there is any
change in the view information.

Let the client deal with what information is redundant to it.

Change-Id: Ic470ea88a94ff281a0ae021014a9fba1b876f648
2016-09-21 12:02:27 +05:30
Ashod Nakashian
0326aa4304 loolwsd: cancel individual tiles
Change-Id: I18faee319fc12de2151460afbb054b8509578579
Reviewed-on: https://gerrit.libreoffice.org/29120
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-09-21 05:15:30 +00:00
Ashod Nakashian
e9f37433d7 loolwsd: combine tiles before rendering to reduce latency
Change-Id: I5af2d2a9ddf3b5a3db5bc5f0835687d7cae5b17c
Reviewed-on: https://gerrit.libreoffice.org/29115
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-09-21 04:59:49 +00:00
Ashod Nakashian
3b2055a0a8 loolwsd: remove the callback descriptor after destroyView
On destroyView Core must flush the events queue, otherwise
by the next idle the descriptor will be gone and we'll
be using freed memory.

Change-Id: I6d3d8f9461bc156383a7294e9c65c535d79f2e7a
Reviewed-on: https://gerrit.libreoffice.org/29088
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-09-20 11:58:20 +00:00
Tor Lillqvist
90c7b553ed Don't erase the CallbackDescriptor record before turning off callbacks
Seems to fix the deadlock problem, or at least makes it very much
rarer. (I am not entirely certain that a callback might not be in
progress already (in another thread) when we turn off callbacks, and
in that case the callback might still then access freed memory?)
2016-09-20 13:32:43 +03:00
Ashod Nakashian
a9fbfe8d8a loolwsd: remove queue thread from child socket handler
Change-Id: Ib6b4890db1f331b2e2cdcfafb57366ff62e3a13d
Reviewed-on: https://gerrit.libreoffice.org/29067
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-09-20 03:31:31 +00:00
Ashod Nakashian
23ef612970 loolwsd: ensure that the connection thread is running
If the connection thread is not running when loading a
document, the callback will drop events. This can happen
when the thread is too slow to spawn, but we return from
the createSession function and process client messages.

This should solve the race where we lose notifications of
other views when a new view is created.

Change-Id: Ia79739889b2f01fbb374d48eb33620084f4ed1c1
Reviewed-on: https://gerrit.libreoffice.org/29063
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-09-20 03:25:16 +00:00
Ashod Nakashian
bad8ae9ed9 loolwsd: one anonymous namespace per file is enough
Change-Id: I12b4967a321de45fc50ad314775d01499b5edd80
Reviewed-on: https://gerrit.libreoffice.org/29061
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-09-20 03:21:18 +00:00
Miklos Vajna
ea274bcf6b Document::ViewCallback: don't fail on EMPTY cell cursor
Change-Id: I67bee2a1f1332bfb82963e0fb3a0e761054f826e
2016-09-19 16:04:23 +02:00
Ashod Nakashian
7fff960391 loolwsd: stop the tile-queue when exiting
Change-Id: I49276c9639e8826d145a31eb476b41eb64baf88a
Reviewed-on: https://gerrit.libreoffice.org/29009
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-09-19 12:03:57 +00:00
Ashod Nakashian
f0c09238ce loolwsd: fail fast rather than catch all
Change-Id: Ib38924bf823315d211eb467d90f364fdc225ba2e
Reviewed-on: https://gerrit.libreoffice.org/29005
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-09-19 11:59:23 +00:00
Tor Lillqvist
df3cc99025 Don't require the LOK_VIEW_CALLLBACK env var any more
Act as if it was always set.

The ChildSession::_multiView field will always be true, so factor it
out. Ditto for Document::_multiView.

The ClientSession::_haveEditLock will also be always true, so factor
it out. This means the ClientSession::isEditLocked() will always
return true, so factor it out, too.

ClientSession::markEditLock() always will always set _haveEditLock to
true (which it will be from the constructor already anyway) so it can
be removed.

ClientSession::setEditLock() does not need a parameter as the
parameter was actually only used for misleading logging. The msg
variable constructed in the function used isEditLocked(), not the
parameter.

We still generate and handle editlock messages. Not sure whether that
makes any sense, though.
2016-09-19 12:13:00 +03:00
Henry Castro
7243e485d0 loolwsd: assign view id after loading
When session, it is not assigned, ViewCallback thread
will not enqueue the message
2016-09-17 18:13:05 -04:00
Henry Castro
722ca5daf5 loolwsd: log: warn lost messages 2016-09-17 18:12:44 -04:00
Miklos Vajna
3d27e285b6 lok::Document: rename getViews() to getViewsCount()
Adapt client code to the changed core.git API.

Change-Id: I752d27919b7983909c8e96900115cca26bac11c6
2016-09-16 12:32:19 +02:00
Marco Cecchetti
80153826db Revert "loolwsd: we use callbacks latch for not missing messages sent very early"
This reverts commit ed983f17cb.

Conflicts:
	loolwsd/bundled/include/LibreOfficeKit/LibreOfficeKit.h

Change-Id: Ia85b4d9223e9918dd33a66b8d6aeb0c3a1516a3c
Reviewed-on: https://gerrit.libreoffice.org/28904
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-09-15 13:23:39 +00:00
Ashod Nakashian
ad6d77cd3b loolwsd: remove cursor of unloading views
Change-Id: I4281a5aa101f034007aa227bb18b14eeba806ea0
2016-09-14 23:19:56 +01:00
Ashod Nakashian
2db1db06c7 loolwsd: queue -> tileQueue
Change-Id: If61de6807fa7f52a703fe45948df911fe162f69a
2016-09-14 23:19:45 +01:00
Ashod Nakashian
ece87da287 loolwsd: tile prioritization per view cursor
Change-Id: I1410b64982ac2db04e5a47d744a95b8d2eab5f7e
2016-09-14 23:19:38 +01:00
Miklos Vajna
6006e22001 LOOLKit: use std::move() in Document ctor
Change-Id: I25aeb5285465385858180747f441a69b858c4fe6
2016-09-12 08:15:37 +02:00
Marco Cecchetti
ed983f17cb loolwsd: we use callbacks latch for not missing messages sent very early
- lok::Document::setCallbackLatch: used on doument loading for
set/unset the latch

- now cell cursors of other views are correctly notified to the new
view
2016-09-10 21:28:11 +02:00
Marco Cecchetti
edc1302f16 Revert "loolwsd: we use callbacks latch for not missing messages sent very early"
This reverts commit f2106157f3.
2016-09-10 20:51:59 +02:00
Marco Cecchetti
f2106157f3 loolwsd: we use callbacks latch for not missing messages sent very early
- lok::Document::setCallbackLatch: used by a child session for
set/unset the latch

- lok::Document::registerCallback has a new boolean parameter used for
setting the latch state just before the callback is actually
registered for a (new) view

- now cell cursors of other views are correctly notified to the new
view
2016-09-09 22:23:51 +02:00
Pranav Kant
33a5c4bc70 Fix comment
Change-Id: Ib43bcc7378590e71b98856c11218fd99ad90d32d
2016-09-07 21:47:11 +02:00
Pranav Kant
1b0088ab69 loolwsd: Comments
Change-Id: Ia4e91f18d695ac2249fa1139afbcb5b3f65f87ba
2016-09-07 11:37:12 +02:00
Pranav Kant
3f421be4da loolwsd: Code reuse, and don't send 'remview' message to inactive clients
Use the existing function notifyOtherSessions() to broadcast the
message.

The function also takes care of sending this message only to
active clients.

Change-Id: I98d40429de17463167a67cb10ba59381a0cbc525
2016-09-07 09:20:37 +02:00
Pranav Kant
9edb1c2994 loolwsd: Don't send addview notification to inactive clients
Change-Id: I4771e4bf12057fdc7099e9433d3b7dc2198cb265
2016-09-07 09:20:37 +02:00
Ashod Nakashian
2663f9b63f loolwsd: replace old tile requests with more recent ones
A new queue with own thread now processes tile requests
so we have a chance to cull backlogged tile requests
that have since been invalidated.

This reduces load on the server significantly, especially
with multiple view at different zoom levels, and very fast
typing.

Change-Id: I6599939cd363dc71c30187f40d542aa37260dc56
Reviewed-on: https://gerrit.libreoffice.org/28607
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-09-01 20:47:10 +00:00
Tor Lillqvist
eb4b4b6ca0 Remove leftover unused field Connection::_stop
Not sure what the stop() function should do now, if anything. Maybe
_stop should be kept and actually tested somewhere, like in the third
lambda passed to IoUtil::SocketProcessor() in Connection::run()?
2016-09-01 17:04:05 +03:00
Ashod Nakashian
f4c0a87991 Revert "loolwsd: remove queue thread from child socket handler"
This reverts commit a30526c87e.

Change-Id: Idcbf2a6c4e228a5fb6a890e8cdd58b6137295666
Reviewed-on: https://gerrit.libreoffice.org/28596
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-09-01 12:37:55 +00:00
Ashod Nakashian
fad6715f7d loolwsd: guard against processing commands before fully loading
Change-Id: Iac915074728f616d81b05558b886998855326a2e
Reviewed-on: https://gerrit.libreoffice.org/28525
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-08-31 04:42:39 +00:00
Ashod Nakashian
a674fc7e8f loolwsd: logs and formatting
Change-Id: Ic3ec268cdc1962814654c7be676da62375494f66
Reviewed-on: https://gerrit.libreoffice.org/28524
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-08-31 04:41:31 +00:00