DescriptionChange the handling of closing sockets
Sockets now supports being half-closed for either reading or writing. When a socket is closed it is by default closed for both read and write and the underlying file descriptor is destroyed. However the socket close can be asked to only half-close the socket to send end of stream to the other end and still have the ability to receive more data.
The close event on a socket is only emitted when the socket is closed by the other end. Both half-close and full-close by the other end is reported as a close event. If a socket is already half closed the close event will automatically destroy the socket.
The streams on the sockets also takes advantage of this. A socket input stream will report a close event when the other end closed. A socket output stream will half-close the socket when close is called making it possible to still receive data on the input stream. When both streams have been closed the socket is destroyed.
For sockets operating on pipes they are initially created as half-closed for either reading or writing depending on which type of pipe a socket object is based on. A pipe for writing will start half-closed for reading so if it is only half-closed for writing the socket will still be destroyed. Same with a pipe for reading that will start half-closed for writing and when a close event is received half-closing the other direction will destroy the socket. Socket objects based on pipes are only exposed through streams.
Extended the socket close test to test a number of different scenarios.
Also refactor the socket data C++ object to encapsulate more socket information and operations.
Now the Linux and Mac OS versions are 100% the same as it turned out that using POLLRDHUP on Linux was not required any more.
R=ager@google.com
BUG=
TEST=
Committed: https://code.google.com/p/dart/source/detail?r=1196
Patch Set 1 #Patch Set 2 : Fix SocketCloseTest #Patch Set 3 : Another fix to SocketCloseTest #
Total comments: 10
Patch Set 4 : Addressed review comments from ager@ #Patch Set 5 : Rebase #Patch Set 6 : Windows port and frog patch #
Total comments: 2
Patch Set 7 : Addressed review comments by ager@ #
Messages
Total messages: 5 (0 generated)
|