Commit graph

18 commits

Author SHA1 Message Date
Tor Lillqvist
223cc97175 Log each line separately in fakeSocketDumpState() instead of with embedded newlines 2018-10-16 23:04:24 +03:00
Tor Lillqvist
cab2f9b6bb Add fakeSocketDumpState() 2018-10-16 01:11:20 +03:00
Tor Lillqvist
e907d0ee01 Switch to using just one mutex in FakeSocket.cpp for now
Makes things simpler and easier to follow, I hope. I had hoped it
would also make the occasional hang I see when loading the document go
away, but nope. Possibly it isn't caused by FakeSocket after all, even
if FakeSocket is the obvious first suspect.
2018-10-10 10:31:07 +03:00
Tor Lillqvist
be945ed51b Bin duplicate const variable 2018-10-10 10:31:07 +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
5ee96e0271 Small correction to poll semantics 2018-09-19 20:03:24 +03:00
Tor Lillqvist
8b5246b038 Bin one presumably pointless lock and unlock 2018-09-19 20:03:24 +03:00
Tor Lillqvist
9c57ffd3b3 Avoid potential deadlock 2018-09-19 17:55:14 +03:00
Tor Lillqvist
763a27280a Add possiblity to force logging to stderr with environment variable
At least LOOLWSD.cpp has a couple of global variables of types that in
their constructors invoke FakeSocket APIs. If we turn on FakeSocket
logging (fakeSocketSetLoggingCallback()) only in the app's
initialization code, we will miss logging from those global variable
constructors.

Sure, the clean solution would be to turn those global variables into
members in the LOOLWSD class instead, but this will do for now.
2018-09-18 15:31:01 +03:00
Tor Lillqvist
c09dfda052 In the logging always precede FakeSocket "fd" numbers with #
Makes it easier to search log files.

Also, Online uses this convention for socket fds in many places (not
sure if consistently).
2018-09-18 13:04:16 +03:00
Tor Lillqvist
435718e9f3 Improve shutdown semantics 2018-09-18 13:04:11 +03:00
Tor Lillqvist
53416a290d Add fakeSocketShutdown() and drop fakeSocketFeed()
Not sure whether the shutdown() implementation matches real shutdown()
semantics, especially with regards to the behaviour of poll(), read(),
and write() (on both the socket itself and the connectd one)
afterwards. But let's see.

The feed() API turned out to be not needed. (And in any case, it was
suposed to be completely equivalent to writing to the peer socket.)
2018-09-17 20:44:18 +03:00
Tor Lillqvist
3bcde388ed FakeSocket poll fix and minor hacking
fakeSocketPoll() needs to return a correct return value.

Use notify_all() instead of notify_one(). Just to see if it makes any
difference.
2018-09-16 22:39:44 +03:00
Tor Lillqvist
7399a86f6a Use optional logging callback in FakeSocket.cpp instead of hardcoded writes
It's easier to either call the function to set the logging callback,
or not, in one place in client code, than to comment in and out all
the logging lines in FakeSocket.cpp as needed.

Change-Id: Id17f7e461c7df817440b47cb3124fcece13b189b
2018-09-16 13:39:43 +03:00
Tor Lillqvist
30ec64566b Attempt to fix various FakeSocket problems
Also add a bit of internals documentation.
2018-09-16 10:42:01 +03:00
Tor Lillqvist
0a2868b8d4 More FakeSocket hacking
As we use #ifdefs at all call sites anyway (because we don't dare use
the generic overrides of close() etc), we can leave out the parameters
related to actual BSD sockets that we ignore anyway.

"Real" Online always uses non-blocking sockets. We don't need to take
flags for that or check it. We can hardcode such behaviour always.
(Assuing that is what we want; let's see once something works.)

Change-Id: I6863907d71c5599b00ce1f8305a44d41bbaf7bee
2018-09-15 12:35:23 +03:00
Tor Lillqvist
55a2f804a6 Change the FakeSocket to be record-oriented
That is how Online uses the sockets for communication between the
processes anyway: It send and receives complete WebSocket frames.
Sure, in the mobile case there is just one process, but (I think) we
want to keep the same basic structure anyway, even if "wsd" and "kit"
are just threads. (We probably also want to drop the WebSocket framing
of the messages.)

Change-Id: I2397f321029c1cbbbc448a9b2403ad185a51cf14
2018-09-15 12:34:29 +03:00
Tor Lillqvist
6d81ebcfeb Add FakeSocket
Intended as a replacement for the real sockets used for WebSocket IPC
in Online on Linux. The idea is that in a mobile app we don't want to
bother with any actual sockets or WebSocket protocol (because we are
running as a single process after all), but keep much of the code that
thinks it is using such mostly unmodified. Just an idea so far, let's
see how this turns out.

Change-Id: I7878b0db99d9cbf70650227186c1fec9677fa74b
2018-09-15 12:30:50 +03:00