Ashod Nakashian
c1ffb64904
wsd: correct shutdown status code echoed back
...
Change-Id: Ieb685135ab280ed76070af3392bfa69cf313f35a
Reviewed-on: https://gerrit.libreoffice.org/35708
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-03-26 05:08:46 +00:00
Ashod Nakashian
3895897213
wsd: improved socket logging
...
Change-Id: Ib4751a5a73b7ec0c7ca319f552d5e0aaff06ffea
Reviewed-on: https://gerrit.libreoffice.org/35707
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-03-26 05:07:37 +00:00
Michael Meeks
ce0dffdc12
Use callback API to implement alertAllUsers safely and simply.
2017-03-21 08:31:20 +00:00
Ashod Nakashian
dc90499514
wsd: remove the socket on move
...
Avoid explicit socket removal too.
Change-Id: I44d773761a5a463aad828c19c6b394bb6bac63d8
2017-03-20 23:26:06 -04:00
Ashod Nakashian
b01e555b47
wsd: correct copying of socket shutdown message
...
Avoid segfaulting.
Change-Id: I320606937a0d3a3e53270a70ef0a00fcb01b855a
2017-03-20 23:25:54 -04:00
Ashod Nakashian
53da72a1dc
wsd: fix hot looping the poll
...
When not sending ping the ping time is not set
which results in the setting the poll timeout to
a negative value, forcing it to return immediately.
This happens when sending ping before upgrading
to WebSocket, which isn't common. One way to
reproduce it, however, is to connect to the
admin console with an unauthenticated socket.
Change-Id: I9f3db1a02b8f8e2781d23d843e848068ad434958
2017-03-20 00:41:54 -04:00
Ashod Nakashian
e9675ed6e1
wsd: close socket when WS close handshake is complete
...
We shouldn't send any more data after the client
shuts down, or after we initiate shutdown.
Change-Id: Ibf0cf61dcabe9d02ddcb7eb40b2df23712c5a136
2017-03-20 00:41:53 -04:00
Ashod Nakashian
6283dbd9cc
wsd: copy and un-mask web-socket data at the same time
...
Change-Id: I2a4831065ae0a81f20d0513b0772d7d427ffc4ea
2017-03-20 00:41:53 -04:00
Ashod Nakashian
0d3ea2bbfd
wsd: flag thread start before creating thread
...
This prevents a race where the thread is started
a second time before the first gets a chance to
set the flag.
Change-Id: Ib106aa0626cdfa403b321822180b0545d3aa9139
2017-03-20 00:41:53 -04:00
Ashod Nakashian
14779f5cd4
wsd: return moved socket state to stop any IO processing
...
Once a socket has changed ownership to a new
poll it will assert thread affinity with said
new poll. So we cannot do any IO on the old
poll's thread at that point and on.
Change-Id: I662f188dea7c377a18f3e546839ec43f2875dc7b
2017-03-20 00:41:53 -04:00
Ashod Nakashian
7096133f07
wsd: log thread affinity violations
...
Change-Id: Ib1317bc71f9162f005e0ce9b8c715bbce656db73
2017-03-20 00:41:53 -04:00
Michael Meeks
50661924b7
Dump much more ClientSession state, and also websocket latency.
2017-03-18 15:03:04 +00:00
Michael Meeks
0d8809f0ca
Get warning logic right on wakeup socket.
2017-03-18 15:03:04 +00:00
Michael Meeks
b8b5cc2069
Shorten time to send first ping - to assess socket latency.
...
Also ensure we never send a ping on a non-upgraded websocket.
2017-03-18 15:03:04 +00:00
Michael Meeks
a6a4094e52
Send ping message, handle pong & store ping-time on the Websocket.
2017-03-17 22:59:03 +00:00
Michael Meeks
9381d4134f
Unify and simplify timeout and poll events setup.
...
Both happen at the same time, and need support from the
SocketHandlerInterface.
Rename hasQueuedWrites to getPollEvents and merge updateTimeout.
2017-03-17 22:00:28 +00:00
Michael Meeks
3a5ca4b03f
Switch to std::chrono from Poco::Time and simplify lots.
2017-03-17 21:13:11 +00:00
Michael Meeks
e9dbab6900
Always call handlePoll so we can handle timeouts.
2017-03-17 21:13:11 +00:00
Michael Meeks
e7ebe0fdaa
remove obsolete Poco headers, and Poco SSL pieces.
2017-03-16 18:03:23 +00:00
Michael Meeks
69feb165dd
Remove websocket assert on performWrites.
...
Since commit 862d7a0734
wsd: write as many messages to socket as possible:
This can be called even if hasQueuedWrites returns false.
2017-03-16 17:23:42 +00:00
Michael Meeks
f392d9e6f0
Move http serving into socket impl.
...
Avoid caching headers with parameter, and add Date: parameter.
2017-03-15 18:21:59 +00:00
Michael Meeks
909b5f8ac3
Admin: should be its own socket-poll goodness.
2017-03-15 16:13:13 +00:00
Ashod Nakashian
fa1dc4e051
wsd: wrap polling thread and manage state correctly
...
Change-Id: Iaa4eff1fac1cd7147603ba0c9d51fd8b6b0e96d2
2017-03-15 00:04:55 -04:00
Ashod Nakashian
c8bece208d
wsd: socket logs include socket FD for better traceability
...
Change-Id: I994c7c5ab73b97be312a9d6abf3258dc5f4c08c1
2017-03-15 00:04:55 -04:00
Ashod Nakashian
aa19964b03
wsd: SSL logging improvement
...
Change-Id: I99d08a764fd43ab0c7eb50a1f017202e6bbc3477
2017-03-15 00:04:55 -04:00
Ashod Nakashian
45e1c7763c
wsd: Socket stores SocketHandler shared_ptr
...
Change-Id: I5b460069eb4d91cee2d58833791f961fd6f42b39
2017-03-15 00:04:55 -04:00
Ashod Nakashian
b258355039
wsd: StreamSocket supports changing its SocketHandler
...
Change-Id: I2ffc33daad4da5b98183af39e3c2a64e7e10b3e8
Reviewed-on: https://gerrit.libreoffice.org/35158
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-03-14 04:31:22 +00:00
Ashod Nakashian
8b9623010a
wsd: sendHttpResponse -> send
...
Change-Id: I7c94f6d4cd1054ea86585bfcd4079140471f3518
Reviewed-on: https://gerrit.libreoffice.org/35157
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-03-14 04:30:55 +00:00
Michael Meeks
bf8068de18
Clarify comment a little.
2017-03-13 13:42:05 +00:00
Andras Timar
07c0452ec1
fix error: unused parameter 'hard' [-Werror=unused-parameter]
...
Change-Id: Ie2f2a12cc2f5d6c2fd3319d3c870cc7f0a226fae
2017-03-13 13:22:56 +01:00
Michael Meeks
97e9463f17
Revert "wsd: TerminatingPoll always starts its own thread"
...
This reverts commit 388d7b1dbf
.
It is vital to have clean control of thread start. By starting
a thread during init. of a member (or base-clase) we loose lots of
control, some examples:
Any members initialized after a member that auto-starts a
thread, is effectively un-defined, and cannot be accessed
reliably.
This is particularly problematic for sub-classes.
I've seen threads started before the base-class has
finished constructing in the original creating thread -
such that the vtable was not yet updated to the sub-class
causing the transient parent vtable used during construction
to be used in-error.
2017-03-13 12:13:22 +00:00
Ashod Nakashian
94051f21b5
wsd: SocketPoll::startThread can be protected
...
Change-Id: Idd17f7314ac181e9a412e05a1287e15edf5047d2
Reviewed-on: https://gerrit.libreoffice.org/35125
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-03-13 04:25:20 +00:00
Ashod Nakashian
c4d27fd060
wsd: prevent and warn when joining own thread
...
Change-Id: I8405a1aacb1281e52bbd07d32cdcf35bdc484d8b
Reviewed-on: https://gerrit.libreoffice.org/35124
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-03-13 04:25:04 +00:00
Ashod Nakashian
862d7a0734
wsd: write as many messages to socket as possible
...
Change-Id: Ie2702ea68dd1ae6200fcc304224dea34fc94544f
Reviewed-on: https://gerrit.libreoffice.org/35123
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-03-13 04:24:37 +00:00
Ashod Nakashian
9248107702
wsd: SocketPoll reports thread isAlive and use in DocBroker
...
Now that DocumentBroker has SocketPoll thread,
it's isAlive() must be defined by the lifetime of
both the SocketPoll thread and the ChildProcess,
which it previously did.
Change-Id: I093f8774cf4374d01729a383f6c535de4143fec6
Reviewed-on: https://gerrit.libreoffice.org/35122
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-03-13 04:23:18 +00:00
Ashod Nakashian
c9a07a3087
wsd: assert socket is in correct thread
...
Change-Id: I22c3f62bdf45188641326774dd86b7cacfce9198
Reviewed-on: https://gerrit.libreoffice.org/35120
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-03-13 04:20:41 +00:00
Ashod Nakashian
04bbb75200
wsd: dump state to generic ostream for flexiblity and to log
...
Change-Id: I4670ee2e90b7809ebc66a2b324a44334b3dbba2b
Reviewed-on: https://gerrit.libreoffice.org/35119
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-03-13 04:19:58 +00:00
Ashod Nakashian
2e2f62edde
wsd: improved logging
...
Change-Id: I6c4a5bcd54c0748cc413afbfcfb34c365b347669
Reviewed-on: https://gerrit.libreoffice.org/35118
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-03-13 04:11:24 +00:00
Ashod Nakashian
6f11918661
wsd: more informative SSL error logging
...
Change-Id: I32baadf995f6fc4c9b112d1a62fee2d618fc9e95
Reviewed-on: https://gerrit.libreoffice.org/35116
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-03-13 04:10:03 +00:00
Michael Meeks
5763d8d9bb
Improve debugging.
2017-03-10 23:28:34 +00:00
Michael Meeks
a9d5801c37
Unwind releaseSocket complexity.
...
We only move sockets in response to input on the socket, which
must happen in the thread that we're processing that input on.
Ergo - no need for this complexity.
2017-03-10 18:46:31 +00:00
Michael Meeks
027b8110ed
Allow isCorrectThread asserts to be hard, or off by default.
2017-03-10 18:46:16 +00:00
Michael Meeks
c30fb670d8
Work on LOOL_CHECK_THREADS=1 a little.
...
The situation made more problematic since the std::thread is only
created in startThread - so getting ownership right before then in
Socket is problematic.
2017-03-10 18:20:51 +00:00
Michael Meeks
160446fd23
Work on resurrecting dying DocumentBrokers if we can.
...
The hope is that they will close lingering session sockets at the
end and the client will re-connect.
2017-03-10 17:58:51 +00:00
Michael Meeks
1065441e7c
Don't autosave if we're being stopped and happened to be overdue.
2017-03-10 16:42:59 +00:00
Michael Meeks
173ca5e3d6
Quote ETag.
2017-03-10 16:42:48 +00:00
Michael Meeks
7a90430f85
Cleanup logging on single packet websocket messages more cleanly.
2017-03-10 14:49:19 +00:00
Michael Meeks
11f3a29cb2
WebSocket - several messages can appear in a single packet.
2017-03-10 14:36:21 +00:00
Michael Meeks
34d9d52207
Avoid assert failure and zero size socket buffer in product build.
2017-03-10 12:12:10 +00:00
Michael Meeks
f4f083e6fe
Cache JS etc. on the client side for 128 days.
2017-03-10 11:36:10 +00:00
Michael Meeks
a5a227e9a3
Re-work socket buffer options, sizing and setting.
...
Only set nodelay and small socket buffers on WebSockets.
Avoid writing more data than can be absorbed by our socket buffer.
It is fine to set socket buffer sizes after bind/accept.
2017-03-10 10:55:29 +00:00
Miklos Vajna
2f07eb9a7d
Fix remaining -Werror,-Winconsistent-missing-override warnings
...
The last ones introduced by the non-blocking merge.
Change-Id: I0b9264428669cdd2b8f6eac911c336c6b0e8de99
2017-03-10 11:11:58 +01:00
Miklos Vajna
400c580800
net: fix -Werror,-Wconstant-conversion
...
Change-Id: If2bbad6d3909c7d6df9eed5edf260609d64db3a8
2017-03-10 11:06:43 +01:00
Miklos Vajna
33cbe908c5
net: fix -Werror,-Winconsistent-missing-override
...
Change-Id: Ia8c1f0233e0b65f5fae01272b4f31638aceac9ee
2017-03-10 10:54:08 +01:00
Ashod Nakashian
2d621f1a47
nb: logging
...
Change-Id: Ic3b724d5869f75234af2238b96a90c4745155b86
2017-03-10 10:47:44 +01:00
Ashod Nakashian
1da9bc3d69
nb: set the polling thread name for better logging
...
Change-Id: Iccc4337827f00af08327a4430f3d40fa69ac71b2
2017-03-10 10:47:44 +01:00
Michael Meeks
3bfc8aa7f3
Use larger socket buffers for serving files to improve efficiency.
...
The combination of nodelay + minimum buffers is horrific for
file-serving; speedup is from 3.3s to 33ms to serve bundle.js.
2017-03-10 10:47:44 +01:00
Michael Meeks
42a19e66e3
Centralize idle poll time.
2017-03-10 10:47:44 +01:00
Michael Meeks
438630c68f
Start DocBroker thread later - when we've added our 1st session.
2017-03-10 10:47:44 +01:00
Michael Meeks
e16fc97c15
SocketPoll - better control starting our threads.
...
Extraordinary trace with a thread starting before the SocketPoll's
derived classes had started - ie. with wrong vtables etc.
2017-03-10 10:47:44 +01:00
Michael Meeks
842b261d9f
Move auto-save of document into the DocumentBroker poll more convincingly.
2017-03-10 10:47:44 +01:00
Jan Holesovsky
4eccd4d7b4
nb: Check threads only when LOOL_CHECK_THREADS is set.
...
Change-Id: I4137685eb956469d419bded318b83de2b10ce19d
2017-03-10 10:47:44 +01:00
Jan Holesovsky
b895393cea
nb: Perform the socket shutdown asynchronously after the data is served.
...
Change-Id: I642e26abf4ef9c8d2be1be428b5786692dfea2c7
2017-03-10 10:47:44 +01:00
Ashod Nakashian
b8af470918
nb: serve files synchronously
...
As there isn't support (yet) to send files
asynchronously, when the socket native buffer
is small, asynchronous writes naturally return
EWOULDBLOCK. As a temp solution, we send files
synchronously, so there is no need to poll.
This should be replaced witha file-server
polling/serving thread that is dedicated to
sending files only (which closes the connection
when done).
Change-Id: I062fea44bfe54ab8d147b745da97bd499bf00657
2017-03-10 10:47:44 +01:00
Michael Meeks
37de43bb58
Tie sockets to threads, and assert that we're being used in the right one.
...
This shows up some problems around cleaning up prisoners etc. that will
need fixing subsequently.
2017-03-10 10:47:43 +01:00
Michael Meeks
0eaef6c896
config.h - get includes right: must always be the first include.
2017-03-10 10:47:43 +01:00
Ashod Nakashian
7b1ed1b4d4
nb: more informative logging of socket activity
...
Change-Id: I9036c778c195936678c6451ba57cc794d6ba0006
2017-03-10 10:47:43 +01:00
Ashod Nakashian
221bfdefc8
nb: get the poll sockets size after setting up
...
Change-Id: I35174f2f9345286791ccefe2d6dc521a767b6571
2017-03-10 10:47:43 +01:00
Ashod Nakashian
aee954af8b
nb: include the SocketPoll name in logs
...
Change-Id: I7a93edfe0bc74e62bd2726f6fa8425c719326023
2017-03-10 10:47:43 +01:00
Michael Meeks
ce4bd9b9be
Unify DocumentBroker thread and its SocketPoll.
2017-03-10 10:47:43 +01:00
Michael Meeks
79fb1e2c1f
Sub-class the SocketPoll to allow more flexibility in termination.
2017-03-10 10:47:43 +01:00
Ashod Nakashian
c6dbce9767
nb: transfer client sockets to respective DocumentBroker
...
Change-Id: I6af656ec6cbb09d4dd80b7b583a009a763de6eb9
2017-03-10 10:47:43 +01:00
Ashod Nakashian
76e96c92c8
nb: SocketPoll is now a thread object
...
Change-Id: I01d13292f0b97a9ebd1ccdef9e41fec46bfa0b11
2017-03-10 10:47:43 +01:00
Michael Meeks
20f15d4001
Switch Prisoner socket handling to use the SocketPoll.
...
Kills the Poco ThreadPool usage, and significantly improves debuggability.
2017-03-10 10:47:43 +01:00
Michael Meeks
a856a95138
Dump buffer contents as hex if we have them.
2017-03-10 10:47:42 +01:00
Michael Meeks
d4cc2e899c
ClientSession: kill the writing thread.
2017-03-10 10:47:42 +01:00
Michael Meeks
6711701721
Socket API to allow asynchronous writing.
2017-03-10 10:47:42 +01:00
Michael Meeks
1655e5d062
Improve socket state dumping on USR1.
2017-03-10 10:47:42 +01:00
Ashod Nakashian
d68377748d
nb: ReadOrWrite -> Neither
...
SSL only requests what to poll for next.
So it's more accurate to rename ReadOrWrite
to Neither, since in that case SSL really
isn't blocked on either read or write.
Change-Id: I62dd4f94730d51666a7661b10a9d582d69fbf45e
2017-03-10 10:47:42 +01:00
Ashod Nakashian
9c0d8cc5b2
nb: log more socket activity
...
Change-Id: Ibcdf5abc3054691c93382c00bb8a9ecc4b882652
2017-03-10 10:47:42 +01:00
Michael Meeks
fa96673ee0
Connect USR1 to initial global state dumping goodness.
2017-03-10 10:47:42 +01:00
Michael Meeks
fffd970425
Work around global initialization order issue with global wakeups.
2017-03-10 10:47:42 +01:00
Michael Meeks
fa6b756346
signal handling: keep track of all socket poll wakeups & wakeup.
...
Instead of waiting for polls to timeout; wake them up.
2017-03-10 10:47:42 +01:00
Jan Holesovsky
17d8b645b4
nb: It seems uppercase 'S' is preferred in Sec-WebSocket-Accept.
...
Change-Id: I6cc86f26cf7e3c9370e5d534877bfeeb6607f5a4
2017-03-10 10:47:42 +01:00
Jan Holesovsky
62afe66df0
nb: Make the loolnb / clientnb work again.
...
The more testing the better :-)
Change-Id: Ibe4249f18109d50b06e1fa35e6d0fef67f9b3643
2017-03-10 10:47:42 +01:00
Ashod Nakashian
8040dc0746
nb: disable hex dumping
...
No longer necessary to have them enabled
permanently, especially that they affect
performance significantly negatively.
Change-Id: I02ef99da00ba4ecb8e24647ee372a03d79d07fe7
2017-03-10 10:47:42 +01:00
Jan Holesovsky
653df9dcce
nb: No need for the WebSocketSender I think.
...
Change-Id: I133bb8341a846d70f95e0c70274541b5db62f65d
2017-03-10 10:47:42 +01:00
Jan Holesovsky
759895a8d7
nb: This file is not needed any more.
...
Change-Id: Ic73ddcc61495889fd36eb6f23f41c1bd45eb85c6
2017-03-10 10:47:42 +01:00
Jan Holesovsky
be743c115d
nb: When we cannot send the file, we must respond with 404.
...
Change-Id: I5f11e7de4b0bfb6e44929b8317e4788d2cc81610
2017-03-10 10:47:41 +01:00
Jan Holesovsky
67293c8183
nb: Fix the check in loolnb.
...
Change-Id: I54f23cb5fb76e4f9aab2743ddc2e6cda04a2656b
2017-03-10 10:47:41 +01:00
Ashod Nakashian
a68c33477d
nb: support inserting image
...
Change-Id: I6ef11634bbda7e3ecdc467ce10727c8573caef8d
2017-03-10 10:47:41 +01:00
Ashod Nakashian
b7e94d03ea
nb: websocket closing handshake
...
Change-Id: I45a6f2e680349fa2f77c20bb8f783093b9e1f212
2017-03-10 10:47:41 +01:00
Ashod Nakashian
4abf706af6
nb: websocket shutdown support
...
Change-Id: I2fcab98e9725eca86d097f34236889fdf9289c47
2017-03-10 10:47:41 +01:00
Ashod Nakashian
27452ec98c
nb: support WS shutdown
...
Change-Id: I08084abb25e494384235260dd1df83adc5e3a624
2017-03-10 10:47:41 +01:00
Ashod Nakashian
f9197ff020
nb: separate sendMessage and sendFrame
...
There are other types of frames than application
data.
Also a message can be composed of multiple frames.
Change-Id: Ia97349553b61ae05fa78854222808eaa43386c0e
2017-03-10 10:47:41 +01:00
Ashod Nakashian
17fc91e220
nb: process POST requests
...
These are really GET requests that aren't
WebSocket upgrade. Should rename to something
less misleading.
Re-enabled testSlideShow which depended on this.
Change-Id: I52b7f67b650fcdcbae7c2bff020b756099263141
2017-03-10 10:47:41 +01:00
Ashod Nakashian
9d72496038
nb: prefix large WS with nextmessage
...
Change-Id: Ie6583c93ada9cff8aa50137431b5c2c5f7b39d97
2017-03-10 10:47:41 +01:00
Ashod Nakashian
0c19d81fee
nb: read the socket on accept
...
It's necessary to do the SSL handshake
and to get the request (if we get there)
on accepting so by the time we poll we know
what SSL needs to do next. No reason to
read on first poll when we should be
expecting a request upon connection anyway.
Change-Id: I8eecaad5f8450075d45e487702972418cad125bc
2017-03-10 10:47:41 +01:00
Ashod Nakashian
72669bf929
nb: logging
...
Change-Id: Ia67f746a6c71b4753d04b92472eddf1614c0d337
2017-03-10 10:47:41 +01:00
Michael Meeks
aa0a85c16d
Add debug, and set the 'fin' bit on messages as we send them.
2017-03-10 10:47:41 +01:00