Commit graph

758 commits

Author SHA1 Message Date
Ashod Nakashian
381d84ea8d wsd: getSteadyClockAsString now includes millis
Change-Id: I1c1e15c5271cd2d9346eaf3a29d11693020e419b
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-02-04 10:26:49 -05:00
Ashod Nakashian
05dc8a0f84 test: improved state-machine helpers
Change-Id: I10c561ae4cf5e4471f1f9eafc9ffbb77badc7284
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-02-04 10:26:49 -05:00
Noel Grandin
0969f25685 make sure modifiedTimeUs calculates with enough precision
otherwise, on some platforms, the calculation might occur with 32-bits, but we really need 64 bits for microseconds.
Also tweak the return type to make sure we use 64 bits.

Signed-off-by: Noel Grandin <noel.grandin@collabora.co.uk>
Change-Id: Ie8b8a49938c7ac2cfe7c5fc1dd6629e6ea347115
2022-01-26 10:23:36 +01:00
Aron Budea
65e3a54857 wsd: Adjust log levels
A non-writable path isn't an error in itself.

The reason why the service tried to write the systemplate,
and the perf implications is worth reporting even on default
log level.

Signed-off-by: Aron Budea <aron.budea@collabora.com>
Change-Id: Ie168875ceb4e501291676a5aa4ddc21b88c5761f
2022-01-23 13:31:17 -05:00
Yunusemre Şentürk
d15c0a6f0f use gmtime_r instead of std::gmtime for thread safe purposes
Change-Id: I3490c1353d9e2eebc3dc856fe5bd4767df4b1bec
Signed-off-by: Yunusemre Şentürk <yunusemre@collabora.com>
2022-01-21 16:51:46 +01:00
Michael Meeks
51a5b129ac fileutil: ubsan - clear state records before stat / lstat.
If these fail, we wstill want something sensible to go on.

Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
Change-Id: Iabd8b60a67808a17767ac63037636e3aadd7be48
2022-01-20 15:46:50 -05:00
Ashod Nakashian
f95ff8205a wsd: test: fail when modified docs are unsaved
Change-Id: I444948ce96ff512491fe72f55a7b5abfcf1dab4e
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
(cherry picked from commit 11dad9c87a979eee0fac9c85ea3387174da61760)
2022-01-11 09:28:03 +01:00
Ashod Nakashian
65d5a4f1a5 wsd: test: add slow save and upload test
Change-Id: I5c7e706a1ded7774c9da4545218ba9fa29fc9d81
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
(cherry picked from commit 29c26c9afee593c20bc72a668ba0c3d5634aa35b)
2022-01-11 09:28:03 +01:00
Ashod Nakashian
cdccf4d820 wsd: test: improved test state machine
This adds a better automatic test state
enum, with support for transitions.

It is intended to be used only in tests,
to simplify the writing of tests around
a state-machine.

Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
(cherry picked from commit bf5e8a2d9f3b2fe99f5b46bcbd4c9e3e28853af5)

Change-Id: I8805dad57ca3c71c26cc30236d4832710e1717f9
2022-01-11 09:28:03 +01:00
Ashod Nakashian
aad22ee83c wsd: test: better logging
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
(cherry picked from commit ec3613ba2df43cffe6baafafa41e5337a43070aa)

Change-Id: I5e245d0ac5c185943586d6aec651f606f8e23bb8
2022-01-11 09:28:03 +01:00
Michael Meeks
15dc307107 signal activity: add some more helpful call sites.
Based on previous crashes, it is useful to have more granularity
on what happened last.

Change-Id: If18a3a4d7817be23a6f8aadd301827a8e1bc007e
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2022-01-10 13:03:37 +00:00
Michael Meeks
9354fc829d signal activity dumping; overdue cleanup / re-factor.
Change-Id: I7cb3047488f6daffbb5de285dfc5631c4dd89c8e
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2022-01-10 13:03:37 +00:00
Michael Meeks
bfb7104bdd Avoid (erroneous) warnings on iOS.
Change-Id: Ibeb44383622b8471abaebfb6ce1d503e264963c4
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2022-01-10 13:03:37 +00:00
Pranam Lashkari
75f37bb1df freemium: added option to make freemium user read only
Signed-off-by: Pranam Lashkari <lpranam@collabora.com>
Change-Id: I4dadb535e722cbeaacf177b30247899795d048f9
2021-12-20 12:03:51 +01:00
Miklos Vajna
15e08d3709 common: introduce COOLProtocol::getNonNegTokenInteger()
To simplify code that wants to extract a non-negative number from a
token value. See
<https://github.com/CollaboraOnline/online/pull/3788#pullrequestreview-826099897>.

Signed-off-by: Miklos Vajna <vmiklos@collabora.com>
Change-Id: I389dfa1a2838e501fc308dbfd7927b142a361922
2021-12-17 02:52:37 -05:00
Luboš Luňák
a5de33496c make stringifyHexLine() simply work on std::string
Trying to construct a string using sprintf() and std::stringstream
is unnecessarily complicated for something as simple as this,
and it shows up in my profiling. This commit makes the hex values
change to uppercase because that's what hexFromByte() returns,
but I don't think it matters.

