From 4c89703789c90aebda3e0c1e10653d01545fa4dd Mon Sep 17 00:00:00 2001 From: patacongo Date: Sun, 27 Jul 2008 19:26:57 +0000 Subject: [PATCH] Fix detection of final close git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@787 42af7a65-404d-4744-a932-0658087f49c3 --- TODO | 17 +++++++++++++---- drivers/pipe.c | 8 +++----- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/TODO b/TODO index 915c74310b..bc91875500 100644 --- a/TODO +++ b/TODO @@ -10,7 +10,7 @@ NuttX TODO List (Last updated February 13, 2008) (11) Network (net/, netutils/) (2) USB (drivers/usbdev) (3) Libraries (lib/) - (4) File system/Generic drivers (fs/, drivers/) + (5) File system/Generic drivers (fs/, drivers/) (1) Pascal add-on (pcode/) (2) Documentation (Documentation/) (3) Build system @@ -221,7 +221,7 @@ o Libraries (lib/) o File system / Generic drivers (fs/, drivers/) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - Description: Add chmod(), truncate(). + Description: Implement chmod(), truncate(). Status: Open Priority: Low @@ -235,10 +235,19 @@ o File system / Generic drivers (fs/, drivers/) Description: There is no way to remove a FIFO or PIPE created in the psuedo filesystem. Once created, they persist indefinitely - and cannot be unlinked. - Status: Open + and cannot be unlinked. This is actually a more generic + issue: unlink does not work for anything in the psuedo- + filesystem. + Status: Open, but partially resolved: pipe buffer is at least freed + when there are not open references to the pipe/FIFO. Priority: Medium + Desccripton: dup and dup2 need to call into driver. Most drivers + will maintain internal open counts. dup and dup2 logically + increase the open count but do not interact with the driver + Status: Open + Priority: Medium + o Pascal Add-On (pcode/) ^^^^^^^^^^^^^^^^^^^^^^ diff --git a/drivers/pipe.c b/drivers/pipe.c index 8c06974b16..5e0b2f6e5a 100644 --- a/drivers/pipe.c +++ b/drivers/pipe.c @@ -133,7 +133,6 @@ static int pipe_close(FAR struct file *filep) { struct inode *inode = filep->f_inode; struct pipe_dev_s *dev = inode->i_private; - ubyte pipeno; int ret; /* Some sanity checking */ @@ -143,16 +142,15 @@ static int pipe_close(FAR struct file *filep) return -EBADF; } #endif - pipeno = dev->d_pipeno; /* Perform common close operations */ ret = pipecommon_close(filep); - if (ret == 0 && !inode->i_private) + if (ret == 0 && dev->d_refs == 0) { - /* Release the pipe */ + /* Release the pipe when there are no further open references to it. */ - pipe_free(pipeno); + pipe_free(dev->d_pipeno); } return ret; }