Commit graph

179 commits

Author SHA1 Message Date
Jan Holesovsky
f76b36193d android: #if(n)def MOBILEAPP -> #if (!)MOBILEAPP for better reliability.
Change-Id: I5f9c9420b6c83601db1c8fdba4ae5a10b17b2107
2019-02-12 12:20:11 +01:00
Michael Meeks
d00aa78c9b Don't name parameter after a local method.
Change-Id: I06929d23009b851cf3fb20da5bfe66d9795dcdd9
2018-11-07 17:37:25 +00:00
Michael Meeks
738abc1de7 Respond to SSL/TLS over http - when we don't expect it.
Change-Id: I48c7607cd4e1416fb4ac28c552c2cd96b51d60a6
2018-11-07 17:36:18 +00:00
Tor Lillqvist
9fec3b0e27 Handle EOF case (when fakeSocketAvailableDataLength() returns 0) 2018-10-30 00:47:21 +02:00
Miklos Vajna
d1e183f20d SocketPoll: make members private
All these protected members are unused by child classes, except read
access to a single member.
2018-10-29 09:06:33 +01:00
Miklos Vajna
5167cf9f58 StreamSocket: make members private
Only a single member needed a setter, otherwise getters were enough.
2018-10-26 09:07:30 +02:00
Miklos Vajna
4724aa0cf7 Socket: do what the TODO says
Drop the list of friends and just add getters for the relevant
members.
2018-10-25 16:39:02 +02:00
Tor Lillqvist
d6d0c3e8a3 As far as I see, no getPollEvents() implementation will ever return negative
In 1c7f94045a that introduced
DelaySocket, its getPollEvents() could indeed return -1, but that was
removed later.

Change-Id: Ie3a7e01b7b9a7517d97f6ed3cc6d96bdb3313969
Reviewed-on: https://gerrit.libreoffice.org/61990
Reviewed-by: Tor Lillqvist <tml@collabora.com>
Tested-by: Tor Lillqvist <tml@collabora.com>
2018-10-19 13:41:18 +02:00
Tor Lillqvist
05c2782a81 Empty out _newCallbacks when stopping a SocketPoll in the MOBILEAPP case
The wakeup() call in SocketPoll::stop() doesn't always (or ever?)
actually cause the wakeup code to be invoked and callbacks called
right after, and we don't want to risk the leftover callbacks being
invoked when the same SocketPoll object is started again. (This did
actually happen.)

In a normal Online, this is not a problem, as SocketPolls aren't
reused. One document per kit process, a separate kit process for each
document. Not so in a mobile app, there we have just one process that
handles document after document as the user closes one, opens another
(or the same anew), etc.
2018-10-17 20:10:52 +03:00
Ashod Nakashian
f3d02cb9e2 wsd: support polling on client thread
Previously SocketPoll expected to be
running its own thread for polling.
This is unnecessary when we have a
spare thread (e.g. main) that can
(and should, for efficiency) be used
for polling rather than starting
dedicated thread.

Not starting the SocketPoll's thread
and calling SocketPoll::poll() directly
worked, the warning logs on each activity
notwithstanding.

The warnings aren't just noisy, they are
a performance drain as well, and signal
that something is wrong. The new code
now makes the API cleaner and avoids
unnecessary warning logs, while being
faster.

Change-Id: Ibf9a223c59dae6522a5fc2e5d84a8ef191b577b1
2018-10-16 20:12:23 -04:00
Tor Lillqvist
c617a8c73f Improve a comment 2018-10-16 23:05:59 +03:00
Miklos Vajna
116510296e net: unnecessary value parameter in Socket 2018-10-15 09:31:03 +02:00
Tor Lillqvist
06051c833b Comment out log.dump() call again
Change-Id: I27ecd6712e72182f3a943e7be86ef5ba7b05f746
2018-09-20 13:38:53 +03:00
Tor Lillqvist
f4ce5df7e1 Implement the timeout parameter to fakeSocketPoll()
Adapt callers that mistakenly passed 0 assuming it meant "forever".

