Commit Graph

167 Commits

Author SHA1 Message Date
Thomas Zimmermann
86db93eaf2 Bug 1161020: Remove old interface and implementation from socket-connector classes, r=kmachulis 2015-05-19 13:28:46 +02:00
Thomas Zimmermann
1097a756a3 Bug 1161020: Use new socket-connector interface in socket classes, r=kmachulis
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.
2015-05-19 13:28:46 +02:00
Thomas Zimmermann
7dc01cb0eb Bug 1161020: Added clean interface to |UnixSocketConnector|, r=kmachulis
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.
2015-05-19 13:28:46 +02:00
Carsten "Tomcat" Book
03af28a47e Backed out 8 changesets (bug 1161020) for b2g ics emulator debug mochitest memory leaks on a CLOSED TREE
Backed out changeset 976e19eac8b5 (bug 1161020)
Backed out changeset 4f782be31f87 (bug 1161020)
Backed out changeset 384de663084c (bug 1161020)
Backed out changeset a8f42d85ce3f (bug 1161020)
Backed out changeset ac23206e80bd (bug 1161020)
Backed out changeset 34a20b05af6c (bug 1161020)
Backed out changeset 13753f9043f7 (bug 1161020)
Backed out changeset f90b8d3d6b70 (bug 1161020)
2015-05-18 15:01:27 +02:00
Thomas Zimmermann
71a19f39a9 Bug 1161020: Remove old interface and implementation from socket-connector classes, r=kmachulis 2015-05-18 11:28:30 +02:00
Thomas Zimmermann
cff86911f3 Bug 1161020: Use new socket-connector interface in socket classes, r=kmachulis
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.
2015-05-18 11:28:30 +02:00
Thomas Zimmermann
31fe56c843 Bug 1161020: Added clean interface to |UnixSocketConnector|, r=kmachulis
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.
2015-05-18 11:28:30 +02:00
Thomas Zimmermann
392fa0aab5 Bug 1162585: Set socket flags after socket has been created, r=kmachulis
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.
2015-05-08 09:45:42 +02:00
Thomas Zimmermann
685e9b30e8 Bug 1162524: Move |accept| out of |UnixSocketWatcher|, r=kmachulis
Calls to |accept| are now handled by the corresponding socket I/O
class. This makes the code more flexible. All callers have been
adapted.
2015-05-08 09:43:01 +02:00
Thomas Zimmermann
5cab8e5006 Bug 1159709: Cleanup inherited methods of |ListenSocket|, r=kmachulis
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'.
2015-04-30 12:55:37 +02:00
Thomas Zimmermann
b61c68c1ca Bug 1159709: Cleanup inherited methods of |StreamSocket|, r=kmachulis
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'.
2015-04-30 12:55:37 +02:00
Thomas Zimmermann
f21f5cd47f Bug 1159709: Integrate |ConnectionOrientedSocket| into socket I/O class hierarchy, r=kmachulis
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.
2015-04-30 12:55:37 +02:00
Thomas Zimmermann
b3af1051a9 Bug 1159209: Remove template parameters from |DataSocketIO|, r=kmachulis
This patch removes the template parameters from |DataSocketIO| and
moves its methods into the C++ source file. All users have been
adapted.
2015-04-29 11:19:28 +02:00
Thomas Zimmermann
a076ff736c Bug 1159209: Remove template parameters from |SocketIOShutdownTask|, r=kmachulis
This patch removes the template parameters from |SocketIOShutdownTask|
and moves its methods into the C++ source file. All users have been
adapted.
2015-04-29 11:19:28 +02:00
Thomas Zimmermann
1df9dd995c Bug 1159209: Remove template parameters from |SocketIODeleteInstanceRunnable|, r=kmachulis
This patch removes the template parameters from
|SocketIODeleteInstanceRunnable| and moves its methods into the
C++ source file. All users have been adapted.
2015-04-29 11:19:28 +02:00
Thomas Zimmermann
2aac7d4aa4 Bug 1159209: Remove template parameters from |SocketIORequestClosingRunnable|, r=kmachulis
This patch removes the template parameters from
|SocketIORequestClosingRunnable| and moves its methods into
the C++ source file. All users have been adapted.
2015-04-29 11:19:28 +02:00
Thomas Zimmermann
a780955c3e Bug 1159209: Remove template parameters from |SocketIOEventRunnable|, r=kmachulis
This patch removes the template parameters from |SocketIOEventRunnable|
and moves its methods into the C++ source file. All users have been
adapted.
2015-04-29 11:19:28 +02:00
Thomas Zimmermann
71aaba0c24 Bug 1158876: Move |DataSocket::ReceiveSocketData| into sub classes, r=kmachulis
|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.
2015-04-28 10:18:13 +02:00
Thomas Zimmermann
358002fcbd Bug 1158876: Move management of socket I/O buffers into socket I/O classes, r=kmachulis
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.
2015-04-28 10:18:13 +02:00
Thomas Zimmermann
f1427ebbb7 Bug 1158876: Rename |SocketConsumerBase| to |DataSocket|, r=kmachulis
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.
2015-04-28 10:18:12 +02:00
Thomas Zimmermann
0f58b21c4e Bug 1156352: Remove |UnixSocketRawData| from socket I/O interfaces, r=kmachulis 2015-04-23 13:48:48 +02:00
Thomas Zimmermann
d7d719ed77 Bug 1156352: Refactor |UnixSocketIOBuffer|, r=kmachulis
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|.
2015-04-23 13:48:47 +02:00
Thomas Zimmermann
450903b88b Bug 1154281: Remove |UnixSocketConsumer| and its helpers, r=kmachulis 2015-04-21 10:33:06 +02:00
Andrea Marchesini
b212600c95 Bug 1148527 - Indentation fix after bug 1145631, r=ehsan 2015-03-27 18:52:19 +00:00
Ehsan Akhgari
33bb32f549 Bug 1145631 - Part 1: Replace MOZ_OVERRIDE and MOZ_FINAL with override and final in the tree; r=froydnj
This patch was automatically generated using the following script:

function convert() {
echo "Converting $1 to $2..."
find . \
       ! -wholename "*/.git*" \
       ! -wholename "obj-ff-dbg*" \
         -type f \
      \( -iname "*.cpp" \
         -o -iname "*.h" \
         -o -iname "*.c" \
         -o -iname "*.cc" \
         -o -iname "*.idl" \
         -o -iname "*.ipdl" \
         -o -iname "*.ipdlh" \
         -o -iname "*.mm" \) | \
    xargs -n 1 sed -i -e "s/\b$1\b/$2/g"
}

convert MOZ_OVERRIDE override
convert MOZ_FINAL final
2015-03-21 12:28:04 -04:00
Thomas Zimmermann
2a810f7896 Bug 1136729: Make destructor of |SocketBase| protected, r=qdot
The destructor methods of ref-counted classes are supposed to
be non-public to prevent accidential deletion. This patch fixes
|SocketBase|'s destructor.
2015-03-02 10:23:52 +01:00
Thomas Zimmermann
7a10047f6e Bug 1119746: Signal active listening in |ListenSocket|, r=qdot
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.
2015-01-20 10:17:19 +08:00
Botond Ballo
b08ca88b2a Bug 1073081 - Fix -Wsign-compare and -Wsign-conversion warnings. r=ehsan
--HG--
extra : source : 88c58a8cc276a4691ed23fd8b8f2f6c0713b50fd
2014-11-24 19:54:33 -05:00
Thomas Zimmermann
6124722821 Bug 1093025: Add |StreamSocket|, r=kyle
|StreamSocket| implements a |ConnectionOrientedSocket| for stream
sockets. It utilizes |ListenSocket| to wait for incoming connection
requests.
2014-12-02 15:00:36 -08:00
Thomas Zimmermann
5cee256658 Bug 1093025: Add |ListenSocket|, r=kyle
The new class |ListenSocket| listens on Unix sockets for incoming
connections. Accepted connections are handed over to a compatible
connection-oriented socket.
2014-12-02 15:00:36 -08:00
Thomas Zimmermann
6d07312483 Bug 1093025: Move |UnixSocketConnector| to separate file, r=kyle
|UnixSocketConnector| will be shared by |UnixSocketConsumer| and
the upcoming listen and stream sockets.
2014-12-02 15:00:36 -08:00
Gina Yeh
f093ed9a75 Bug 1091479, Patch2: Rename enum members, r=sinker. 2014-11-24 09:47:39 +08:00
Thomas Zimmermann
395962fa36 Bug 1083092: Add |mozilla::ipc::UnixSocketIOBuffer|, r=shawnjohnjr
The class |UnixSocketIOBuffer| maintains memory buffers for socket I/O
operations. The actual I/O is still implemented by subclasses, such as
|UnixSocketRawData|.
2014-10-21 10:52:12 +02:00
Thomas Zimmermann
7bf2af4097 Bug 1083092: Data parameter for |mozilla::ipc::SocketIOSendTask| template, r=shawnjohnjr
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.
2014-10-21 10:52:12 +02:00
Thomas Zimmermann
e86ec92e48 Bug 1083092: Introduce |mozilla::ipc::SocketBase|, r=shawnjohnjr
The new class |SocketBase| contains the notification mechanism of
|SocketConsumerBase|. The latter still contains I/O methods.
2014-10-21 10:52:11 +02:00
Thomas Zimmermann
32d01f27e1 Bug 1059813: Protect access to fields of |UnixSocketRawData|, r=qdot
This patch adds protection for fields of |UnixSocketRawData| by
making them private.
2014-09-08 11:44:02 +02:00
Thomas Zimmermann
452351cf5c Bug 1059813: Wrap socket I/O operations in |UnixSocketRawData|, r=qdot
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.
2014-09-08 11:44:00 +02:00
Thomas Zimmermann
cfe17e277b Bug 1062754: Support peer shutdown and EOF in |SocketIOBase|, r=qdot, btian
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.
2014-09-05 10:16:24 +02:00
Andrew Osmond
0c797b1728 Bug 1055316 - Fix unix socket connect backoff scheme such that it will actually backoff. r=tzimmermann 2014-08-18 15:53:00 -04:00
Thomas Zimmermann
2361eec5bb Bug 1048093: Delete sent socket-data objects instead of raw data, r=kyle
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.
2014-08-11 09:36:15 +02:00
Thomas Zimmermann
ea4744aa25 Bug 1046109: Cleanup |UnixSocketImpl|, r=kyle
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.
2014-07-31 13:55:30 +02:00
Thomas Zimmermann
ae46aec1d3 Bug 1046109: Add |SocketIOShutdownTask|, r=kyle
|SocketIOShutdownTask| invokes the shutdown procedure for Socket I/O
objects on the I/O thread.
2014-07-31 13:55:30 +02:00
Thomas Zimmermann
e57e07d8d1 Bug 1046109: Add |SocketIOSendTask|, r=kyle
|SocketIOSendTask| moves data from the main thread to the Socket I/O
class on the I/O thread, and invokes the Socket I/O classes sending
methods.
2014-07-31 13:55:30 +02:00
Thomas Zimmermann
8f2f04ce2a Bug 1046109: Add |SocketIOTask|, r=kyle
|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|.
2014-07-31 13:55:29 +02:00
Thomas Zimmermann
5866e150ca Bug 1046109: Add |SocketIOBase|, r=kyle
|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.
2014-07-31 13:55:29 +02:00
Thomas Zimmermann
63e43f2cc7 Bug 1046109: Add |SocketIODeleteInstanceRunnable|, r=kyle
|SocketIODeleteInstanceRunnable| deletes a Socket I/O object on the
main thread. This is required to serialize the close operation of
Socket consumers.
2014-07-31 13:55:29 +02:00
Thomas Zimmermann
17664c3055 Bug 1046109: Add |SocketIORequestClosingRunnable|, r=kyle
|SocketIORequestClosingRunnable| notifies the Socket consumer on
the main thread to clean up the Socket I/O object and close the
connection.
2014-07-31 13:55:28 +02:00
Thomas Zimmermann
1e99e98b9c Bug 1046109: Add |SocketIOReceiveRunnable|, r=kyle
|SocketIOReceiveRunnable| sends received data from the Socket I/O
object on the I/O thread to the Socket consumer on the main thread.
2014-07-31 13:55:28 +02:00
Thomas Zimmermann
b7e43001ca Bug 1046109: Add |SocketIOEventRunnable|, r=kyle
|SocketIOEventRunnable| sends a notification from the Socket I/O
object to a Socket consumer on the main thread.
2014-07-31 13:55:28 +02:00
Thomas Zimmermann
244a4a0fdd Bug 1046109: Add |SocketIORunnable|, r=kyle
|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|.
2014-07-31 13:55:28 +02:00