Signed-off-by: Luboš Luňák <l.lunak@collabora.com>
Change-Id: I31c7b8e7cf4c2a495eca0bf03ae4cab53b26a04b
2021-12-07 13:44:40 +01:00
Pranam Lashkari
2ac0d01461 added method to get inode number from Stat object
Signed-off-by: Pranam Lashkari <lpranam@collabora.com>
Change-Id: I110f5bd0908a1c457af65429e377425e2055290a
2021-11-25 09:59:11 +02:00
Ashod Nakashian
587d160146 wsd: Termination flag requires having ShutdownRequested
Certain parts of the code assume ShutdownRequested is set
when relying on the Termination flag. This is because
they serve as degrees not as independent flags.

The Termination flag is basically a more impatient
ShutdownRequested flag. It is used to forcefully
and immediately terminate. It is not designed to be
used independently from ShutdownRequested.

This pair is a good candidate for unifying as a single enum.

Change-Id: I8e3913a1959868197d8c5a059e89cbdbc6cef070
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-11-23 09:31:46 +01:00
Ashod Nakashian
4c884a003a wsd: test: safer assertions without side-effects
The default behavior of LOK_ASSERT is that of assert,
which is to evaluate the argument(s) multiple times.

This obviously has side-effects, and is therefore
problematic. It seems it's not safe to assume all
uses of assertion is aware of this side-effect.

To prevent side-effect issues, now the LOK_ASSERT
family of macros evaluate the arguments only once.

Change-Id: I5827264ca7fcd77a7d7f5ad787353c6a7beb4fab
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-11-23 09:31:46 +01:00
Andras Timar
f07ff8c7e0 rename: remaining lool->cool changes
Signed-off-by: Andras Timar <andras.timar@collabora.com>
Change-Id: Ib7d4e804bebe52dead8d53b0e0bbaed0f08bf3d0
2021-11-18 14:14:11 +01:00
Mert Tumer
c9a4d2f6f3 rename: loolmount -> coolmount
Signed-off-by: Mert Tumer <mert.tumer@collabora.com>
Change-Id: Ic025c5a76c6f27cdf1a6267f24cf8052733f1f24
2021-11-17 21:51:05 +01:00
Henry Castro
23afa3843c kit: rename 'lool' -> 'cool'
Change-Id: I4198570d9940a028f1b4d84666a80516174c2f7a
Signed-off-by: Henry Castro <hcastro@collabora.com>
2021-11-17 09:18:38 +01:00
Henry Castro
85ba63ddce misc: more renames 'lool' -> 'cool'
Change-Id: Ic9fbae88d92921b9081e7067347852e385f45af3
Signed-off-by: Henry Castro <hcastro@collabora.com>
2021-11-17 09:17:46 +01:00
Mert Tumer
81f61c8073 rename: loolforkit -> coolforkit
Signed-off-by: Mert Tumer <mert.tumer@collabora.com>
Change-Id: I1de688dce4b068bff35451604486b72ecc8c91d4
2021-11-16 21:02:24 +01:00
Andras Timar
49f6f5cb54 Write timestamps to log in local time and add time zone differential
Signed-off-by: Andras Timar <andras.timar@collabora.com>
Change-Id: I895bff775b36db48fa88f02c8b81841567e62271
2021-11-16 16:38:00 +01:00
Tor Lillqvist
09942e76c5 Strip shell string syntax quotes from the PRETTY_NAME line in /etc/os-release
Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: I5cb6f294d6d4bf62c2e16fc88bc6195695595ba5
2021-11-16 13:33:26 +02:00
Pranam Lashkari
f84df1161c quarantine: create hard links for quarantining when file is saved
number of versions to maintain per file can be specified in loolwsd.xml
on exceeding specified quarantine size oldest file(s) is deleted

Signed-off-by: Pranam Lashkari <lpranam@collabora.com>
Change-Id: I3ca55b9ab29a82988f19fe0acd43e0fae2c2a423
2021-11-01 17:21:51 +02:00
Rash419
d9795fff2e wsd: use the WOPI protocol for local files instead of the current "local storage" (in debug builds)
Signed-off-by: Rash419 <rashesh.padia@collabora.com>
Change-Id: I9e21df4c5b611ca9989915180310f0991ed28725
2021-11-01 15:45:14 +01:00
Hugo Peixoto
b2abb5e4aa Use tokens.equals() instead of tokens[] ==
This prevents additional strings from being allocated.

Signed-off-by: Hugo Peixoto <hugo.peixoto@gmail.com>
Change-Id: I84b1e5cf4d11bf8512febe068b3097770b63dc5c
2021-10-21 13:36:57 +02:00
Pranam Lashkari
f88a38a4e7 LOK: unifying the Freemium and uno command hiding APIs part 2
* replace vector with unordered_set
* avoid sending multiple blocking messages

