From 1670b8f596897bfe1b4e55b73d0a9e8acfebf801 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Thu, 6 Oct 2005 08:53:17 +0000 Subject: [PATCH] num_used_fds counting was broken for dup2() and vfs_new_io_context() when it was used with a parent context. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14311 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/system/kernel/fs/fd.c | 3 +++ src/system/kernel/fs/vfs.cpp | 1 + 2 files changed, 4 insertions(+) diff --git a/src/system/kernel/fs/fd.c b/src/system/kernel/fs/fd.c index 4a50ed194e..3e1c5059d0 100644 --- a/src/system/kernel/fs/fd.c +++ b/src/system/kernel/fs/fd.c @@ -242,6 +242,9 @@ dup2_fd(int oldfd, int newfd, bool kernel) atomic_add(&context->fds[oldfd]->ref_count, 1); atomic_add(&context->fds[oldfd]->open_count, 1); context->fds[newfd] = context->fds[oldfd]; + + if (evicted == NULL) + context->num_used_fds++; } mutex_unlock(&context->io_mutex); diff --git a/src/system/kernel/fs/vfs.cpp b/src/system/kernel/fs/vfs.cpp index cd341c875d..7849440b6f 100644 --- a/src/system/kernel/fs/vfs.cpp +++ b/src/system/kernel/fs/vfs.cpp @@ -2903,6 +2903,7 @@ vfs_new_io_context(void *_parentContext) if (descriptor != NULL && (descriptor->open_mode & O_CLOEXEC) == 0) { context->fds[i] = descriptor; + context->num_used_fds++; atomic_add(&descriptor->ref_count, 1); atomic_add(&descriptor->open_count, 1); }