Commit graph

5110 commits

Author SHA1 Message Date
Ashod Nakashian
c6dbce9767 nb: transfer client sockets to respective DocumentBroker
Change-Id: I6af656ec6cbb09d4dd80b7b583a009a763de6eb9
2017-03-10 10:47:43 +01:00
Ashod Nakashian
5a8734b7de nb: cleanup defunct socket code
Change-Id: Iaff9d530ca4a62eb3dcf3068f86d0bd52c47a5d0
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
Jan Holesovsky
8b8bb67cd7 Fix a misplaced ENABLE_SSL #endif.
Change-Id: Ie2a4b777f7df422eca18e3a1b5331b9e0c722c52
2017-03-10 10:47:43 +01:00
Michael Meeks
52327d78e2 Cleanout old socket code, and several obsolete LOOLWebSocket uses. 2017-03-10 10:47:43 +01:00
Michael Meeks
c84f9738fd Disable new-style unit tests for now. 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
Jan Holesovsky
6083911a0d nb: Remember also the messages sent to sessions queued for creation.
Without this, it was impossible to connect to an existing session, because we
were trying to send messages to sessions that were not connected yet.

Change-Id: If9260a1f0ac8f5387f492541548724b0065df9d9
2017-03-10 10:47:42 +01:00
Jan Holesovsky
380624ba32 nb: Remove also the queued sessions.
Change-Id: I455fbbabfea9805d70fe909fd9b4078f02d21438
2017-03-10 10:47:42 +01:00
Ashod Nakashian
3b67f709d2 nb: Fix race when loading a document.
Don't block when creating new sessions, instead queue the requests, and handle
them in the DocumentBroker.

Change-Id: I200bbfc740f004c37178fa316d1eb91afdde5d4a
2017-03-10 10:47:42 +01:00
Jan Holesovsky
1914f9215c Revert "Horror hack to avoid race for now."
This reverts commit e977667754ba34b83ba0259d6568aa88ae5995df.
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
Jan Holesovsky
4be3ac614d nb: Fix polling with http.
When we call readIncomingData() outside of the poll, we read the data, and
store them into the buffer.  But then the next poll will not indicate that
there data actually some available (they've been already read from the FD),
and we will get stuck.

I susppect we should remove from the SSL case at some stage too, to be
symmetrict to the non-SSL case.

Change-Id: Ib8339400b41e797adb2eb8519f87093ebf6be9c5
2017-03-10 10:47:42 +01:00
Michael Meeks
1b8e6f8c78 Horror hack to avoid race for now. 2017-03-10 10:47:42 +01:00
Michael Meeks
11c2e15a93 Rename members: accept and webserver pieces have cleaner names.
As distinct from the websocket poll per DocumentBroker.
2017-03-10 10:47:42 +01:00
Michael Meeks
4f883e9fc4 Setup a poll per DocumentBroker with thread to go with that.
Also dung out a chunk of older code.

FIXME: websocket / ClientSession needs to associate itself with the
DocumentBroker poll loop in place of the original loop.
2017-03-10 10:47:42 +01:00
Michael Meeks
073a216aa1 Annotate some blocking methods - ugly, but necessary. 2017-03-10 10:47:42 +01:00
Michael Meeks
333f8994e9 Cleanup shutdown flag handling.
Pull the notification pieces out of SigUtil.cpp - not signal safe,
and invoked only from LOOLWSD anyway.

In a non-blocking world, the socket close notification sends are
instant - so more work required to count-down / timeout remaining
clients.
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
Ashod Nakashian
2ed8c3d875 nb: search for free client port
Change-Id: I33238e83756481267c222b3cd3b9d30f4fcd3d48
2017-03-10 10:47:42 +01:00
Michael Meeks
892e755700 Cleanup shutdown. 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
7c9082e2a4 nb: No need to construct a new WebSocketHandler here.
Change-Id: I91bdc71732cd54266a2a3f8c751b09e22b7c83a4
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
fa0771921d nb: enable testCloseAfterClose
Change-Id: I4150c547c3859e22c6628cd8d65e470b71d8cad4
2017-03-10 10:47:41 +01:00
Ashod Nakashian
f26e64fb54 nb: shutdown on reaching connection or document limit
Change-Id: I5eedaf780ed00804d93c362e83ac4fcfd5d057b1
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
28b3813249 nb: clear the input buffer only on success
With multipart streams the parsing isn't
done until all parts are in. We will need
to reparse the header when more data comes in
until we can parse all parts. Otherwise we
end up removing the header and losing it
when we can't find all parts in the body.

This fixes convert-to requests.

Change-Id: Ic1d5ccbd00fd6763eb91fdda35177f6df847f100
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
88bbc303dc nb: unittest improvements
Change-Id: Ife4ed343d54137f254077d4f194157120cf82bad
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
4b36fc9716 nb: send the WS upgrade response separate from later frames
Apparently if we don't send immediately after the upgrade
the first frame doesn't get parsed as WebSocket (at least
in Poco).

Change-Id: Ieb30afae1423d8352d81c79af568947d10fca1e6
2017-03-10 10:47:41 +01:00
Ashod Nakashian
c845890630 nb: log the test name where possible
Helps troubleshoot failed tests faster.

Change-Id: I12172bcdd46403b902bf440b919916263cb1a02b
2017-03-10 10:47:41 +01:00
Michael Meeks
3df5061a6b Wait for more data pleasantly if we fail to parse HTTP header. 2017-03-10 10:47:41 +01:00