Signed-off-by: Pranam Lashkari <lpranam@collabora.com>
Change-Id: I2f714e4f2797ade4ac9d5b4f824855bba31031c4
2021-10-21 12:28:13 +03:00
Pranam Lashkari
88601440d0 introduce way to hide/restrict uno commands
Signed-off-by: Pranam Lashkari <lpranam@collabora.com>
Change-Id: I1225190a67f726832e5b38a7c3f690b51c1385f3
2021-10-21 12:28:13 +03:00
Pranam Lashkari
f02a0a1447 freemium: renamed Freemium namespace to CommandControl
also renamed freemium files accordingly

Signed-off-by: Pranam Lashkari <lpranam@collabora.com>
Change-Id: Id33b8a1d1a2a8725bfa6e7b7c562430ea126993c
2021-10-21 12:28:13 +03:00
Hugo Peixoto
2bdb7ed56f Fix bug in StringVector::startsWith and add tests
The startsWith method that receives a StringToken was doing a bounds
check on the wrong parameter. This caused most calls to return false.

This commit adds some tests to both versions of StringVector::startsWith.

Signed-off-by: Hugo Peixoto <hugo.peixoto@gmail.com>
Change-Id: Icd4c648d681723ac66dba3c6a42ab7920850c619
2021-10-18 08:18:14 +02:00
Hugo Peixoto
7bf0ead625 Optimize startsWith calls on StringVector elements
There was a pattern of calling Util::startsWith on StringVector
elements:

- Util::startsWith(tokens[0], "boo")
- Util::startsWith(tokens.getParam(token), "boo")

These two expressions would cause a new string to be allocated and
immediately released. To optimize this, a StringVector::startsWith
method is introduced.

This method works by calling compare directly on the underlying
StringVector string, avoiding creating a temporary string.

Signed-off-by: Hugo Peixoto <hugo.peixoto@gmail.com>
Change-Id: I6f27d5bb13783f39c7d4ce0644a11e57b0071244
2021-10-15 13:58:26 +02:00
Mike Kaganski
ad2cbb4a9d JSON escaping: Have some initial extra space
Signed-off-by: Mike Kaganski <mike.kaganski@collabora.com>
Change-Id: I65421d8eaa69f42bd3557f4f221226f8fd4234ec
2021-10-14 13:41:53 +01:00
Mike Kaganski
d1bc6911b5 Escape strings in JSON
This should take care e.g. for SharePoint user IDs, which have the
form of "domain\username", and the backslash must be escaped.

Signed-off-by: Mike Kaganski <mike.kaganski@collabora.com>
Change-Id: I75936070ad1661dc9b03e05a19b64159b0758018
2021-10-13 16:29:50 +01:00
Mike Kaganski
ee44f755dc Drop circular inclusion of the header itself
Signed-off-by: Mike Kaganski <mike.kaganski@collabora.com>
Change-Id: I7518a9d1729d35b85592d474ba7cdfe9065e238c
2021-10-13 14:56:33 +01:00
Michael Meeks
b043b6213d Move LOOLWebSocket into test/ - where it can be slowly removed.
Change-Id: I388690261d323377648a1502b927e73f862ad802
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2021-10-11 13:40:20 +01:00
Ashod Nakashian
88d5491108 wsd: allow shutting down during startup
During startup we wait for extended time until
a child process is up and running. In case this
takes a long time, or indeed if forking permanently
fails, we simply don't respond to shutdown requests.

This patch makes it possible to wait for about 20
seconds at a time for a child. This way on average
we will exit the process within about 10 seconds,
assuming we are blocked waiting for a child that
will never spawn.

Change-Id: I4409cbc60aa3c7bd30970d4638c820bc581b65ba
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
(cherry picked from commit 6ed8b4bb1a6532d947a6bb00f936183767b54a80)
2021-10-06 12:28:06 -04:00
Ashod Nakashian
31913d56c2 wsd: avoid misbehaving library cleanup
We cleanup all the relevant objects and instances
before exiting the wsd process, however some libraries
may still misbehave and deadlock during this final
cleanup stage. Notably, Poco has been observed to
deadlock during cleaning up the SSL context static
instance (used for the singleton) by waiting on
its internal mutex indefinitely.

Here we exit forcefully after cleaning up.

Change-Id: I76621c1de7f9a4ff918624b3019b9869c08787c2
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
(cherry picked from commit f776d87cf595bab084e53202777251a38e482147)
2021-10-06 12:28:06 -04:00
Miklos Vajna
803e9fef28 common: fix leftover debug output
Assuming that the intention is to output a pair of strings on start and
a pair of string on finish.

