cvs commit: src/sys/kern kern_checkpoint.c kern_descrip.c kern_event.c sys_pipe.c uipc_syscalls.c uipc_usrreq.c vfs_syscalls.c src/sys/opencrypto cryptodev.c src/sys/sys filedesc.h
Matthew Dillon
dillon at crater.dragonflybsd.org
Mon May 22 14:21:45 PDT 2006
dillon 2006/05/22 14:21:26 PDT
DragonFly src repository
Modified files:
sys/kern kern_checkpoint.c kern_descrip.c
kern_event.c sys_pipe.c uipc_syscalls.c
uipc_usrreq.c vfs_syscalls.c
sys/opencrypto cryptodev.c
sys/sys filedesc.h
Log:
Do a major cleanup of the file descriptor handling code in preparation for
making the descriptor table MPSAFE. Introduce a new feature that allows a
file descriptor number to be reserved without having to assign a file
pointer to it. This allows code such as open(), dup(), etc to reserve
descriptors to work with without having to worry about the related file
being ripped out from under them by another thread sharing the descriptor
table.
falloc() - This function allocates the file pointer and descriptor as
before, but does NOT associate the file pointer with the
descriptor.
Before this change another thread could access the file
pointer while the system call creating it was blocked,
before the system call had a chance to completely initialize
the file pointer.
The caller must call fsetfd() to assign or clear the
reserved descriptor.
fsetfd() - Is now responsible for associating a file pointer with a
previously reserved descriptor or clearing the reservation.
fdealloc() - This hack existed to deal with open/dup races against other
threads. The above changes remove the possibility so this
routine has been deleted.
dup code - kern_dup() and dupfdopen() have been completely rewritten.
They are much cleaner and less obtuse now. Additional race
conditions in the original code were also found and fixed.
funsetfd() - Now returns the file pointer that was cleared and takes
responsibility for adjusting fd_lastfile.
NOTE: fd_lastfile is inclusive of any reserved descriptors.
fdcopy() - While not yet MPSAFE, fdcopy now properly handles races
against other threads.
fdp->fd_lastfile -
This field was not being properly updated in certain failure
cases. This commit fixes that. Also, if all a process's
descriptors were closed this field was incorrectly left at
0 when it should have been set to -1.
fdp->fd_files - A number of code blocks were trying to optimize a for()
loop over all file descriptors by caching a pointer to
fd_files. This is a problem because fd_files can be
reallocated if code within the loop blocks. These loops
have been rewritten.
Revision Changes Path
1.8 +2 -1 src/sys/kern/kern_checkpoint.c
1.60 +199 -184 src/sys/kern/kern_descrip.c
1.24 +1 -0 src/sys/kern/kern_event.c
1.36 +4 -1 src/sys/kern/sys_pipe.c
1.68 +27 -27 src/sys/kern/uipc_syscalls.c
1.25 +4 -2 src/sys/kern/uipc_usrreq.c
1.92 +27 -49 src/sys/kern/vfs_syscalls.c
1.15 +1 -0 src/sys/opencrypto/cryptodev.c
1.17 +4 -5 src/sys/sys/filedesc.h
http://www.dragonflybsd.org/cvsweb/src/sys/kern/kern_checkpoint.c.diff?r1=1.7&r2=1.8&f=u
http://www.dragonflybsd.org/cvsweb/src/sys/kern/kern_descrip.c.diff?r1=1.59&r2=1.60&f=u
http://www.dragonflybsd.org/cvsweb/src/sys/kern/kern_event.c.diff?r1=1.23&r2=1.24&f=u
http://www.dragonflybsd.org/cvsweb/src/sys/kern/sys_pipe.c.diff?r1=1.35&r2=1.36&f=u
http://www.dragonflybsd.org/cvsweb/src/sys/kern/uipc_syscalls.c.diff?r1=1.67&r2=1.68&f=u
http://www.dragonflybsd.org/cvsweb/src/sys/kern/uipc_usrreq.c.diff?r1=1.24&r2=1.25&f=u
http://www.dragonflybsd.org/cvsweb/src/sys/kern/vfs_syscalls.c.diff?r1=1.91&r2=1.92&f=u
http://www.dragonflybsd.org/cvsweb/src/sys/opencrypto/cryptodev.c.diff?r1=1.14&r2=1.15&f=u
http://www.dragonflybsd.org/cvsweb/src/sys/sys/filedesc.h.diff?r1=1.16&r2=1.17&f=u
More information about the Commits
mailing list