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.
|SocketIORunnable| is a runnable class template that holds a
reference to a arbitrary Socket I/O object. |SocketIORunnable|
replaces |UnixSocketImplRunnable|, which only handles objects of
type |UnixSocketImpl|.
|SocketConsumerBase| handles connection state for |UnixSocketConsumer|
and its derived classes. Implementing classes must override a number of
virtual methods, to handle notifications about changes to the state of
the connection.
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, and
- 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.
|SocketIORunnable| is a runnable class template that holds a
reference to a arbitrary Socket I/O object. |SocketIORunnable|
replaces |UnixSocketImplRunnable|, which only handles objects of
type |UnixSocketImpl|.
|SocketConsumerBase| handles connection state for |UnixSocketConsumer|
and its derived classes. Implementing classes must override a number of
virtual methods, to handle notifications about changes to the state of
the connection.
|SocketSendTask| acquires a reference to |UnixSocketConsumer| on
the main thread and releases this reference on the I/O thread;
leading to race-conditions. This patch adds
- atomicity for ref-counting of |UnixSocketConsumer|, and
- stricter tests in the destructor of this class.
This patch cleans up runnables and tasks in UnixSocket.cpp. Every
runnable's name now ends in Runnable. There are a base classes for
runnables and tasks that hold reference to UnixSocketImpl and from
which all runnables and tasks inherit.
We cannot use blocking file-descriptor I/O on the I/O thread. This
patch adds an assertion to UnixFdWatcher the tests for the O_NONBLOCK
flag, when installing a file descriptor. In UnixFileWatcher, the
Open method tests for the O_NONBLOCK flag for the opened file.
File-descriptor flags for UnixSocketImpl et al are currently set by
UnixSocketImpl itself. Later patches should move this into the
methods of connector classes.
This patch cleans up the implementation of UnixSocketImpl by
- inlining all calls to SetUpIO,
- removing the unsued constant SOCKET_RETRY_TIME_MS, and
- separating logging from Bluetooth.
The base class UnixSocketWatcher handles the connection state of
the socket. UnixSocketImpl overrides UnixSocketWatcher's callback
methods for implementing it's functionality.
UnixSocketConsumer now maintains a delay for re-establishing closed
connection. The initial delay is zero, so that the first connect call
is processed immediately. At the first failed attempt to connect, the
delay is set to ~1 second, and is increased by a factor of 2 on each
successive error until it reaches ~1 minute.
The UnixSocketConsumer code resets the delay to zero if it is lower
than the time that the connection was open. This heuristics protects
against cases where the peer establishes a connection, and closes it
shortly afterwards. Incompatible versions of rild show this behavior.