Commit graph

133 commits

Author SHA1 Message Date
Tor Lillqvist
f94d4c789d 'Handshake' is one word
Change-Id: Ibef905cc42a74052738a71bd4743431e30b863d1
2017-01-02 13:29:09 +02:00
Ashod Nakashian
85102cf76a wsd: log the session name when subscribing for tiles
Change-Id: I478834bdd7e91eaa64b224a56c8344cb0ef9f82a
Reviewed-on: https://gerrit.libreoffice.org/32632
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-02 06:17:44 +00:00
Ashod Nakashian
aebfccd2ca wsd: force forking children when none is outstanding
Change-Id: I06f9063ddf32f9296e5e523454b19e8b5692c285
Reviewed-on: https://gerrit.libreoffice.org/32630
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-02 06:16:43 +00:00
Ashod Nakashian
28db46a59c wsd: always update the last save time to detect failures
When saving we need to differentiate between no-op
and failure. The lastSaveTime must always be updated
when saving didn't fail (i.e. no modification or saved).

Change-Id: I0e2455afac22c82f0b623f9441fbc0bca8a7cb83
Reviewed-on: https://gerrit.libreoffice.org/32629
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-02 06:16:25 +00:00
Ashod Nakashian
228eb98f4c wsd: move rebalanceChildren and avoid declaration
Change-Id: Ie8e7e1e28f5496cf5376622cb8f24696e45cb5fc
Reviewed-on: https://gerrit.libreoffice.org/32628
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-02 06:15:13 +00:00
Ashod Nakashian
65d2036d63 wsd: use chrono instead of time_t
While time_t is much simpler, it's too
opaque. The new chrono library is type-safe
and does conversion correctly, as well as
guarantees monotonity and other desirable
properties.

Change-Id: Id41c44c397a31d73e894e8f1715ff18f2b67df53
Reviewed-on: https://gerrit.libreoffice.org/32627
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-02 06:14:51 +00:00
Ashod Nakashian
a4868edb41 wsd: merge idle document killing with document cleanup
Since we already enumerate the DocumentBrokers and
remove dead ones before every autosave (every 30 seconds)
as well as when loading/unloading documents, there
is little reason to have a separate timeout and loop
for idle documents.

In addition, the previous code only killed the child
but didn't remove the dead DocumentBroker entry from
DocBrokers. Not clear if this was intentional, but it
would have been removed on the next cleanup anyway.

Change-Id: Ie1e09c77133165dd1255930b0b0be06fde7646b1
Reviewed-on: https://gerrit.libreoffice.org/32626
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-02 06:13:20 +00:00
Ashod Nakashian
9b99f64772 wsd: don't sleep after autosaving or spawning children
Between waits on forkit we shouldn't spend too much time.
This is to recover from forkit crashes.

Now we first spawn children, and only when not successful
(i.e. no more spare children needed) we check for autosave
and DocBrokers cleanup. Only when none of the above is done
do we sleep.

This gives the best balance between forkit waits and reduces
the unittests by a good 25 seconds (crash tests down from 34s
to about 10s only).

Change-Id: If69284746859bc78d14f1c6eda07aef4e006709e
Reviewed-on: https://gerrit.libreoffice.org/32624
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-02 06:12:14 +00:00
Ashod Nakashian
d716428f71 wsd: return child forking status
Change-Id: If2504bc8b745c8cf0894a6ccaae7b869e06a8f24
Reviewed-on: https://gerrit.libreoffice.org/32623
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-02 06:10:29 +00:00
Ashod Nakashian
46ef41a687 wsd: force spawning children on startup
Otherwise we throttle spawning to allow
time to fork the process. If we don't wait
we can bomb a loaded server and bring it down.

However during startup this is not necessary
as there are no in-flight spawn requests.

Change-Id: I1beac94571f6d8d96136d32c81310bea6547242b
Reviewed-on: https://gerrit.libreoffice.org/32622
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-02 06:09:54 +00:00
Ashod Nakashian
e55be929b0 wsd: reuse rebalanceChildren in getNewChild
Change-Id: Ib5e2750e3b3f49c649c2d14fb5016e427b535912
Reviewed-on: https://gerrit.libreoffice.org/32621
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-02 06:08:47 +00:00
Ashod Nakashian
78f3a4d9b9 wsd: refactor and reuse child forking
Change-Id: Ie5e5966896a728edf032c046bda65c7c9553c27c
Reviewed-on: https://gerrit.libreoffice.org/32620
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-02 06:08:21 +00:00
Ashod Nakashian
fb1e8eb63a wsd: flag for shutdown when we fail to create forkit
And say 'forkit' in the logs where we recognize it
instead of the generic 'child'.