This also seems to help with the occasional hangs.
2018-09-19 20:03:24 +03:00
Tor Lillqvist
95eb849217 Still more iOS app and related Online C++ code hacking
Re-think the plumbing between the different parts of the C++ Online
code. Do try to have it work more like in real Online on all but the
lowest socket level. Except that we don't have multiple processes, but
threads inside the same process. And instead of using actual system
sockets for WebSocket traffic between the threads, we use our own
FakeSocket things, with no WebSocket framing of messages.

Reduce the amount of #ifdef MOBILEAPP a bit also by compiling in the
UnitFoo things. Hardcode that so that no unit testing is ever
attempted, though. We don't try to dlopen any library.

Corresponding changes in the app Objective-C code. Plus fixes and
functionality improvements.

Now it gets so far that the JavaScript code thinks it has the document
tiles presented, and doesn't crash. But it hangs occasionally. And all
tiles show up blank.

Anyway, progress.

Change-Id: I769497c9a46ddb74984bc7af36d132b7b43895d4
2018-09-19 11:31:18 +03:00
Tor Lillqvist
7fd28d5676 Revert part of my iOS related commit, causes compilation warning with Clang
Won't actually be needed anyway, the way the code is going in my work
tree.

Change-Id: I4480ed59fe96ddcfad8483517f2a23452606f332
Reviewed-on: https://gerrit.libreoffice.org/60576
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Miklos Vajna <vmiklos@collabora.co.uk>
2018-09-17 12:51:07 +02:00
Tor Lillqvist
4841ee4f47 Move SocketPoll::pollingThreadEntry() implementation to cpp file
Makes it easier to put a breakpoint in it in Xcode...

Not sure if we have any consistent convention around here anyway about
which member functions should be defined inline in the class
definition in the hpp file, and which ones should be in the cpp file.
2018-09-13 09:33:40 +03:00
Tor Lillqvist
b59d160a08 Intermediate commit of work in progress on an iOS app
The app is unimaginatively called "Mobile" for now.

Runs but crashes pretty quickly after loading the document by the LO
core. Will need some heavy changes to get a ClientSession object
created in there, too, to handle the (emulated) WebSocket messages
from the JavaScript. It would then handle some of these messages
itself, and forwards some to the ChildSession, which in this case is
in the same process. Now the messsages from the JavaScript go to a
ChildSession, which is wrong. As the assertion says, "Tile traffic
should go through the DocumentBroker-LoKit WS"
2018-09-12 18:32:05 +03:00
Tor Lillqvist
75438baa70 More mobile app stuff, very much early state of work in progress
Re-think Linux vs mobile ifdefs a bit. Use #ifdef __linux only to
surround code that actually is Linux-specific. Use #ifdef MOBILEAPP
for code that is for a mobile version (with no separste wsd, forkit,
and kit processes, and with no WebSocket protocol used).

Bypass UnitFoo for mobile. Possibly we do want the UnitFoo stuff after
all on mobile, to run in some special testing mode? Hard to say, let's
skipt it for now.
2018-09-10 15:13:43 +03:00
Tor Lillqvist
d07f686b28 Make this file compile for iOS 2018-08-29 20:56:59 +03:00
Miklos Vajna
65df3e6ceb net: use std::move() in the StreamSocket ctor
It was inconsistent that the StreamSocket ctor had a const parameter,
but the SslStreamSocket had a non-const one and used std::move(). Use
the later in the parent class as well for consistency.

Change-Id: I58597b97432a801d164d6ed9d831a0372280e687
2018-05-24 08:50:30 +02:00
Jan Holesovsky
93cc4b4548 Use std::shared_ptr consistently.
Change-Id: I6bf3ff7de47010fd78fab26a5a318bde21c1f153
2018-05-18 15:16:40 +02:00
Jan Holesovsky
98ed24257b Move the functionality from connectToMonitor() to SocketPoll.
Change-Id: Iab2ac09638323f5e59f7a2ea0d880f52989ad64d
2018-05-18 15:16:40 +02:00
Michael Meeks
9e7dff79f3 re-factor socket factories to take a client parameter.
Change-Id: I0be98eb583b4f8081dd8ad23e688e93c55220367
2018-05-18 15:16:39 +02:00
Michael Meeks
b483f477dd Allow a 'monitor' to be connected to remotely if configured.
So far monitors have the access an permissions of an
authenticated admin.

