|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.
UnixSocketImpl, which mostly runs on the I/O thread, doesn't control
its reference to UnixSocketConsumer. If the connection status is
stored in UnixSocketConsumer, the I/O thread can't read it safely.
This patch duplicates the connection status in UnixSocketImpl, where
reading from the I/O thread is safe. Methods of UnixSocketImpl don't
need to access mConsumer any longer to obtain the connection status.
We used to allocate memory on the stack when reading from a file
descriptor and copied the result into an instance of UnixSocketRawData.
This patch
- cleans up the interface of UnixSocketRawData,
- removes the large stack allocation (64KiB), and
- removes the unnecessary memcpy.
Other memcpys for sending data have been moved into the constructor
of UnixSocketRawData.
--HG--
extra : rebase_source : 46ed1c73481732c3f3350bf0bedb56d376c24e98
r=tbsaunde for accessible
r=jmuizelaar for gfx
r=roc for layout
r=glandium for mozglue
r=jduell for netwerk
r=khuey for everything else
This is a mechanical change made with sed. Later patches in this queue
clean up the whitespace errors and so on.
This version of BlueZ from Code Aurora has added GOEP_PSM to Object
Push Profile service record, which means that remote devices may
connect with us via both L2CAP and RFCOMM. This patch completes
L2CAP/EL2CAP socket implementation.