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:
+16
-7
@@ -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) \
|
||||||
@@ -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;
|
||||||
|
|||||||
Reference in New Issue
Block a user