Signed-off-by: Miklos Vajna <vmiklos@collabora.com>
Change-Id: I1ab3b03c353a8d0875e2fee451ca34965fc3038e
2021-10-05 08:23:46 +02:00
Michael Meeks
48b943e85b Notify of completing sleeping to wait for a debugger.
Change-Id: I64e7d509fa9a5e299942a0a5ec05c0b7fd7344a2
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2021-10-02 21:24:15 +01:00
Szymon Kłos
b05c6e86a2 Handle UnitType::Tool in global instance getters and setters
Signed-off-by: Szymon Kłos <szymon.klos@collabora.com>
Change-Id: I40bf3ea69d1722e652f9d2f64d2496557dc221e1
2021-09-28 14:23:34 +02:00
Szymon Kłos
78f68fa7ef Cleanup in Unit* subclasses
- we cannot get rid of UnitBase::get() which returns the last
  set Unit class because we use it for example in WebSocketHandler
  where we don't know which kind of test we run

- free memory correctly and reset global variables for subclasses

- setup _type member variable on construction

Signed-off-by: Szymon Kłos <szymon.klos@collabora.com>
Change-Id: Ic61b88785bff7de63b11ce2046eecc993c3ddeaf
2021-09-22 20:31:35 +02:00
Szymon Kłos
029d4195ad android fix: use correct instance for Unit classes getter
On android we had issue with not working release builds
(worked when optimization flag -O0 was used for Unit.cpp).

Global which stored instance of UnitBase subtype was returned
after cast to a choosen subtype. Unfortunately in case when
android didn't work UnitWSD was returned in UnitKit::get() !

Thich patch makes us sure we don't cast to not-correct type.

Signed-off-by: Szymon Kłos <szymon.klos@collabora.com>
Change-Id: I98e91d8fa82a8e81a8f7cee2fe3109b67c4f64f7
2021-09-22 20:31:35 +02:00
Michael Meeks
b0cd66feae Enable wait for attaching a debugger in debug builds by default.
Hopefully helps to hunt segv's more effectively in development.

Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
Change-Id: Ife800f9902fe8d95711b3b14867ee21bb3c3f21b
2021-09-13 14:54:00 +01:00
Ashod Nakashian
28687c0bbf wsd: hexifying helpers and tests
Change-Id: I2f7fa4e6ade3361db612dbb9aa68e4d28b3905d9
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
(cherry picked from commit 348ca073abe2c980f746324589bc58bf5550dc4b)
2021-09-13 09:40:09 -04:00
Tor Lillqvist
84d9a73676 Stop using .bmp files for tiles on iOS
We don't want leaking tiles to take up valuable space on the device.
Not even just while a document is open.

Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: I761c2bb2ab121ee76b5535e96bd5702d0fce6856
2021-09-07 09:59:57 +03:00
Tor Lillqvist
c77b7e7dfd Actually do remove leftover tiles in the iOS app
Fix silly mistake in my previous commit. Had put code in #if 0 that
should be in #ifdef IOS.

Change-Id: I72f4dc3867bd070a01a4ba5625baba0eea3c2d73
Signed-off-by: Tor Lillqvist <tml@collabora.com>
2021-09-01 15:32:42 +03:00
Tor Lillqvist
6d2a6e110c Remove leftover tiles in the iOS app already when the document is closed
Normally (ideally), tiles (.bmp files) are removed as soon as the JS
has displayed them. But occasionally something goes wrong and they are
left behind. (For instance, it seems to happen if the user closes the
document immediately when it shows up.)

Do not leave them on disk until the app starts the next time.

Change-Id: I0c764280a69a16ad3b7b67c329832fd5331c2e1e
Signed-off-by: Tor Lillqvist <tml@collabora.com>
2021-09-01 13:32:23 +03:00
Pranam Lashkari
daef96dcb3 freemium: corrected typos
Signed-off-by: Pranam Lashkari <lpranam@collabora.com>
Change-Id: If21f4471b3ad4b20f049e2e9f2330e31989ead0b
2021-09-01 09:44:19 +02:00
Michael Meeks
09a2237372 Always lock the work queue.
The worker threads can be running and have not yet responded
to the last _cond.wait() by the time we start compressing again
- at least under valgrind:

