Commit graph

320 commits

Author SHA1 Message Date
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
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
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
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
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
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
62afe66df0 nb: Make the loolnb / clientnb work again.
The more testing the better :-)

Change-Id: Ibe4249f18109d50b06e1fa35e6d0fef67f9b3643
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
Ashod Nakashian
a68c33477d nb: support inserting image
Change-Id: I6ef11634bbda7e3ecdc467ce10727c8573caef8d
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
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
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
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
Michael Meeks
3df5061a6b Wait for more data pleasantly if we fail to parse HTTP header. 2017-03-10 10:47:41 +01:00
Ashod Nakashian
f08d9c9ec1 nb: handle bad requests with 400 response
Change-Id: I15ecc06a933a88f5ccdd0acfd16aac8b357f29df
2017-03-10 10:47:41 +01:00
Ashod Nakashian
ccdb1bcc6e nb: proper POST body processing
Change-Id: Ic37094e50979e14d2862ae32088295b42d9c4931
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
Ashod Nakashian
df45db9da2 nb: shutdown socket after file-serving
Change-Id: Ibe0b33f371d46e62637f570265fcdf9c8bf60b2d
2017-03-10 10:47:41 +01:00
Ashod Nakashian
925934d09d nb: set the Date in http header
Change-Id: I71e3388c1f204135c6dc72ad27890bffe53792b3
2017-03-10 10:47:41 +01:00
Ashod Nakashian
0759d1afbc nb: http error cases in file server
Change-Id: I81b0ef3f080ba61836d99fbdde0fb94e1a44a625
2017-03-10 10:47:41 +01:00
Ashod Nakashian
1bb29282f1 nb: serve files using non-blocking sockets
Change-Id: I254288980f72f197d29b7b57ec9c88a01a5a1d03
2017-03-10 10:47:40 +01:00
Ashod Nakashian
ba8d3c8eb1 nb: log requests as debug and not error
Change-Id: Ic3ec3257f98c80e959c9d980fe6b1d8d6f40f604
2017-03-10 10:47:40 +01:00
Ashod Nakashian
c8619bed1f nb: respond with HTTP 200 on root
Change-Id: Icfcf8d79d5b6370b7965584e89e9006d7bd451b3
2017-03-10 10:47:40 +01:00
Ashod Nakashian
de92b1627e nb: send files over HTTP
Change-Id: I346e97cd19a8dbbdee493d23b89c390ea6e3c948
2017-03-10 10:47:40 +01:00
Ashod Nakashian
0d9bbac18c nb: serve wopi discovery XML
Change-Id: I7bb4910f948e8b4e89f3bbdf2a62a8b1540eef2f
2017-03-10 10:47:40 +01:00
Ashod Nakashian
9bf8720d2b nb: SSL socket support in wsd
Change-Id: I21e8b2d04caf7da872fe07b4950b02a8c52a3552
2017-03-10 10:47:40 +01:00
Ashod Nakashian
2b4e7bd067 nb: SocketHandlerInterface must hold weak_ptr to Socket
Because the socket can be freed while a separate
thread is sending data via the handler, we must
have a locked reference to the socket instance
in the handler.

Change-Id: Iefad3fc2b147f96b8d538d9edd7cac3fce25b5bf
2017-03-10 10:47:40 +01:00
Ashod Nakashian
32b7d5ceee nb: WebSocketSender used to send back loading progress
Change-Id: I3b09c44c4d64db39217d364ebff0a647a82457f4
2017-03-10 10:47:40 +01:00
Ashod Nakashian
5b944cf99b nb: don't own your owner
Change-Id: Ia74dbd3441b8b1f682091ba3d973dd33b2599309
2017-03-10 10:47:40 +01:00
Ashod Nakashian
66bc78aa33 nb: differentiate between incomplete request and processing failure
Change-Id: Ieffae987c9008a92d8040f0c4315afe6625715c4
2017-03-10 10:47:40 +01:00
Ashod Nakashian
221059cd6b nb: move WebSocket upgrade to the ClientRequestDispatcher
Change-Id: Id11b139563a55e50d3f7e216e2231d79e07015b3
2017-03-10 10:47:40 +01:00
Ashod Nakashian
73f9001004 nb: remove HTTP handling from WebSocketHandler
WebSocketHandler now supports upgrading given
the original HTTP header.

Change-Id: Ifb3b8fee9aef8015548a625bbb88e75f4e97255f
2017-03-10 10:47:40 +01:00
Ashod Nakashian
6b28ea0c12 nb: autosave document on client disconnection
Change-Id: Ic75a9796a1cca0bf919fb2dcbe24c504e447e7f1
2017-03-10 10:47:40 +01:00
Ashod Nakashian
3b3b61af30 nb: create and assign ClientSession to DocumentBroker
Change-Id: I684007363de6e25d78f9f1c9236fd623325da509
2017-03-10 10:47:40 +01:00