summaryrefslogtreecommitdiffstats
path: root/sys/kern/uipc_syscalls.c
diff options
context:
space:
mode:
authordes <des@FreeBSD.org>2004-01-15 10:15:04 +0000
committerdes <des@FreeBSD.org>2004-01-15 10:15:04 +0000
commitf270054cd314ee2f822fb6cb1e04452749d4c214 (patch)
tree17db0a692fa4e5f4c64cebaf9205ad10ff29301e /sys/kern/uipc_syscalls.c
parenteb1be5f02d7c125633ee09a54f1c6bbefbd1348a (diff)
downloadFreeBSD-src-f270054cd314ee2f822fb6cb1e04452749d4c214.zip
FreeBSD-src-f270054cd314ee2f822fb6cb1e04452749d4c214.tar.gz
New file descriptor allocation code, derived from similar code introduced
in OpenBSD by Niels Provos. The patch introduces a bitmap of allocated file descriptors which is used to locate available descriptors when a new one is needed. It also moves the task of growing the file descriptor table out of fdalloc(), reducing complexity in both fdalloc() and do_dup(). Debts of gratitude are owed to tjr@ (who provided the original patch on which this work is based), grog@ (for the gdb(4) man page) and rwatson@ (for assistance with pxeboot(8)).
Diffstat (limited to 'sys/kern/uipc_syscalls.c')
-rw-r--r--sys/kern/uipc_syscalls.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/sys/kern/uipc_syscalls.c b/sys/kern/uipc_syscalls.c
index 3007c75..e0fd0b7 100644
--- a/sys/kern/uipc_syscalls.c
+++ b/sys/kern/uipc_syscalls.c
@@ -125,6 +125,7 @@ socket(td, uap)
if (error) {
if (fdp->fd_ofiles[fd] == fp) {
fdp->fd_ofiles[fd] = NULL;
+ fdunused(fdp, fd);
FILEDESC_UNLOCK(fdp);
fdrop(fp, td);
} else {
@@ -391,6 +392,7 @@ noconnection:
FILEDESC_LOCK(fdp);
if (fdp->fd_ofiles[fd] == nfp) {
fdp->fd_ofiles[fd] = NULL;
+ fdunused(fdp, fd);
FILEDESC_UNLOCK(fdp);
fdrop(nfp, td);
} else {
@@ -585,6 +587,7 @@ free4:
FILEDESC_LOCK(fdp);
if (fdp->fd_ofiles[sv[1]] == fp2) {
fdp->fd_ofiles[sv[1]] = NULL;
+ fdunused(fdp, sv[1]);
FILEDESC_UNLOCK(fdp);
fdrop(fp2, td);
} else {
@@ -595,6 +598,7 @@ free3:
FILEDESC_LOCK(fdp);
if (fdp->fd_ofiles[sv[0]] == fp1) {
fdp->fd_ofiles[sv[0]] = NULL;
+ fdunused(fdp, sv[0]);
FILEDESC_UNLOCK(fdp);
fdrop(fp1, td);
} else {
OpenPOWER on IntegriCloud