This patch cleans up the interface of |StreamSocket|. All arguments
that contain protocol parameters are removed from |Connect|. They are
stored in the connector class. |Connect| now returns error codes. The
method |GetSocketAddr| is unused and not thread-safe and therefore
removed. The method |SendSocketData| for strings is unused and removed.
This patch converts the socket I/O classes to use the new interface
of the socket-connector classes. All sockets are now created and set
up by a socket connector.
The current interface of |UnixSocketConnector| doesn't follow any design
and is not easily understandable.
This patch adds a new interface to the class. The new interface provides
a method for each of the following operations:
* converting an address to a human-readable string,
* creating a listening socket,
* creating a stream socket, and
* accepting a stream socket from a listening socket.
All arguments are stored in the connector class, so that connect and
listen methods of the socket classes don't require protocol-specific
arguments. All socket parameters are set within the connector class,
so each connector class can now select parameters individually.
This patch converts the socket I/O classes to use the new interface
of the socket-connector classes. All sockets are now created and set
up by a socket connector.
The current interface of |UnixSocketConnector| doesn't follow any design
and is not easily understandable.
This patch adds a new interface to the class. The new interface provides
a method for each of the following operations:
* converting an address to a human-readable string,
* creating a listening socket,
* creating a stream socket, and
* accepting a stream socket from a listening socket.
All arguments are stored in the connector class, so that connect and
listen methods of the socket classes don't require protocol-specific
arguments. All socket parameters are set within the connector class,
so each connector class can now select parameters individually.
This patch moves the code for setting socket flags in the socket I/O
classes to the few locations were sockets are created. Any other socket
setup is redundant and has been removed.
This patch cleans up the inherited methods of |ListenSocket|. Methods
of the same base class are grouped within the file, and each method is
labeled with 'override'.
This patch cleans up the inherited methods of |StreamSocket|. Methods
of the same base class are grouped within the file, and each method
is labeled with 'override'.
This patch integrates |ConnectionOrientedSocket| into the hierarchy
of socket I/O classes. In future patches, the class can provide
common interfaces and functionality for all connection-oriented
sockets.
This patch removes the template parameters from
|SocketIODeleteInstanceRunnable| and moves its methods into the
C++ source file. All users have been adapted.
This patch removes the template parameters from
|SocketIORequestClosingRunnable| and moves its methods into
the C++ source file. All users have been adapted.
|ReceiveSocketData| receives socket data on the main thread. This
is a specific detail of the current socket classes, which should not
be required by future implementations.
This patch moves the receive method and the corresponding runnable
into socket classes.
This patch moves management of received socket I/O buffers from
|DataSocketIO| into the I/O classes. Each I/O class is responsible
for (de-)allocating buffers, and consuming them once data has been
received.
All current I/O classes forward their buffers to the main thread,
but other operations are possible. For example, received data can
be parsed and processed directly in the I/O thread.
This patch renames |SocketConsumerBase| to |DataSocket|, and for the
I/O classes |SocketConsumerIO| to |DataSocketIO|. |DataSocketIO| also
contains send and receive functionality from |SocketBaseIO|.
|DataSocket| is a virtual base class that represents a socket that
transfers data, without a particular constraints to what the data
represents. |DataSocketIO| is the corresponding helper class on the
I/O thread.
This patch moves memory management of |UnixSocketIOBuffer| into
|UnixSocketBuffer| and extends |UnixSocketIOBuffer| with send and
receive interfaces. The class is now the base for all socket-buffer
classes, such as |UnixSocketRawData| and |BluetoothDaemonPDU|.
The destructor methods of ref-counted classes are supposed to
be non-public to prevent accidential deletion. This patch fixes
|SocketBase|'s destructor.
The listen socket will now send-out CONNECT_SUCCESS after it started
listening. Callers might rely on this event. Before, CONNECT_SUCCESS
in |ListenSocket| was not used by callers.
The new class |ListenSocket| listens on Unix sockets for incoming
connections. Accepted connections are handed over to a compatible
connection-oriented socket.
The class |UnixSocketIOBuffer| maintains memory buffers for socket I/O
operations. The actual I/O is still implemented by subclasses, such as
|UnixSocketRawData|.
The data class in |SocketIOSendTask| is now a template parameter, instead
of being hard-coded to |UnixSocketRawData|. The patch also adds soem minor
cleanups to the file.
This patch moves the I/O operations for sending and receiving data
in |SocketIOBase| into |UnixSocketRawData|. This change allows to
add a clean interface to |UnixSocketRawData| and later replace the
class by other implementations.
Calling read on a socket that has been closed for reading by the
peer, read returns 0. The socket is still readable however, so
polling and reading will return constant results of 0 received
bytes.
With this patch, if a socket's peer shuts down reading or if
we reached the EOF, we stop watching the file descriptor for
readability. |SocketIOBase| will detect this case exactly once
and initiate the socket's shutdown.
After successfully sending data, |SocketIOBase::SendPendingData|
deletes the raw data instead of the actual socket-data object. The
behavior is undefined and leads to a segmentation fault.
This patch fixes the bug by deleting the correct object.
This patch cleans up |UnixSocketImpl| and it's file in general. The
patch
- renames |UnixSocketImpl| to |UnixSocketConsumerIO|,
- moves method definitions out of class definition,
- adds const correctness,
- adds MOZ_FINAL to several classes,
- moves task classes to a separate location.
No functional changes are performed.
|SocketIOTask| is a task-class template that holds a reference to
a Socket I/O object. It replaces |UnixSocketImplTask|, which only
supports objects of type |UnixSocketImpl|.
|SocketIOBase| is a base class for Socket I/O classes. It's not a
requirement, but provides a number of helpful methods for common
I/O operations on the I/O thread.
|SocketIODeleteInstanceRunnable| deletes a Socket I/O object on the
main thread. This is required to serialize the close operation of
Socket consumers.