summaryrefslogtreecommitdiff
path: root/nuttx
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2015-02-01 08:52:26 -0600
committerGregory Nutt <gnutt@nuttx.org>2015-02-01 08:52:26 -0600
commitb8cb626af9bcd00611b4dcb5e2b491cd1b714191 (patch)
tree5635b1cea98de725f819eaf48250142deb4677b9 /nuttx
parentcbeb0d860dfd5bc0195f20f716325fa79c0521b7 (diff)
downloadpx4-nuttx-b8cb626af9bcd00611b4dcb5e2b491cd1b714191.tar.gz
px4-nuttx-b8cb626af9bcd00611b4dcb5e2b491cd1b714191.tar.bz2
px4-nuttx-b8cb626af9bcd00611b4dcb5e2b491cd1b714191.zip
Unix domain: Enable logic to clean up the FIFOs underlying stream sockets with those sockets are disconnected. Tehre is still no corresponding clean-up logic in place for Unix domain datagram sockets because the life of the FIFO is not as well known in that case
Diffstat (limited to 'nuttx')
-rw-r--r--nuttx/TODO44
-rw-r--r--nuttx/net/local/local_fifo.c32
2 files changed, 48 insertions, 28 deletions
diff --git a/nuttx/TODO b/nuttx/TODO
index 14dcaf1f5..545420d5b 100644
--- a/nuttx/TODO
+++ b/nuttx/TODO
@@ -826,13 +826,12 @@ o Network (net/, drivers/net)
Title: SOCKETS DO NOT ALWAYS SUPPORT O_NONBLOCK
Description: sockets do not support all modes for O_NONBLOCK. Sockets
- support only (1) TCP/IP non-blocking read operations when read-ahead
- buffering is enabled, (2) TCP/IP accept() operations when TCP/IP
- connection backlog is enabled, and (3) nonblocking operations on
- Unix domain sockets.
- REVISIT: UDP read-ahead buffering has been implemented. But I
- do not think that the necessary bits of logic are in place to
- permit non-clocking UDP reads.
+ support nonblocking operations only (1) for TCP/IP non-
+ blocking read operations when read-ahead buffering is
+ enabled, (2) TCP/IP accept() operations when TCP/IP
+ connection backlog is enabled, (2) UDP/IP read() operations
+ when UDP read-ahead is enabled, and (3) non-blocking
+ operations on Unix domain sockets.
Status: Open
Priority: Low.
@@ -923,20 +922,23 @@ o Network (net/, drivers/net)
Status: Open
Priority: Low, this is just a nuisance in most cases.
- Title: FIFO CLEAN-UP AFTER CLOSING UNIX DOMAIN SOCKET
- Description: FIFOs are used as the IPC underlying local Unix domain sockets.
- In NuttX, FIFOs are implemented as device drivers (not as
- special files). The FIFO device driver is instantiated when
- the Unix domain socket communications begin and will
- automatically be released when (1) the driver is unlinked and
- (2) all open references to the driver have been closed. But
- there is no mechanism in place now to unline the FIFO when
- the Unix domain socket is no longer used. The primary issue
- is timing.. the FIFO should persist until it is no longer
- needed. Perhaps there should be a delayed call to unlink()
- (using a watchdog or the work queue). If the driver is re-
- opened, the delayed unlink could be canceled? Needs more
- thought.
+ Title: FIFO CLEAN-UP AFTER CLOSING UNIX DOMAIN DATAGRAM SOCKET
+ Description: FIFOs are used as the IPC underlying all local Unix domain
+ sockets. In NuttX, FIFOs are implemented as device drivers
+ (not as a special FIFO files). The FIFO device driver is
+ instantiated when the Unix domain socket communications begin
+ and will automatically be released when (1) the driver is
+ unlinked and (2) all open references to the driver have been
+ closed. But there is no mechanism in place now to unlink the
+ FIFO when the Unix domain datagram socket is no longer used.
+ The primary issue is timing.. the FIFO should persist until
+ it is no longer needed. Perhaps there should be a delayed
+ call to unlink() (using a watchdog or the work queue). If
+ the driver is re-opened, the delayed unlink could be
+ cancelled? Needs more thought.
+ NOTE: This is not an issue for Unix domain streams sockets:
+ The end-of-life of the FIFO is well determined when sockets
+ are disconnected and support for that case is fully implemented.
Status: Open
Priority: Low for now because I don't have a situation where this is a
problem for me. If you use the same Unix domain paths, then
diff --git a/nuttx/net/local/local_fifo.c b/nuttx/net/local/local_fifo.c
index 42a59fa4c..cb94f7519 100644
--- a/nuttx/net/local/local_fifo.c
+++ b/nuttx/net/local/local_fifo.c
@@ -193,17 +193,17 @@ static int local_create_fifo(FAR const char *path)
static int local_release_fifo(FAR const char *path)
{
+ int ret;
+
/* Unlink the client-to-server FIFO if it exists. */
if (local_fifo_exists(path))
{
- /* REVISIT: This is wrong! Un-linking the FIFO does not eliminate it;
- * it only removes it from the namespace. A new interface will be
- * required to destroy the FIFO driver instance and all of its resources.
+ /* Un-linking the FIFO removes the FIFO from the namespace. It will
+ * also mark the FIFO device "unlinked". When all of the open
+ * references to the FIFO device are closed, the resources consumed
+ * by the device instance will also be freed.
*/
-#warning Missing logic
-#if 0
- int ret;
ret = unlink(path);
if (ret < 0)
@@ -214,7 +214,6 @@ static int local_release_fifo(FAR const char *path)
ndbg("ERROR: Failed to unlink FIFO %s: %d\n", path, errcode);
return -errcode;
}
-#endif
}
/* The FIFO does not exist or we successfully unlinked it. */
@@ -440,6 +439,24 @@ int local_release_halfduplex(FAR struct local_conn_s *conn)
#ifdef CONFIG_NET_LOCAL_STREAM
int local_open_client_rx(FAR struct local_conn_s *client, bool nonblock)
{
+#if 1
+ /* REVIST: We need to think about this carefully. Unlike the connection-
+ * oriented Unix domain socket, we don't really know the best time to
+ * release the FIFO resource. It would be extremely inefficient to create
+ * and destroy the FIFO on each packet. But, on the other hand, failing
+ * to destory the FIFO will leave the FIFO resources in place after the
+ * communications have completed.
+ *
+ * I am thinking that ther should be something like a timer. The timer
+ * would be started at the completion of each transfer and cancelled at
+ * the beginning of each transfer. If the timer expires, then the FIFO
+ * would be destroyed.
+ */
+
+# warning Missing logic
+ return OK;
+
+#else
char path[LOCAL_FULLPATH_LEN];
int ret;
@@ -458,6 +475,7 @@ int local_open_client_rx(FAR struct local_conn_s *client, bool nonblock)
}
return ret;
+#endif
}
#endif /* CONFIG_NET_LOCAL_STREAM */