Change-Id: I7628b064bb6330db145a948640e48b727def3270
Reviewed-on: https://gerrit.libreoffice.org/32619
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-02 06:07:45 +00:00
Ashod Nakashian
401c7e54c7 wsd: cleanup document saving logs and include the DocKey
Change-Id: I17100ef2115c1953779fe9dda9568c8ae4d6326e
Reviewed-on: https://gerrit.libreoffice.org/32618
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-02 06:06:52 +00:00
Ashod Nakashian
d67437735f wsd: cleanup all DocBrokers when one is removed
Change-Id: I1010093185e117f50f56d96e73d0771c52113d90
Reviewed-on: https://gerrit.libreoffice.org/32614
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-02 06:03:11 +00:00
Ashod Nakashian
15a6c02f70 wsd: remove DocumentBroker instances without sessions
Change-Id: I052acba594f0da76332996b25c5349e8fff23606
Reviewed-on: https://gerrit.libreoffice.org/32613
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-02 06:02:49 +00:00
Ashod Nakashian
3844f5934e wsd: use isAlive before sending message to child
Change-Id: Ie463f89226bc0391102a3a4ae700e90cd3993271
Reviewed-on: https://gerrit.libreoffice.org/32612
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-02 06:02:30 +00:00
Ashod Nakashian
f3a90ef77a wsd: always notify threads waiting on save
And check for save-failed first before finding
the session, as otherwise the session is useless.

Change-Id: I3eb45e54872547eb36765b2c8409e1aa51aee589
Reviewed-on: https://gerrit.libreoffice.org/32611
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-02 06:02:04 +00:00
Ashod Nakashian
38bf731a98 wsd: simplify logging during save
Change-Id: Icdd790a555c301e285c9fa3a4eeff87aae2aec3e
Reviewed-on: https://gerrit.libreoffice.org/32610
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-02 06:01:18 +00:00
Ashod Nakashian
df32077005 wsd: read message payload from correct source
Change-Id: I9333b4ecb3aae7c22e93f0b92a3e6eed59bb875f
Reviewed-on: https://gerrit.libreoffice.org/32600
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-02 05:53:31 +00:00
Ashod Nakashian
62371e5f41 wsd: log failure in else and not unconditionally
Change-Id: I24f1ac57f350aa67cc14682d695e1e4a07453c8d
Reviewed-on: https://gerrit.libreoffice.org/32562
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-01 04:20:40 +00:00
Ashod Nakashian
aef5af8114 wsd: Storage logs updated
Change-Id: Ib3083e833fdc2891ab0c89231bf2ec3e81285803
Reviewed-on: https://gerrit.libreoffice.org/32560
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-01 04:19:47 +00:00
Ashod Nakashian
759564368d wsd: reorganize DocBrokers lookup
Avoid unnecessary code under lock
or when DocBrokers is updated,
which requires removal on exception.

Change-Id: Id01aed42cd66616b910b7e16a8a1ed6c1d1e74b9
Reviewed-on: https://gerrit.libreoffice.org/32558
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-01 04:18:22 +00:00
Ashod Nakashian
e4a0402924 wsd: improved logging of DocBrokers and NewChildren activity
And improved some comments.