loolforkit-nocaps: ./common/RenderTiles.hpp:304: void ThreadPool::run(): Assertion `_working == 0' failed.
==240379== Process terminating with default action of signal 6 (SIGABRT): dumping core
==240379==    at 0x5505322: raise (raise.c:50)
==240379==    by 0x54EE863: abort (abort.c:79)
==240379==    by 0x54EE748: __assert_fail_base.cold (assert.c:92)
==240379==    by 0x54FD9D5: __assert_fail (assert.c:101)
==240379==    by 0x5886BB: ThreadPool::run() (RenderTiles.hpp:304)
==240379==    by 0x56DC02: RenderTiles::doRender(std::shared_ptr<lok::Document>, TileCombined&, PngCache&, ThreadPool&, bool, std::function<void (unsigned char*, int, int, unsigned long, unsigned long, int, int, LibreOfficeKitTileMode)> const&, std::function<void (char const*, unsigned long)> const&) (RenderTiles.hpp:711)
==240379==    by 0x5A0104: Document::renderTiles(TileCombined&, bool) (Kit.cpp:762)
==240379==    by 0x59CF1A: Document::renderCombinedTiles(StringVector const&) (Kit.cpp:719)
==240379==    by 0x59AEC8: Document::drainQueue(std::chrono::time_point<std::chrono::_V2::steady_clock, std::chrono::duration<long, std::ratio<1l, 1000000000l> > > const&) (Kit.cpp:1570)

That means our queue starts processing work as we do the unlocked
queue push - causing some potential badness.

Change-Id: Ib0578dac009376c0676da73a8c1d8960304dc072
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2021-09-01 07:14:44 +01:00
Michael Meeks
85ae2d668a Get argument count right to spawn.
Why pass a dozen empty arguments each time: someone bitten
again by the default vector constructor.

Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
Change-Id: I31bc6f23f0b5d7352b85d3df4b7b5298199044a1
2021-09-01 07:14:44 +01:00
Michael Meeks
d1ae5a8fb7 Valgrind support for tracing the forkit & kits.
Change-Id: Ie9dd69598bd408ae1994d8cdd6f886224890ad23
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2021-09-01 07:14:44 +01:00
NickWingate
6eb93a2330 Assign _firstLine before _data is changed
_firstLine must be assigned before _data is
changed, as it is used to check _data's
first line hasn't changed

Signed-off-by: NickWingate <nicholas.wingate03@gmail.com>
Change-Id: I79dfd0a64d53fc8503709015bbe7ab6875a58204
2021-08-30 21:07:59 +01:00
NickWingate
e72b073090 Make firstLine() return reference not value
And make return const to prevent _firstLine being
mutable.

Signed-off-by: NickWingate <nicholas.wingate03@gmail.com>
Change-Id: I1a6e391cd128704b67ec5cc99a4ed4d105f64e29
2021-08-30 21:07:59 +01:00
NickWingate
cc58c79136 Remove _firstLine assignment from constructor
_firstLine is no assigned when firstLine() is called
and _firstLine is empty.

Signed-off-by: NickWingate <nicholas.wingate03@gmail.com>
Change-Id: Ie6d86abd1f9db7a4f05e95e41f6b791f5923729f
2021-08-30 21:07:59 +01:00
Tor Lillqvist
65b8001d73 Remove more leftover files taking space in the iOS app
Remove the app's copy of the document after core has saved it and we
have stored the edited version at its real location.

Remove possible leftover tile bitmaps when the app starts.

Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: Ibc41be38c2cfb689c532640d148116bc06a248ab
2021-08-24 18:02:40 +03:00
Michael Meeks
ebc0d0aaf4 Unit: add new 'Tool' type of unit test handler.
Dummy, but useful for eg. fuzzing.

Change-Id: I9819cda898a7bf1c0fba3d1fccbb63b16955f01d
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2021-08-17 11:07:21 +01:00
Miklos Vajna
3186597097 log: avoid logging after shutdown on all log levels
This can happen on an assertion failure, and causes noise while looking
for real memory errors.

Also disable an unstable test, it's not clear that it passes depending
on how loaded the machine is (just increasing timeouts doesn't seem to
help).

Signed-off-by: Miklos Vajna <vmiklos@collabora.com>
Change-Id: I049bd0a06f41e2d43702ec12a2c35944bc5200d8
2021-08-12 10:02:48 +02:00
Pranam Lashkari
dcd6795e57 use pragma instead of header guards in freemium header files
Signed-off-by: Pranam Lashkari <lpranam@collabora.com>
Change-Id: I5b55c2de4a2467503108e4172de84a27e207ba3c
2021-08-06 17:21:04 +02:00
Tor Lillqvist
17e07847cf Don't let other clients prevent textinput and removetextcontext merging
Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: Iff95e9624b687938b83d1666059efbffb32c2b54
2021-07-22 13:41:53 +03:00
Tor Lillqvist
07046e0a35 Merge sequential 'removetextcontext' messages when possible
Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: I53529bbb1fe45e74fde6fa6489b1580521f23d2d
2021-07-22 13:41:53 +03:00
Tor Lillqvist
65a42ecd2e Merge textinput messages when possible
When adding a freshly arrived textinput message to the queue, check if
there is an outstanding one queued, and if so, remove it, and prefix
its text to the text in the fresh message. Don't do this if there are
messages inbetween that affect what the textinput messages do
semantically, including textinput messages from other clients.

Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: I712eebfb10d410bb424157c8df46b2848a236d88
2021-07-22 13:41:53 +03:00
Tor Lillqvist
8b6ee5b8bf No need for the template class MessageQueueBase
Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: Ie007344f9a0ffe7fdf767cb9e9069db99aa224b9
2021-07-21 09:54:28 +03:00
Szymon Kłos
9cbe11699f Don't stop loolwsd when logger already exists
there was a case detected by tinderbox when logger
somehow existed already what closed the app:

unit-wopi-versionrestore:

Test unit-wopi-versionrestore FAILED.
-25786 2021-07-19 08:37:08.429079 [ loolwsd ] TST  UnitWOPIVersionRestore (+0ms): WopiTestServer created for []| WopiTestServer.hpp:71
-25786 2021-07-19 08:37:08.429160 [ loolwsd ] TST  UnitWOPIVersionRestore (+0ms): setFileContent: [Hello, world]| WopiTestServer.hpp:57
wsd-25786-25789 2021-07-19 08:37:08.430827 [ UnitWOPIVersionRestore ] INF  Thread 25789 (7fb8e5063700) of process 25786 formerly unnamed is now called [UnitWOPIVersionRestore]| common/Util.cpp:572
wsd-25786-25789 2021-07-19 08:37:08.430954 [ UnitWOPIVersionRestore ] INF  Starting polling thread [UnitWOPIVersionRestore] with thread affinity set to 0x7fb8e5063700.| net/Socket.cpp:310
Failed to initialize LOOLWSD: Exists
wsd-25786-25786 2021-07-19 08:37:08.438294 [ loolwsd ] FTL  Failed to initialize LOOLWSD: Exists| wsd/LOOLWSD.hpp:469
Exists

Signed-off-by: Szymon Kłos <szymon.klos@collabora.com>
Change-Id: I489fab82ca604de76d13bc47674ee4f02e800f79
2021-07-21 08:49:45 +02:00
Pranam Lashkari
e02e1df76d Introduce Freemium options
Signed-off-by: Pranam Lashkari <lpranam@collabora.com>
Change-Id: Ib6b68ff74839cf84f2d8c8cfb7d380be9209f923
2021-07-20 14:41:18 +05:30
Miklos Vajna
f569c2b496 log: don't try to get the channel of a non-existing logger
Signed-off-by: Miklos Vajna <vmiklos@collabora.com>
Change-Id: Ic08043dac01b682184ff440b2f7d7f4f3df9522e
2021-07-15 09:01:16 +02:00
Gopi Krishna Menon
9d86193972 Log Last Uno 4 Commands During a Fatal Crash
Records the uno commands from different instances of ChildSession and
dumps the last 4 uno commands into the crashlog during a fatal crash

Signed-off-by: Gopi Krishna Menon <krishnagopi487.github@outlook.com>
Change-Id: I838f71769dc08df7076c040f3d72c15f7607e9d3
2021-07-13 19:48:21 +03:00
Tor Lillqvist
bd0c225c9f Revert "Make it possible to generate Trace Events already when loading the document"
Makes unit-rendering-options fail reliably.

This reverts commit 175c9c5b2a.

Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: Id05c911991baaae0dbc52678a192fc01639352e0
2021-07-07 12:38:11 +03:00
Tor Lillqvist
175c9c5b2a Make it possible to generate Trace Events already when loading the document
By passing a traceevent=yes query parameter in the URL. Note that if
Trace Event generation is not enabled in loolwsd.xml this will have no
effect.

It is a bit silly to notice this query parameter only in loleaflet and
then send the information back to the server. Would be better if the
server noticed it itself before sending the URL to loleaflet.

While at it, let's not bother ever enabling Trace Event generation in
the WSD process. That is not what we are interested in.

Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: I985bfd1e2dbd14aa5a55b386b4762fb64bcb4008
2021-07-07 09:28:02 +03:00
Tor Lillqvist
4f0f7d6123 Avoid assertion failure if toggling Trace Event generation back and forth
Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: Ie6b7144ecf16faa9d22e7d87801d9dbe9b97d3fc
2021-06-30 12:40:08 +03:00
Tor Lillqvist
64675d2926 Add ProfileZone to encodeSubBufferToPNG
Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: I7363ea929ba703ce34a5c2411687f120ac5ba59e
2021-06-22 16:43:40 +03:00
Tor Lillqvist
1a2b29d3d5 Add function to check if config has been initialized
Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: Ieadcb9ad6d34bb6cf789d29896889601baf88a33
2021-06-21 12:43:17 +03:00
Tor Lillqvist
4c68a97ce5 Re-factor Trace Event stuff for improved functionality and thread safety
Write to the Trace Event JSON file in just one place, protected by a
mutex.

Handle metadata events separately. We want them to propagate to the
output if Event Trace generation is just enabled, regardless whether
it has been turned on or not.

We can send the metadata for the Kit process only after we have opened
the docuemnt as sending a Trace Event to WSD uses the (singleton)
Document object in Kit.

Introduce some new functions for the above and adapt callers
appropriately.

Generate a Complete event for the handling of one image tile, from
setting the src attribute of the Image object to finishing the onload
function.

Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: I5978e0fb2495e0d2dc479bf861eb4ac7da03fa50
2021-06-21 12:43:17 +03:00
Tor Lillqvist
b2f4776781 No need to add the thread name to the args of Trace Events now
We automatically emit metadata events that identify threads.

Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: Icb25b5cfc29b28ba7112ca72de56dbb697c8dd5a
2021-06-21 12:43:17 +03:00
Tor Lillqvist
d6569159b7 Output a Trace Event metadata event identifying each named thread
Move the generic dummy implementation of
TraceEvent::emitOneRecording() to a source file of its own. (That is
the one which is used in test and tool executables.)

Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: I81cab07e5a6852b42d278a5446c13c3825cf546e
2021-06-21 12:43:17 +03:00
Ashod Nakashian
f2f713cdaf wsd: rename file after saving to support async uploading
To avoid writing (saving) while reading (uploading) or
any other undesirable racse on the document file,
we atomically rename the file after saving on disk
to pass ownership.

After saving in Core, we rename the document in the
jail to .upload (by appending it). DocumentBroker
looks for the file with that extension and atomically
renames it to .uploading (by appening the 'ing' suffix).
This way, the Kit only renames from the original to
.upload and DocBroker renames only .upload to .uploading.
This guarantees that we never rename the same file
concurrently.

Uploading decision is strictly based on the modified
timestamp of the .uploading file, compared to the
timestamp of the last file we uploaded successfully.

Change-Id: I03520cd8c87605f6dad417e7a978204f76fc0c38
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-06-19 17:44:59 -04:00
Ashod Nakashian
0fa12e8e76 wsd: add hexify-data utility
Using for fuzzing and integration testing.

With unit-tests.

Change-Id: I23f8c619e239310d92c74c4d5e4157afb52a5e56
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-06-13 21:57:43 -04:00
Tor Lillqvist
dcf9d9f12b Log also the average tile PNG size and the average compression ratio
Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: I77fb1ae0e9ef892b23212222b44dc3dc522c7ce3
2021-06-11 09:42:17 +03:00
Henry Castro
371c394d7c Revert "common: add tag string to extract backtrace logs"
It was a request an approved by @kendy despite the signal
handler limitations. After several tries, we were blind
when we introduce the commit using the heap.

This reverts commit 9720eb0f81.
2021-06-03 11:10:08 -04:00
Tor Lillqvist
0f156aefec Include the thread name in the Trace Events emitted from the C++ code, too
Make sure to avoid most of the code path through createArgsString() if
Trace Event generation is not turned on.

Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: Id86b2c9b4ded9d402647b7a12b9290d0122ba2aa
2021-06-02 10:18:24 +03:00
Tor Lillqvist
8cef48a0fa Introduce a generic TraceEvent class and instant events here, too
Modelled on how it is done in core. ProfileZone is derived from
NamedEvent which is derived from TraceEvent. Here we don't keep any
separate ProfileZone.hpp, though.

This was needed to introduce generation of "instant" events here, too.

Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: I6583134e96001641c50339deb4197fca6ab7d5d5
2021-06-02 09:04:21 +03:00
Tor Lillqvist
b7ca93a41a Add the possibilty to set a thread-local logging level
Add a way to set it from the client.

For now, in the Help > About dialog, the L key toggges the logging
level between the default (whatever is set in loolwsd.xml or on the
loolwsd command line) and the maximum a client is allowed to set
(which also can be set in loolwsd.xml or on the loolwsd command line).

Also while at it, uncouple the toggling of the Trace Event generation
from the triple-click tha toggles tile debugging. It is now on the T
key.

Also swap the meaning of "min" and "max" for the logging levels. Even
if the Poco::Message::Priority values are such that the less urgent
priorities have a numerbcally higher value, conceptually it is more
clear to say the more urgent priorities (levels) are "higher".

Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: I5383b16ead7d2d378901525eb0d16513d88f045e
2021-05-31 10:56:19 +03:00
Tor Lillqvist
dec5d7f127 Slight renaming to make names match functionality
The "StaticNameHelper" was more than just related to a "name", so call
it StaticHelper instead. And why call the variable of that type
"Source"?

Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: I099b326cc731e7fb4c96ead9ec19143257090cb1
2021-05-31 10:56:19 +03:00
Tor Lillqvist
2398c792cb No Hungarian notation please
I had accidentally used core naming conventions for ProfileZone.

Change-Id: If10eceb7a5a29d26662d5b21a9289681d814a12e
Signed-off-by: Tor Lillqvist <tml@collabora.com>
2021-05-31 10:56:19 +03:00
Tor Lillqvist
929e466c91 Re-work the ProfileZone implementation here
Don't bother collecting them into a vector, like in core. Instead,
just call a static member function ProfileZone::addOneRecording() for
each Event Trace object (string) to be emitted. That function then
needs to be implemented separately in each executable. In WSD it logs
the object to the Event Trace file. In Kit it sends it to WSD for
logging. In Unit tests we use a dummy implementation.

(If Event Trace logging is not enabled at all in loolwsd.xml (the
default), nothing is done, of course.)

When receiving the "traceeventrecording start" or "traceeventrecording
stop" message from the client, turn ProfileZone recoring on or off in
the WSD and Kit process. (Probably in WSD the flag should be
per-client.)

Change-Id: Ie1127d65dd44ed77e7eeab4b0f0a90cce95dc4a2
Signed-off-by: Tor Lillqvist <tml@collabora.com>
2021-05-31 10:56:19 +03:00
Tor Lillqvist
b265586dda Add the possibility to have arbitrary "arguments" in a ProfileZone object
Note that the C++ ProfileZone class here in Online is totally separate
from the comphelper::ProfileZone in core (which is now derived from
the more generic comphelper::TraceEvent class there).

Also note that this is work in progress and I know that there isn't
any code yet to write out the collected information from this C++
ProfileZone stuff here in Online. Which is why we don't actually have
any ProfileZone variables yet sprinkled through the code. That is
upcoming.

And finally, note that the Trace Event stuff in loleaflet also is
unrelated.

Change-Id: I8765d6dbc1d5108d9d1042781644cbee2419cd9d
Signed-off-by: Tor Lillqvist <tml@collabora.com>
2021-05-24 16:49:46 +03:00
Tor Lillqvist
73943230d2 Fix build for iOS
Change-Id: I774e8802d959eefecd9863edd693f26f0fd1d863
Signed-off-by: Tor Lillqvist <tml@collabora.com>
2021-05-19 13:33:26 +03:00
Tor Lillqvist
d5ded73b11 Fix FreeBSD compilation error
Change-Id: I0201c8213c9593f225c0aab7c4e95b06bd6a22ec
Signed-off-by: Tor Lillqvist <tml@collabora.com>
2021-05-19 13:33:26 +03:00
Gökhan Karabulut
7f736a9bc4 Improve state dump
Add `dumpState` methods to `TileQueue`, `PngCache`, `ThreadPool` classes
and call them from Document::dumpState method within kit.Kit.cpp.
Because `dumpState` method of `_websocketHandler` is protected,
currently we can't dump its internals.

Also dump the other members of the `Document` class. Note that as
`_lastMemStatsTime` is never used, we don't dump it. It seems we could
simply delete it.

Signed-off-by: Gökhan Karabulut <gokhanettin@gmail.com>
Change-Id: Ia89b7fff41eaf475c7a09a644c0eb523b72cf97d
2021-05-13 09:29:35 +01:00
Ashod Nakashian
f6da8d664c wsd: create the unittest SocketPoll thread only when testing
Change-Id: I901ef4722182dd44406c35528c7642414f680814
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-05-06 22:14:51 -04:00
Henry Castro
ae76450398 common: revisit log messages misc files
LOG_FTL = abnormal, crash, denied service
LOG_ERR = load, save, session, connection, wrong parameters
other cases LOG_WRN, LOG_INF

Change-Id: I15bc840f5a6eaf9a74a1ee1caa57d447baa2afce
Signed-off-by: Henry Castro <hcastro@collabora.com>
2021-05-05 13:50:41 -04:00
Michael Meeks
d387700914 Message: don't generate and allocate abbreviations just for trace logging.
Also avoid generating abbreviations in various message handling loops
unless debugging is enabled.

Change-Id: I22f4929b0bfd4da36917db6882bb2f5f5be02780
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2021-05-05 09:40:10 +01:00
Michael Meeks
5c345a1d14 Message: cleanup message parsing of payloads.
Change-Id: Id11a702590539ff4f20fa56272beeb6d91b9e7bd
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2021-05-05 02:51:54 +01:00
Gleb Popov
53e1c0250b Use Util::getThreadId() instead of Linux system call.
Signed-off-by: Gleb Popov <6yearold@gmail.com>
Change-Id: I5cab82f0d869cc9f2ea97ac9320d8f4bbf466c37
2021-05-04 15:40:50 +01:00
Tor Lillqvist
9ef32a3e38 Similar improvements to the ProfileZone here as to that in core
Perhaps we should use the exact same code in both core and online? But
that would be a bit tedious as core needs to be cross-platform (and
thus we use things like osl_getSystemTime and osl_getProcessInfo in
its version) while online is Linux-only.

Also imporve the test for it.

Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: I0bc9dca71dc4489bd1671e0dae1e582990a8f8b4
2021-05-03 16:09:35 +03:00
Tor Lillqvist
e7ed4e11cf Add a ProfileZone implementation here, too
Compiled but not yet used.

Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: I3b85696ca6076e42d16e710b49bfd37bac342ec8
Signed-off-by: Tor Lillqvist <tml@collabora.com>
2021-05-03 16:09:35 +03:00
merttumer
5742acd87c android: Fix build fail and crash on doc load
Signed-off-by: merttumer <mert.tumer@collabora.com>
Change-Id: Id998e2bdf7051d54784543015c7d34c0bdd64543
2021-05-02 21:47:37 -07:00
Ashod Nakashian
5c84542c7d wsd: test: log poco exceptions
While Poco::Exception inherits from std::exception,
it's what() member returns simply the name of the
exception, which is hardly useful without the message.
Therefore, we are forced to log it's displayText()
member for the full error message.

Change-Id: I650614a9b4b3bb1b2e31841c37250a2a069e6b77
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-05-02 22:35:39 -04:00