This patch finally breaks up forwarding received RIL messages to the
main thread before they go to the RIL worker. Any RIL message that is
received on th I/O thread is forwarded directly to the RIL worker
thread and handed over to the RIL worker JS code.
The patch includes a number of changes. They all depend on each other,
so there's no good way of landing them one-by-one.
* |RilConsumer| now runs on the RIL worker thread.
* |RilWorker| uses tasks to register/unregister |RilConsumer| in the worker.
* |RilConsumer| uses |RilSocket| instead of |StreamSocket|.
* With |RilSocket|, received RIL messages do not go through main. They are
forwared to the RIL worker and handed over to JS immediately.
This patch separates the current interface of |RilConsumer| into
two distinct classes. |RilWorker| provides the public interface
and |RilConsumer| provides the internal implementation. Running
|RilConsumer| on a worker thread will be easier this way.
With this patch, |RilSocket| and it's helpers forward received data
via a WCTD. This will hand over the worker's JS context to the RIL
consumer.
In a later patch, the RIL consumer will be moved onto the RIL worker
thread and call the JS ril-worker code directly.
|RilSocket| and |RilSocketConsumer| are copies of the respective stream-
socket classes. Improvements to the RIL I/O code will be implemented on
top of the new classes.
--HG--
rename : ipc/unixsocket/StreamSocket.cpp => ipc/ril/RilSocket.cpp
rename : ipc/unixsocket/StreamSocket.h => ipc/ril/RilSocket.h
rename : ipc/unixsocket/StreamSocketConsumer.cpp => ipc/ril/RilSocketConsumer.cpp
rename : ipc/unixsocket/StreamSocketConsumer.h => ipc/ril/RilSocketConsumer.h
This patch finally breaks up forwarding received RIL messages to the
main thread before they go to the RIL worker. Any RIL message that is
received on th I/O thread is forwarded directly to the RIL worker
thread and handed over to the RIL worker JS code.
The patch includes a number of changes. They all depend on each other,
so there's no good way of landing them one-by-one.
* |RilConsumer| now runs on the RIL worker thread.
* |RilWorker| uses tasks to register/unregister |RilConsumer| in the worker.
* |RilConsumer| uses |RilSocket| instead of |StreamSocket|.
* With |RilSocket|, received RIL messages do not go through main. They are
forwared to the RIL worker and handed over to JS immediately.
This patch separates the current interface of |RilConsumer| into
two distinct classes. |RilWorker| provides the public interface
and |RilConsumer| provides the internal implementation. Running
|RilConsumer| on a worker thread will be easier this way.
With this patch, |RilSocket| and it's helpers forward received data
via a WCTD. This will hand over the worker's JS context to the RIL
consumer.
In a later patch, the RIL consumer will be moved onto the RIL worker
thread and call the JS ril-worker code directly.
|RilSocket| and |RilSocketConsumer| are copies of the respective stream-
socket classes. Improvements to the RIL I/O code will be implemented on
top of the new classes.
--HG--
rename : ipc/unixsocket/StreamSocket.cpp => ipc/ril/RilSocket.cpp
rename : ipc/unixsocket/StreamSocket.h => ipc/ril/RilSocket.h
rename : ipc/unixsocket/StreamSocketConsumer.cpp => ipc/ril/RilSocketConsumer.cpp
rename : ipc/unixsocket/StreamSocketConsumer.h => ipc/ril/RilSocketConsumer.h
The bulk of this commit was generated by running:
run-clang-tidy.py \
-checks='-*,llvm-namespace-comment' \
-header-filter=^/.../mozilla-central/.* \
-fix
We were deallocating very small regions instead of the entire
region we had originally allocated. Mamma mia!
--HG--
extra : commitid : KlEr9q3Lnxj
extra : rebase_source : d72c362347354a7384790788e0e48feba0dbe69a
The class |DaemonSocket| and its helpers implement a service-
neutral connection to a HAL daemon. This patch moves the code
to an appropriate directory and breaks up the code into smaller
pieces.
--HG--
rename : ipc/bluetooth/BluetoothDaemonConnection.cpp => ipc/hal/DaemonSocket.cpp
rename : ipc/bluetooth/BluetoothDaemonConnection.h => ipc/hal/DaemonSocket.h
rename : ipc/bluetooth/BluetoothDaemonConnectionConsumer.cpp => ipc/hal/DaemonSocketConsumer.cpp
rename : ipc/bluetooth/BluetoothDaemonConnectionConsumer.h => ipc/hal/DaemonSocketConsumer.h
rename : ipc/bluetooth/moz.build => ipc/hal/moz.build
Dispatching events via |nsIThread| doesn't work with worker threads. This
patch replaces all uses of |nsIThread| in the socket code by equivalent
uses of |MessageLoop|.
Different users of the socket I/O code have different requirements
for their I/O buffers. This patch moves the buffer management into
sub-classes of |UnixSocketBuffer|. Each of them can maintain memory
according to its needs.
Make it harder for users to accidentally reintroduce usage of the PR_LOG macros
when using 'mozilla/Logging.h'. This can still be worked around by directly
including 'prlog.h' (and not 'mozilla/Logging.h') if absolutely necessary.
The socket IPC interfaces still use 'main thread' in a number of
places. This patch changes all such interfaces and documentation
to speak of 'consumer thread' instead.
The consumer thread handles socket creation, destruction, and
data processing for socket IPC. Traditionally this has been
done on the main thread.
This patch extends the socket IPC classes to support arbitrary
consumer threads. The thread is configured when establishing a
connection, and performs all of the above operations until the
socket is closed.
The I/O thread sends and receives data on a file descriptor. This
has traditionally been performed on a single I/O thread.
This patch extends the socket IPC classes to support arbitrary I/O
threads. The thread is configured when a connection is established
and used until the socket gets closed.
Both types, |union sockaddr_any| and |struct sockaddr_storage|, provide
a sockaddr type that can hold any address. The latter is standardized by
POSIX, so we prefer it.
This patch integrates the functionality of |BluetoothDaemonChannel|
into |BluetoothDaemonConnection|. All users are adapted, the former
class is removed.
This patch converts |ListenSocket| to forward events to an instance
of |ListenSocketConsumer|. All users are converted and the related
listener and consumer classes are removed.
This patch converts |StreamSocket| to forward events and data to an
instance of |StreamSocketConsumer|. All users are converted and the
related listener and consumer classes are removed.
With this patch, stream and listening sockets handle the setup of
accepted sockets internally. Sub-classes of |StreamSocket| don't
have to overload StreamSocket's |GetIO| any longer.
The new method |UnixSocketConnector::Duplicate| allows a socket
connector to duplicate itself. Listening sockets will used this
feature to create socket connectors for accepted connections.
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 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.
Make it harder for users to accidentally reintroduce usage of the PR_LOG macros
when using 'mozilla/Logging.h'. This can still be worked around by directly
including 'prlog.h' (and not 'mozilla/Logging.h') if absolutely necessary.
Make it harder for users to accidentally reintroduce usage of the PR_LOG macros
when using 'mozilla/Logging.h'. This can still be worked around by directly
including 'prlog.h' (and not 'mozilla/Logging.h') if absolutely necessary.
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.
CLOSED TREE
Backed out changeset 12ce98475c6e (bug 1119980)
Backed out changeset bdb8d05f8870 (bug 1119980)
Backed out changeset a68a18840492 (bug 1119980)
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.
With this patch, it's not an error if the connection operations
stalls on a non-blocking socket; so don't return an error code.
The patch also makes |connect| restart if it was aborted by a
signal.
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.
With the current code, the Bluetooth result runnable is saved for
receiving before a command has been sent successfully. If sending
fails afterwards, the saved result runnable will still sit in the
result queue, and interfere with later, successful commands.
With this patch, the result runnable is saved only if the sending
was successful.
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.