Change-Id: I00605e7471e4f6354d3ff62e1e3873f7e5a7986d
Reviewed-on: https://gerrit.libreoffice.org/32557
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-01 03:59:15 +00:00
Ashod Nakashian
9dfd2008d5 wsd: send text messages as text not binary
Change-Id: I03dccb8035eb0f1d1fbf85f75f2e4f36af1ce689
Reviewed-on: https://gerrit.libreoffice.org/32554
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-01 03:57:27 +00:00
Ashod Nakashian
1a90273672 wsd: log child-to-wsd messages once
Change-Id: I723f673998622416a8aa1f0f46928f530ceb252e
Reviewed-on: https://gerrit.libreoffice.org/32553
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-01 03:56:47 +00:00
Ashod Nakashian
ba90ea304c wsd: ClientSession logs updated
Change-Id: I4ec664ebd7eadbe3763ee18eb511662de6453ebb
Reviewed-on: https://gerrit.libreoffice.org/32552
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-01 03:56:19 +00:00
Ashod Nakashian
3a5be2926b wsd: log WS incoming messages only once
Change-Id: Iee31bc649ae2d194b6418367f0e9ab8561099b17
Reviewed-on: https://gerrit.libreoffice.org/32551
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-01-01 03:55:19 +00:00
Ashod Nakashian
8481e9c21d wsd: improved logging of child process management
Change-Id: Iaa1f333e3fe427219f244f913834a46a80377032
Reviewed-on: https://gerrit.libreoffice.org/32549
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-12-31 23:23:04 +00:00
Ashod Nakashian
ba9ffb4775 wsd: include cleanup
Change-Id: Id481cfbab6be12a095918bdc7318fb3584345307
Reviewed-on: https://gerrit.libreoffice.org/32548
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-12-31 23:22:15 +00:00
Noel Grandin
08ce0ed2da loplugin:simplifybool
Change-Id: If2de633684eeef572b5fe0a2b675f221f513e3f7
Reviewed-on: https://gerrit.libreoffice.org/32369
Reviewed-by: Tor Lillqvist <tml@collabora.com>
Tested-by: Tor Lillqvist <tml@collabora.com>
2016-12-27 10:44:22 +00:00
Noel Grandin
0bb8ba8307 loplugin:staticaccess
Change-Id: I1abd6c2a28d3a8e4fb0cda2d35be94d787ff67b7
Reviewed-on: https://gerrit.libreoffice.org/32368
Reviewed-by: Tor Lillqvist <tml@collabora.com>
Tested-by: Tor Lillqvist <tml@collabora.com>
2016-12-27 10:43:34 +00:00
Noel Grandin
98c236f9bb loplugin:staticanonymous
Change-Id: I2adf6be69967c163dd6dabbc35e9777589133956
Reviewed-on: https://gerrit.libreoffice.org/32367
Reviewed-by: Tor Lillqvist <tml@collabora.com>
Tested-by: Tor Lillqvist <tml@collabora.com>
2016-12-27 10:42:36 +00:00
Noel Grandin
6c0022fb10 loplugin:staticmethods
Change-Id: Idf9596cfbbd6eef77e6271a1108d64dae864ed27
Reviewed-on: https://gerrit.libreoffice.org/32366
Reviewed-by: Tor Lillqvist <tml@collabora.com>
Tested-by: Tor Lillqvist <tml@collabora.com>
2016-12-27 10:34:20 +00:00
Noel Grandin
f53669cf9d loplugin:unreffun
Change-Id: I06b13a5c035f6ae4dd4b414f49a0987c019feea5
Reviewed-on: https://gerrit.libreoffice.org/32365
Reviewed-by: Tor Lillqvist <tml@collabora.com>
Tested-by: Tor Lillqvist <tml@collabora.com>
2016-12-27 10:26:23 +00:00
Noel Grandin
0caeab803b loplugin:loopvartoosmall
Change-Id: I32f75fac7626b9ae56fa3f898bfa50051a22677f
Reviewed-on: https://gerrit.libreoffice.org/32362
Reviewed-by: Tor Lillqvist <tml@collabora.com>
Tested-by: Tor Lillqvist <tml@collabora.com>
2016-12-27 10:15:38 +00:00
Noel Grandin
d425157f53 loplugin:literaltoboolconversion
Change-Id: Ic38256273a8cad001fff6a3d7148a9b272acfa50
Reviewed-on: https://gerrit.libreoffice.org/32361
Reviewed-by: Tor Lillqvist <tml@collabora.com>
Tested-by: Tor Lillqvist <tml@collabora.com>
2016-12-27 10:14:31 +00:00
Pranav Kant
a6666d373c storage: catch exceptions explicitly when interacting with WOPI host
... and print error in the logs. So that if there is some problem
in the setup and we are not able to interact with WOPI host for some
reason, we print it in the error logs clearly.

Convert to new style logging - LOG_XXX macros.

Change-Id: I53ce4f61136ffd256b0eae8712dc7f22a620e2bf
2016-12-23 15:28:45 +05:30
Noel Grandin
80b0eaa773 loplugin:unnecessaryoverride
Change-Id: Ib077de07e832ae30137f465596961731954d8e62
Reviewed-on: https://gerrit.libreoffice.org/32340
Reviewed-by: Tor Lillqvist <tml@collabora.com>
Tested-by: Tor Lillqvist <tml@collabora.com>
2016-12-22 14:41:10 +00:00
Tor Lillqvist
3d5b9dd573 Typo
Change-Id: I93a9abc63699155b3ac923256d3c86e69e5acd15
2016-12-22 14:48:20 +02:00
Noel Grandin
4199efc91c convert enums to scoped
Change-Id: Ic3d4c09dbcec28b4638bb8888f812f970f40a1c5
Reviewed-on: https://gerrit.libreoffice.org/32331
Reviewed-by: Tor Lillqvist <tml@collabora.com>
Tested-by: Tor Lillqvist <tml@collabora.com>
2016-12-22 09:51:56 +00:00
Ashod Nakashian
70bbc53d86 wsd: don't reuse DocBrokers iterator to insert
Simplifies the code and makes it less error prone.