Change-Id: I59dfa8a646a60584a5c113ee0521e9afba4f6b76
2018-05-18 15:16:39 +02:00
Michael Meeks
b5a1af763c Share HTTP header parsing inside the StreamSocket.
Change-Id: Id98e895a939d931ac10b7cd7403da4cbe822ee82
2018-05-01 16:29:56 +01:00
YiiChang Yen
910ae806ef wsd: to filter clientAddress before POST action.
Change-Id: I293580f041bc46b36c57f63fe4a2c0131763b3c1
Reviewed-on: https://gerrit.libreoffice.org/50977
Reviewed-by: pranavk <pranavk@collabora.co.uk>
Tested-by: pranavk <pranavk@collabora.co.uk>
2018-04-30 18:50:06 +02:00
Ashod Nakashian
71f4597059 wsd: WebSocket state is a property of the socket
This resolves the erroneous warnings of pinging
on a non-upgraded (i.e. HTTP) socket.

This was due to the fact that we moved the socket
from one SocketHandlerInterface to a WebSocketHandler
after upgrading and since the WSState was a property
of the handler, the WebSocketHandler didn't know
that the socket had already been upgraded.

Also other cosmetics and cleanups.

Change-Id: I1a88edef750117ed551d23245e49380371561422
Reviewed-on: https://gerrit.libreoffice.org/49911
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2018-02-23 16:42:22 +01:00
Ashod Nakashian
7be98efd93 ut: log timestamp to track timeouts better
And improve the logging support in unit-tests to
help troubleshoot issues faster and more accurately.
Also makes the code more readable (hopefully).

Change-Id: I4f8aafb5245e2f774b03231591a74544f9ec84aa
Reviewed-on: https://gerrit.libreoffice.org/48645
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2018-02-11 19:21:15 +01:00
Pranav Kant
39f11ab4f7 document conflict: unit test
Change-Id: I4ea310fe5adb198bc7b5e083f6bd4b0431c0cdef
2018-02-09 00:22:57 +05:30
Ashod Nakashian
11cdfb7688 wsd: avoid misleading socket error logs
Change-Id: Ie70d8eb1ecc0442643f4b2a4757b95688b4cf1f7
Reviewed-on: https://gerrit.libreoffice.org/48284
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2018-01-22 10:14:17 +01:00
Michael Meeks
a1ee97c222 Add IPv6 support, and configuration option.
Default to listening on both IPv44 and IPv6 for public interfaces.

Change-Id: Ib04e3bf65e7dcf2a798d381297b15ee9c56e9259
2018-01-09 22:03:17 +00:00
Ashod Nakashian
57d535b15b wsd: lambda cleanup and better readability
Change-Id: Iabb850be7a7c162847514ee0fb600297accfcffb
Reviewed-on: https://gerrit.libreoffice.org/47364
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2018-01-06 22:13:50 +01:00
Jan Holesovsky
343c5bc690 tdf#99744 SaveAs: Extend test to check that the Save As result was sent.
Change-Id: I3788b87d2599c01000af97f496ee2b840c0cae3e
2017-10-26 11:11:38 +02:00
Miklos Vajna
f375a9d5de Socket: mark setNoDelay() as non-virtual
No derived classes override it, and if they would, that would be a
problem, as setNoDelay() is called from init(), which is called from the
Socket ctor. Calling virtual functions from the base class ctor is not a
good idea, since the object is not fully constructed yet.

Change-Id: I4993e26d09f5d3429c7e2afae7688b84c0061c9d
2017-09-18 10:15:59 +02:00
Miklos Vajna
bcb5b744b8 net, wsd: fix -Werror,-Wdelete-non-virtual-dtor warnings
Two problem types:

- non-final class has virtual functions but no virtual dtor -> mark the
  class final
- abstract class has no virtual dtor -> add a virtual dtor

