remove_fd() is now static.

Added some comments.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1307 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2002-09-30 03:31:42 +00:00
parent 03874b549f
commit 79f4cb3e2c
+18 -9
View File
@@ -5,13 +5,15 @@
*/ */
//#include <ktypes.h>
#include <OS.h>
#include <fd.h> #include <fd.h>
#include <vfs.h>
#include <OS.h>
#include <Errors.h> #include <Errors.h>
#include <vfs.h>
#include <debug.h> #include <debug.h>
#include <memheap.h> #include <memheap.h>
#include <string.h> #include <string.h>
#define CHECK_USER_ADDR(x) \ #define CHECK_USER_ADDR(x) \
@@ -38,8 +40,8 @@ void
dump_fd(int fd,struct file_descriptor *descriptor) dump_fd(int fd,struct file_descriptor *descriptor)
{ {
dprintf("fd[%d] = %p: type = %d, ref_count = %d, ops = %p, vnode = %p, cookie = %p, dummy = %x\n", dprintf("fd[%d] = %p: type = %d, ref_count = %d, ops = %p, vnode = %p, cookie = %p, dummy = %x\n",
fd,descriptor,descriptor->type,descriptor->ref_count,descriptor->ops, fd, descriptor, descriptor->type, descriptor->ref_count, descriptor->ops,
descriptor->vnode,descriptor->cookie,descriptor->dummy); descriptor->vnode, descriptor->cookie, descriptor->dummy);
} }
#endif #endif
@@ -92,13 +94,16 @@ err:
} }
/** Reduces the descriptor's reference counter, and frees all resources
* if necessary.
*/
void void
put_fd(struct file_descriptor *descriptor) put_fd(struct file_descriptor *descriptor)
{ {
/* Run a cleanup (fd_free) routine if there is one and free structure, but only // free the descriptor if we don't need it anymore
* if we've just removed the final reference to it :)
*/
if (atomic_add(&descriptor->ref_count, -1) == 1) { if (atomic_add(&descriptor->ref_count, -1) == 1) {
// close the underlying object (and free any resources allocated there)=
if (descriptor->ops->fd_close) if (descriptor->ops->fd_close)
descriptor->ops->fd_close(descriptor); descriptor->ops->fd_close(descriptor);
if (descriptor->ops->fd_free) if (descriptor->ops->fd_free)
@@ -131,7 +136,11 @@ get_fd(struct io_context *context, int fd)
} }
void /** Removes the file descriptor in the specified slot, and
* reduces its reference counter.
*/
static void
remove_fd(struct io_context *context, int fd) remove_fd(struct io_context *context, int fd)
{ {
struct file_descriptor *descriptor = NULL; struct file_descriptor *descriptor = NULL;