Also add more logging on modifying DocBrokers.

Change-Id: I861495912eb4994a32b1ccaccc181fb1aad26e1f
Reviewed-on: https://gerrit.libreoffice.org/32295
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-12-21 15:40:45 +00:00
Ashod Nakashian
bc65f8220b wsd: don't poll WS for write to check child alive
The WS could be chocked on write, but we shouldn't
assume the child is dead because of that. We are
only trying to test if the child process is alive
in that helper.

Change-Id: I108a297e43f923cab0dfa30204837dc4df15d3a1
Reviewed-on: https://gerrit.libreoffice.org/32289
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-12-21 15:39:00 +00:00
Ashod Nakashian
e1d5bf4ec2 wsd: no need for first foreslash in local path
Since the local path already ends in foreslash,
no need to keep the on in provided by the client.

Change-Id: Ia2bc24c7faa84509f9ec18deefb14cad2858e856
Reviewed-on: https://gerrit.libreoffice.org/32288
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-12-21 15:01:39 +00:00
Ashod Nakashian
a3de232c7a wsd: FileServer logging updated
Change-Id: Ia797c6c8f9068805d85f066030f8110f0affb7f4
Reviewed-on: https://gerrit.libreoffice.org/32286
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-12-21 15:00:52 +00:00
Tor Lillqvist
07b917f97e Ignore dummy (epoch) timestamps
Change-Id: I745940005f018c43ff83a48199d7945d5e807a8c
2016-12-21 14:06:07 +02:00
Tor Lillqvist
fe7aaafd3e WIP: Check if the document has been modified behind our back
For now, do the check only when a new session connects to the
document, because at that point we fetch the document information (in
separate function for WOPI and local files) and construct the
FileInfo, including timestamp.

For now, just log an ERR message if we notice that the document in its
storage system (WOPI or local file system) has an unexpected last
modified time. What should we do? If we don't have unsaved changes,
most likely we should just silently reload the document and force all
sessions to refresh. But if we have unsaved changes, and the document
has changed underneath, we have a problem.

We need to fetch the timestamp also also after saving ("persisting")
as we can't assume that the clock on the machine running loolwsd and
that of the storage (as reported in the WOPI case in CheckFileInfo)
are in synch. (Assuming separate machines, they certainly won't ever
exactly in synch, but aren't necessarily even just a few seconds apart
(think incorrectly set up timezone etc), so no amount of tolerance in
the comparison would be good enough, because after all, it might be
that in the problematic cases we are looking for the timestamps also
are separated by a quite short time.)

Yes, this means there is a race condition; what if the document is
modified behind out back right after we have persisted it, before we
ask for its timestamp? It would be much better if the persisting
operation atomically also told what the timestamp of the document in
the storage is after persisting, but alas, WOPI doesn't do that.

Rename the DocumentBroker::origDocumentLastModifiedTime field to
_documentLastModifiedTime as that is less misleading. It is not the
"original" document timestamp but the timestamp of the document in its
storage system.

This needs much more work: Ideally the timestamp of the document in
its storage system should be retrieved and checked against the
expected value also before we are about to save it.

But unfortunately experience has shown that the WOPI CheckFileInfo
operation can be expensive, so we'll see what can be done. Ideally
WOPI should contain the optional functionality to return an error if,
when saving a document, its timestamp (and size?) in storage are not
what the saving client expects.

Also add a few FIXME comments.

Change-Id: I5a9b55d4b55a8db0c9ee8638edd368dc0aa325d5
2016-12-21 11:41:08 +02:00
Tor Lillqvist
2f2607dfe9 No reason to keep original _fileInfo forever
The information in StorageBase::_fileInfo is not expensive to
construct. What might be expensive we were doing anyway for each time
a session connects to the document. So just update _fileInfo whenever
we fetch currrent information about the document in its storage, which
is useful, as the timestamp and size after all will change whenever
the document is persisted.

Change-Id: I173394c88b4d6448ad5bf1ab9b41694cffdf1ff4
2016-12-21 10:53:19 +02:00
Tor Lillqvist
1d124f1980 Drop unneeded forward declaration
Change-Id: Iba2fab89780b381ad60a921e4d3fbe80355a8f64
2016-12-21 10:53:19 +02:00
Ashod Nakashian
200bf6f92b wsd: fix compiler warnings of shadowing variables
Change-Id: I3a1344d58b1af11c95accb5f7a9d1c8e5b2d19fb
Reviewed-on: https://gerrit.libreoffice.org/32180
Reviewed-by: Andras Timar <andras.timar@collabora.com>
Tested-by: Andras Timar <andras.timar@collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/32181
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-12-19 13:18:53 +00:00