Ashod Nakashian
e0822f8516
wsd: better thread affinity logging
...
Change-Id: I9e4bc3fe864aa409dc4874a9d6fc4ab22bfea592
Reviewed-on: https://gerrit.libreoffice.org/36029
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-04-03 05:11:57 +00:00
Michael Meeks
aeb204fb14
Kill race during DocumentBroker shutdown over child process.
...
==20033== Invalid read of size 4
==20033== at 0x466504: ChildProcess::close(bool) (DocumentBroker.hpp:111)
==20033== by 0x44EA28: DocumentBroker::terminateChild(std::string const&, bool) (DocumentBroker.cpp:1313)
==20033== by 0x45F70E: DocumentBroker::pollThread() (DocumentBroker.cpp:264)
==20033== by 0x504B2F: SocketPoll::pollingThreadEntry() (Socket.hpp:486)
==20033== by 0x7310E6F: execute_native_thread_routine (thread.cc:84)
==20033== by 0x7AF60A3: start_thread (pthread_create.c:309)
==20033== by 0x7DF002C: clone (clone.S:111)
==20033== Address 0x0 is not stack'd, malloc'd or (recently) free'd
2017-03-31 17:28:20 +01:00
Michael Meeks
194c169f68
Remove obsolete write-lock.
...
The lock was used incompletely & inconsistently, and we should
always and only ever write in the associated SocketPoll's thread.
2017-03-31 14:58:37 +01:00
Michael Meeks
913c469aa8
Cleanup whitespace, return is not a function.
2017-03-30 17:34:52 +01:00
Michael Meeks
a4ac00d854
Add zlib cflags and libs to configuration.
2017-03-30 12:09:12 +01:00
dewana-dewan
4322045667
tdf#106579 - serving gzipped file content
...
Change-Id: I320b22babf1bf65a0f1d4b1809a6ffb1f5ec8344
2017-03-30 12:09:12 +01:00
Jan Holesovsky
1d335b92ce
Avoid extensive warning about a normal situation.
...
Change-Id: Ie67a12847afddac087f74e4872744b2b8bb07b1e
2017-03-30 11:21:10 +02:00
Ashod Nakashian
492b818022
wsd: warn if isCorrectThread will fail
...
Change-Id: I362b23e651c00a6514bd1e44fa0961269252bcdd
2017-03-29 23:55:19 -04:00
Ashod Nakashian
30d58f96a4
wsd: avoid unnecessary temp string construction
...
...when sending text messages over socket and
make return value indicative of success/failure.
Change-Id: Ie4d99103b0d49d238152f7da3155ebcb6ccd4e22
2017-03-29 23:55:19 -04:00
Ashod Nakashian
d77ede8954
wsd: consistent naming sendFrame -> sendMessage
...
Change-Id: I06c6bb42392a8982a8bb232eee33ece4c8dfc451
2017-03-29 20:03:01 -04:00
Ashod Nakashian
fbf3b87626
wsd: simplify and cleanup session creation
...
Change-Id: I8cc05bc7a8dc89c6a521b81c6d59ff1e9968763a
Reviewed-on: https://gerrit.libreoffice.org/35789
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-03-28 05:15:28 +00:00
Michael Meeks
e26079eecb
tdf#106797 - avoid locking up / crashing on exceptions from main.
2017-03-27 20:15:30 +01:00
Ashod Nakashian
6d7f39356c
wsd: flush sockets before exiting DocBroker poll thread
...
Change-Id: Id5384c113bd761b5b8c25286f1bd5a28051c63d3
Reviewed-on: https://gerrit.libreoffice.org/35740
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-03-27 03:21:38 +00:00
Ashod Nakashian
f2f0040275
wsd: use isCorrectThread
...
Change-Id: Id63c30b19489d590b995e0ea66ef2f44e8cddfb7
Reviewed-on: https://gerrit.libreoffice.org/35738
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-03-27 03:20:43 +00:00
Ashod Nakashian
5ae94cc7ec
wsd: onConnect takes shared_ptr and better logging
...
Change-Id: I175dfa1f28444b9bb1f612242ee44b6d0507272c
Reviewed-on: https://gerrit.libreoffice.org/35737
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-03-27 03:20:22 +00:00
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