mirror of
https://github.com/apache/nuttx.git
synced 2026-06-02 09:38:37 +08:00
Correct opendir semaphore hanlding -- was causing deadlock
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@285 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
@@ -181,5 +181,6 @@
|
|||||||
* tools/Makefile.mkconfig: Under Cygwin, executable has a different name
|
* tools/Makefile.mkconfig: Under Cygwin, executable has a different name
|
||||||
* tools/mkdeps.sh & arch/arm/src/Makefile: Corrected a problem makeing dependencies
|
* tools/mkdeps.sh & arch/arm/src/Makefile: Corrected a problem makeing dependencies
|
||||||
* tools/zipme.sh: Force directory name to be nuttx-xx.yy.zz
|
* tools/zipme.sh: Force directory name to be nuttx-xx.yy.zz
|
||||||
|
* fs/fs_opendir.c: Correct errors in semaphore usage that can cause deadlock.
|
||||||
* Started m68322
|
* Started m68322
|
||||||
|
|
||||||
|
|||||||
@@ -616,6 +616,7 @@ Other memory:
|
|||||||
* tools/Makefile.mkconfig: Under Cygwin, executable has a different name
|
* tools/Makefile.mkconfig: Under Cygwin, executable has a different name
|
||||||
* tools/mkdeps.sh & arch/arm/src/Makefile: Corrected a problem makeing dependencies
|
* tools/mkdeps.sh & arch/arm/src/Makefile: Corrected a problem makeing dependencies
|
||||||
* tools/zipme.sh: Force directory name to be nuttx-xx.yy.zz
|
* tools/zipme.sh: Force directory name to be nuttx-xx.yy.zz
|
||||||
|
* fs/fs_opendir.c: Correct errors in semaphore usage that can cause deadlock.
|
||||||
* Started m68322
|
* Started m68322
|
||||||
</pre></ul>
|
</pre></ul>
|
||||||
|
|
||||||
|
|||||||
+11
-7
@@ -94,9 +94,9 @@ FAR DIR *opendir(const char *path)
|
|||||||
* request for the root inode.
|
* request for the root inode.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
inode_semtake();
|
||||||
if (!path || *path == 0 || strcmp(path, "/") == 0)
|
if (!path || *path == 0 || strcmp(path, "/") == 0)
|
||||||
{
|
{
|
||||||
inode_semgive();
|
|
||||||
inode = root_inode;
|
inode = root_inode;
|
||||||
isroot = TRUE;
|
isroot = TRUE;
|
||||||
}
|
}
|
||||||
@@ -106,12 +106,12 @@ FAR DIR *opendir(const char *path)
|
|||||||
|
|
||||||
if (*path != '/')
|
if (*path != '/')
|
||||||
{
|
{
|
||||||
return NULL;
|
ret = -ENOTDIR;
|
||||||
|
goto errout_with_semaphore;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Find the node matching the path. */
|
/* Find the node matching the path. */
|
||||||
|
|
||||||
inode_semtake();
|
|
||||||
inode = inode_search(&path, (FAR void*)NULL, (FAR void*)NULL, &relpath);
|
inode = inode_search(&path, (FAR void*)NULL, (FAR void*)NULL, &relpath);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -166,9 +166,11 @@ FAR DIR *opendir(const char *path)
|
|||||||
goto errout_with_direntry;
|
goto errout_with_direntry;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Take reference to the mountpoint inode (fd_root) */
|
/* Take reference to the mountpoint inode (fd_root). Note that we do
|
||||||
|
* not use inode_addref() because we already hold the tree semaphore.
|
||||||
|
*/
|
||||||
|
|
||||||
inode_addref(inode);
|
inode->i_crefs++;
|
||||||
|
|
||||||
/* Perform the opendir() operation */
|
/* Perform the opendir() operation */
|
||||||
|
|
||||||
@@ -199,10 +201,12 @@ FAR DIR *opendir(const char *path)
|
|||||||
|
|
||||||
/* It looks we have a valid psuedo-filesystem node. Take two references
|
/* It looks we have a valid psuedo-filesystem node. Take two references
|
||||||
* on the inode -- one for the parent (fd_root) and one for the child (fd_next).
|
* on the inode -- one for the parent (fd_root) and one for the child (fd_next).
|
||||||
|
* Note that we do not call inode_addref because we are holding
|
||||||
|
* the tree semaphore and that would result in deadlock.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
inode_addref(inode);
|
inode->i_crefs++;
|
||||||
inode_addref(inode);
|
inode->i_crefs++;
|
||||||
dir->u.psuedo.fd_next = inode; /* This is the next node to use for readdir() */
|
dir->u.psuedo.fd_next = inode; /* This is the next node to use for readdir() */
|
||||||
|
|
||||||
/* Flag the inode as belonging to the psuedo-filesystem */
|
/* Flag the inode as belonging to the psuedo-filesystem */
|
||||||
|
|||||||
Reference in New Issue
Block a user