summaryrefslogtreecommitdiff
path: root/nuttx/drivers/pipe.c
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2008-07-27 19:26:57 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2008-07-27 19:26:57 +0000
commite3ff949fecaf5d7a66082b3c394c217368076078 (patch)
treeb72568b397144b7f72b7e00c8fb4067596a17e03 /nuttx/drivers/pipe.c
parente836de52ab6423fe83da3a3b937308c5dd743990 (diff)
downloadpx4-nuttx-e3ff949fecaf5d7a66082b3c394c217368076078.tar.gz
px4-nuttx-e3ff949fecaf5d7a66082b3c394c217368076078.tar.bz2
px4-nuttx-e3ff949fecaf5d7a66082b3c394c217368076078.zip
Fix detection of final close
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@787 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/drivers/pipe.c')
-rw-r--r--nuttx/drivers/pipe.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/nuttx/drivers/pipe.c b/nuttx/drivers/pipe.c
index 8c06974b1..5e0b2f6e5 100644
--- a/nuttx/drivers/pipe.c
+++ b/nuttx/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;
}