aboutsummaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorJeff Roberson <jeff@FreeBSD.org>2009-07-01 20:43:46 +0000
committerJeff Roberson <jeff@FreeBSD.org>2009-07-01 20:43:46 +0000
commit2141453eb458a78107ea7b17ccc9c1e7ebc0d377 (patch)
treeb2fc0d630559045a6dc040d8277d005b310be42e /sys
parent8edfe76ab583833418987ad3325ea16387cd8c8a (diff)
Notes
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/sys_generic.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/sys/kern/sys_generic.c b/sys/kern/sys_generic.c
index b9fd77034d60..9073a8568837 100644
--- a/sys/kern/sys_generic.c
+++ b/sys/kern/sys_generic.c
@@ -124,6 +124,7 @@ struct selfd {
};
static uma_zone_t selfd_zone;
+static struct mtx_pool *mtxpool_select;
#ifndef _SYS_SYSPROTO_H_
struct read_args {
@@ -794,11 +795,8 @@ kern_select(struct thread *td, int nd, fd_set *fd_in, fd_set *fd_ou,
if (nd < 0)
return (EINVAL);
fdp = td->td_proc->p_fd;
-
- FILEDESC_SLOCK(fdp);
- if (nd > td->td_proc->p_fd->fd_nfiles)
- nd = td->td_proc->p_fd->fd_nfiles; /* forgiving; slightly wrong */
- FILEDESC_SUNLOCK(fdp);
+ if (nd > fdp->fd_lastfile + 1)
+ nd = fdp->fd_lastfile + 1;
/*
* Allocate just enough bits for the non-null fd_sets. Use the
@@ -1373,7 +1371,9 @@ selrecord(selector, sip)
stp->st_free2 = NULL;
else
panic("selrecord: No free selfd on selq");
- mtxp = mtx_pool_find(mtxpool_sleep, sip);
+ mtxp = sip->si_mtx;
+ if (mtxp == NULL)
+ mtxp = mtx_pool_find(mtxpool_select, sip);
/*
* Initialize the sfp and queue it in the thread.
*/
@@ -1529,6 +1529,8 @@ SYSINIT(select, SI_SUB_SYSCALLS, SI_ORDER_ANY, selectinit, NULL);
static void
selectinit(void *dummy __unused)
{
+
selfd_zone = uma_zcreate("selfd", sizeof(struct selfd), NULL, NULL,
NULL, NULL, UMA_ALIGN_PTR, 0);
+ mtxpool_select = mtx_pool_create("select mtxpool", 128, MTX_DEF);
}