Change-Id: Iae208b65c774e6da7a3dda5e725fe07d4d589e4f
2017-09-12 10:03:32 +02:00
Ashod Nakashian
4f8ebca0cb wsd: free leaking memory
With help from Valgrind to find and verify
these leaks.

Change-Id: I3afeed89dc4bcd714a222f81822144477a346fb0
Reviewed-on: https://gerrit.libreoffice.org/39464
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-07-03 05:42:38 +02:00
Miklos Vajna
ffbe55adb5 SocketDisposition::setMove(): parameter is passed by value, move it
Change-Id: I2c7facfc4fc5422cef886c6ba28ac60c656a908e
2017-06-21 09:07:27 +02:00
Michael Meeks
3101fa510d Accumulate I/O stats per document.
Change-Id: Ie2f5647e65070ddd828f048820efd38b600f9133
2017-06-02 20:41:25 +01:00
Michael Meeks
c224413a9d Track bytes recv'd and sent on StreamSockets.
Dump on USR1 as part of our state.

Change-Id: I4c6b87c19bca768402c9b0b8e26f16336e007749
2017-05-26 15:54:58 +01:00
Ashod Nakashian
bdd8b715dd wsd: include cleanup
Change-Id: I9f28ee329e318043c31c899d3a07cd3139d838f0
Reviewed-on: https://gerrit.libreoffice.org/37890
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-05-22 07:04:24 +02:00
Ashod Nakashian
7cff4fb08a wsd: fix server shutdown
Thread-affinity checks must be inhibited
not just on Socket, but on the SocketPoll as well,
before destroying DocumentBroker instances.

Also, properly initialize the inhibit statics.

Change-Id: I2ced1554d477f0c3faf09bda74034cbae99e4ce1
Reviewed-on: https://gerrit.libreoffice.org/37608
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-05-15 05:10:31 +02:00
Michael Meeks
9e45fb30d7 SocketDisposition: push it down the stack, and cleanup around that.
Dung out overlapping return enumerations. Move more work into 'move'
callbacks at a safer time, etc.

Change-Id: I62ba5a35f12073b7b9c8de4674be9dae519a8aca
2017-05-05 18:37:26 +01:00
Michael Meeks
faf24f7888 SocketDisposition - controls socket movement & lifecyle.
It is important that moving sockets between polls happens in a
safe and readable fashion, this enforces that.
2017-04-25 22:49:08 +01:00
Ashod Nakashian
8b3a2ed9d7 wsd: reduce included headers
Change-Id: I3107b18b2edae34a76e9f56a5cbd24836b1b57c0
Reviewed-on: https://gerrit.libreoffice.org/36872
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-04-24 06:52:02 +02:00
Ashod Nakashian
988ddaf7be wsd: cleanup sendFile to allow header-only response
HTTP HEAD verb requires sending back NO content.

Currently we don't support HEAD and that harms
the browser from using its cache where possible.

Change-Id: I3c67dc106df95312c73f6ae786b7b1657a4167fb
Reviewed-on: https://gerrit.libreoffice.org/36871
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-04-24 06:47:42 +02:00
Michael Meeks
1c7f94045a Initial DelaySocket goodness. 2017-04-22 18:42:16 +01:00
Jan Holesovsky
47ca32beb5 We never call setNoDelay() with false.
Change-Id: I865027300559b185222f21faa48ccd32100bd02d
2017-04-19 11:07:55 +02:00
Michael Meeks
f72b7d2ba1 Don't set the buffer size to zero.
This slows things down terribly, particularly the setting on the websocket
made tiles appearing one by one. Let's keep the possibility to zero the buffer
sizes for debugging, but hide that behind an env. variable (and in debug
builds only anyway).

Change-Id: Ie4d2cdb3c0ec3c50f1a2b4f9941a462ac4f2d196
2017-04-19 10:58:18 +02:00
Ashod Nakashian
9b3a22aafe wsd: save document upon server shutdown
The server correctly saves all documents
and waits to upload them before exiting.

Change-Id: I04dc9ce588bc0fa39a9deb298d0a5efa61a03f1a
Reviewed-on: https://gerrit.libreoffice.org/36654
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-04-19 07:04:26 +02:00