bonefish+mmlr:

* Add file descriptor and IO context tracing.
* Some minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36272 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Michael Lotz
2010-04-14 21:38:08 +00:00
parent 18383104ce
commit 74fc3e9a8b
4 changed files with 342 additions and 7 deletions
+14 -2
View File
@@ -23,6 +23,8 @@
#include <vfs.h>
#include <wait_for_objects.h>
#include "vfs_tracing.h"
//#define TRACE_FD
#ifdef TRACE_FD
@@ -168,6 +170,8 @@ new_fd_etc(struct io_context* context, struct file_descriptor* descriptor,
goto err;
}
TFD(NewFD(context, fd, descriptor));
context->fds[fd] = descriptor;
context->num_used_fds++;
atomic_add(&descriptor->open_count, 1);
@@ -194,6 +198,8 @@ put_fd(struct file_descriptor* descriptor)
{
int32 previous = atomic_add(&descriptor->ref_count, -1);
TFD(PutFD(descriptor));
TRACE(("put_fd(descriptor = %p [ref = %ld, cookie = %p])\n",
descriptor, descriptor->ref_count, descriptor->cookie));
@@ -291,8 +297,10 @@ get_fd_locked(struct io_context* context, int fd)
// Disconnected descriptors cannot be accessed anymore
if (descriptor->open_mode & O_DISCONNECTED)
descriptor = NULL;
else
else {
TFD(GetFD(context, fd, descriptor));
inc_fd_ref_count(descriptor);
}
}
return descriptor;
@@ -341,8 +349,10 @@ remove_fd(struct io_context* context, int fd)
select_info* selectInfos = NULL;
bool disconnected = false;
if (descriptor) {
if (descriptor != NULL) {
// fd is valid
TFD(RemoveFD(context, fd, descriptor));
context->fds[fd] = NULL;
fd_set_close_on_exec(context, fd, false);
context->num_used_fds--;
@@ -427,6 +437,8 @@ dup2_fd(int oldfd, int newfd, bool kernel)
select_info* selectInfos = NULL;
if (oldfd != newfd) {
// Now do the work
TFD(Dup2FD(context, oldfd, newfd));
evicted = context->fds[newfd];
selectInfos = context->select_infos[newfd];
context->select_infos[newfd] = NULL;