Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 2 Aug 2002 00:26:06 -0700 (PDT)
From:      Jonathan Mini <mini@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 15438 for review
Message-ID:  <200208020726.g727Q6vi062600@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://people.freebsd.org/~peter/p4db/chv.cgi?CH=15438

Change 15438 by mini@mini_stylus on 2002/08/02 00:25:05

	Axe the fd table, the fd table locks, wonky fd handling, and the kernel polling stuff.

Affected files ...

.. //depot/projects/kse/lib/libc_r/uthread/Makefile.inc#5 edit
.. //depot/projects/kse/lib/libc_r/uthread/pthread_private.h#5 edit
.. //depot/projects/kse/lib/libc_r/uthread/uthread_accept.c#3 delete
.. //depot/projects/kse/lib/libc_r/uthread/uthread_acl_aclcheck_fd.c#3 delete
.. //depot/projects/kse/lib/libc_r/uthread/uthread_acl_delete_fd.c#3 delete
.. //depot/projects/kse/lib/libc_r/uthread/uthread_acl_get_fd.c#3 delete
.. //depot/projects/kse/lib/libc_r/uthread/uthread_acl_set_fd.c#3 delete
.. //depot/projects/kse/lib/libc_r/uthread/uthread_bind.c#3 delete
.. //depot/projects/kse/lib/libc_r/uthread/uthread_cancel.c#3 edit
.. //depot/projects/kse/lib/libc_r/uthread/uthread_close.c#3 edit
.. //depot/projects/kse/lib/libc_r/uthread/uthread_connect.c#3 delete
.. //depot/projects/kse/lib/libc_r/uthread/uthread_create.c#4 edit
.. //depot/projects/kse/lib/libc_r/uthread/uthread_dup.c#3 delete
.. //depot/projects/kse/lib/libc_r/uthread/uthread_dup2.c#3 delete
.. //depot/projects/kse/lib/libc_r/uthread/uthread_execve.c#3 delete
.. //depot/projects/kse/lib/libc_r/uthread/uthread_exit.c#3 edit
.. //depot/projects/kse/lib/libc_r/uthread/uthread_fchflags.c#3 delete
.. //depot/projects/kse/lib/libc_r/uthread/uthread_fchmod.c#3 delete
.. //depot/projects/kse/lib/libc_r/uthread/uthread_fchown.c#3 delete
.. //depot/projects/kse/lib/libc_r/uthread/uthread_fcntl.c#3 edit
.. //depot/projects/kse/lib/libc_r/uthread/uthread_fd.c#3 delete
.. //depot/projects/kse/lib/libc_r/uthread/uthread_file.c#3 delete
.. //depot/projects/kse/lib/libc_r/uthread/uthread_flock.c#3 delete
.. //depot/projects/kse/lib/libc_r/uthread/uthread_fork.c#3 edit
.. //depot/projects/kse/lib/libc_r/uthread/uthread_fpathconf.c#3 delete
.. //depot/projects/kse/lib/libc_r/uthread/uthread_fstat.c#3 delete
.. //depot/projects/kse/lib/libc_r/uthread/uthread_fstatfs.c#3 delete
.. //depot/projects/kse/lib/libc_r/uthread/uthread_fsync.c#3 edit
.. //depot/projects/kse/lib/libc_r/uthread/uthread_getdirentries.c#3 delete
.. //depot/projects/kse/lib/libc_r/uthread/uthread_getpeername.c#3 delete
.. //depot/projects/kse/lib/libc_r/uthread/uthread_getsockname.c#3 delete
.. //depot/projects/kse/lib/libc_r/uthread/uthread_getsockopt.c#3 delete
.. //depot/projects/kse/lib/libc_r/uthread/uthread_info.c#3 edit
.. //depot/projects/kse/lib/libc_r/uthread/uthread_init.c#5 edit
.. //depot/projects/kse/lib/libc_r/uthread/uthread_ioctl.c#3 delete
.. //depot/projects/kse/lib/libc_r/uthread/uthread_kern.c#4 edit
.. //depot/projects/kse/lib/libc_r/uthread/uthread_kevent.c#3 delete
.. //depot/projects/kse/lib/libc_r/uthread/uthread_listen.c#3 delete
.. //depot/projects/kse/lib/libc_r/uthread/uthread_open.c#3 edit
.. //depot/projects/kse/lib/libc_r/uthread/uthread_pipe.c#3 delete
.. //depot/projects/kse/lib/libc_r/uthread/uthread_poll.c#3 edit
.. //depot/projects/kse/lib/libc_r/uthread/uthread_pselect.c#3 edit
.. //depot/projects/kse/lib/libc_r/uthread/uthread_read.c#3 edit
.. //depot/projects/kse/lib/libc_r/uthread/uthread_readv.c#3 edit
.. //depot/projects/kse/lib/libc_r/uthread/uthread_recvfrom.c#3 delete
.. //depot/projects/kse/lib/libc_r/uthread/uthread_recvmsg.c#3 delete
.. //depot/projects/kse/lib/libc_r/uthread/uthread_select.c#3 edit
.. //depot/projects/kse/lib/libc_r/uthread/uthread_sendfile.c#3 delete
.. //depot/projects/kse/lib/libc_r/uthread/uthread_sendmsg.c#3 delete
.. //depot/projects/kse/lib/libc_r/uthread/uthread_sendto.c#3 delete
.. //depot/projects/kse/lib/libc_r/uthread/uthread_setsockopt.c#3 delete
.. //depot/projects/kse/lib/libc_r/uthread/uthread_shutdown.c#3 delete
.. //depot/projects/kse/lib/libc_r/uthread/uthread_socket.c#3 delete
.. //depot/projects/kse/lib/libc_r/uthread/uthread_socketpair.c#3 delete
.. //depot/projects/kse/lib/libc_r/uthread/uthread_write.c#3 edit
.. //depot/projects/kse/lib/libc_r/uthread/uthread_writev.c#3 edit

Differences ...

==== //depot/projects/kse/lib/libc_r/uthread/Makefile.inc#5 (text+ko) ====

@@ -4,11 +4,6 @@
 .PATH: ${.CURDIR}/uthread
 
 SRCS+= \
-	uthread_accept.c \
-	uthread_acl_delete_fd.c \
-	uthread_acl_get_fd.c \
-	uthread_acl_set_fd.c \
-	uthread_acl_aclcheck_fd.c \
 	uthread_aio_suspend.c \
 	uthread_attr_destroy.c \
 	uthread_attr_init.c \
@@ -30,50 +25,29 @@
 	uthread_attr_setstackaddr.c \
 	uthread_attr_setstacksize.c \
 	uthread_autoinit.c \
-	uthread_bind.c \
 	uthread_cancel.c \
 	uthread_clean.c \
 	uthread_close.c \
 	uthread_cond.c \
 	uthread_condattr_destroy.c \
 	uthread_condattr_init.c \
-	uthread_connect.c \
 	uthread_creat.c \
 	uthread_create.c \
 	uthread_detach.c \
-	uthread_dup.c \
-	uthread_dup2.c \
 	uthread_equal.c \
-	uthread_execve.c \
 	uthread_exit.c \
-	uthread_fchflags.c \
-	uthread_fchmod.c \
-	uthread_fchown.c \
 	uthread_fcntl.c \
-	uthread_fd.c \
-	uthread_file.c \
 	uthread_find_thread.c \
-	uthread_flock.c \
 	uthread_fork.c \
-	uthread_fpathconf.c \
-	uthread_fstat.c \
-	uthread_fstatfs.c \
 	uthread_fsync.c \
 	uthread_gc.c \
-	uthread_getdirentries.c \
-	uthread_getpeername.c \
 	uthread_getprio.c \
 	uthread_getschedparam.c \
-	uthread_getsockname.c \
-	uthread_getsockopt.c \
 	uthread_info.c \
 	uthread_init.c \
-	uthread_ioctl.c \
 	uthread_join.c \
 	uthread_kern.c \
-	uthread_kevent.c \
 	uthread_kill.c \
-	uthread_listen.c \
 	uthread_main_np.c \
 	uthread_mattr_init.c \
 	uthread_mattr_kind_np.c \
@@ -87,35 +61,25 @@
 	uthread_once.c \
 	uthread_open.c \
 	uthread_pause.c \
-	uthread_pipe.c \
 	uthread_poll.c \
 	uthread_priority_queue.c \
 	uthread_pselect.c \
 	uthread_read.c \
 	uthread_readv.c \
-	uthread_recvfrom.c \
-	uthread_recvmsg.c \
 	uthread_resume_np.c \
 	uthread_rwlock.c \
 	uthread_rwlockattr.c \
 	uthread_select.c \
 	uthread_self.c \
 	uthread_sem.c \
-	uthread_sendfile.c \
-	uthread_sendmsg.c \
-	uthread_sendto.c \
 	uthread_seterrno.c \
 	uthread_setprio.c \
 	uthread_setschedparam.c \
-	uthread_setsockopt.c \
-	uthread_shutdown.c \
 	uthread_sigmask.c \
 	uthread_sigsuspend.c \
 	uthread_sigwait.c \
 	uthread_single_np.c \
 	uthread_sleep.c \
-	uthread_socket.c \
-	uthread_socketpair.c \
 	uthread_spec.c \
 	uthread_spinlock.c \
 	uthread_stack.c \

==== //depot/projects/kse/lib/libc_r/uthread/pthread_private.h#5 (text+ko) ====

@@ -434,13 +434,6 @@
 	PS_SIGTHREAD,
 	PS_MUTEX_WAIT,
 	PS_COND_WAIT,
-	PS_FDLR_WAIT,
-	PS_FDLW_WAIT,
-	PS_FDR_WAIT,
-	PS_FDW_WAIT,
-	PS_FILE_WAIT,
-	PS_POLL_WAIT,
-	PS_SELECT_WAIT,
 	PS_SLEEP_WAIT,
 	PS_WAIT_WAIT,
 	PS_SIGSUSPEND,
@@ -461,45 +454,9 @@
 #define FD_WRITE            0x2
 #define FD_RDWR             (FD_READ | FD_WRITE)
 
-/*
- * File descriptor table structure.
- */
-struct fd_table_entry {
-	/*
-	 * Lock for accesses to this file descriptor table
-	 * entry. This is passed to _spinlock() to provide atomic
-	 * access to this structure. It does *not* represent the
-	 * state of the lock on the file descriptor.
-	 */
-	spinlock_t		lock;
-	TAILQ_HEAD(, pthread)	r_queue;	/* Read queue.                        */
-	TAILQ_HEAD(, pthread)	w_queue;	/* Write queue.                       */
-	struct pthread		*r_owner;	/* Ptr to thread owning read lock.    */
-	struct pthread		*w_owner;	/* Ptr to thread owning write lock.   */
-	char			*r_fname;	/* Ptr to read lock source file name  */
-	int			r_lineno;	/* Read lock source line number.      */
-	char			*w_fname;	/* Ptr to write lock source file name */
-	int			w_lineno;	/* Write lock source line number.     */
-	int			r_lockcount;	/* Count for FILE read locks.         */
-	int			w_lockcount;	/* Count for FILE write locks.        */
-	int			flags;		/* Flags used in open.                */
-};
-
-struct pthread_poll_data {
-	int	nfds;
-	struct pollfd *fds;
-};
-
 union pthread_wait_data {
 	pthread_mutex_t	mutex;
 	pthread_cond_t	cond;
-	struct {
-		short	fd;		/* Used when thread waiting on fd */
-		short	branch;		/* Line number, for debugging.    */
-		char	*fname;		/* Source file name for debugging.*/
-	} fd;
-	FILE		*fp;
-	struct pthread_poll_data *poll_data;
 	spinlock_t	*spinlock;
 	struct pthread	*thread;
 };
@@ -587,7 +544,7 @@
 
 	/*
 	 * Time to wake up thread. This is used for sleeping threads and
-	 * for any operation which may time out (such as select).
+	 * for any operation which may time out.
 	 */
 	struct timespec	wakeup_time;
 
@@ -640,11 +597,6 @@
 	union pthread_wait_data data;
 
 	/*
-	 * Allocated for converting select into poll.
-	 */
-	struct pthread_poll_data poll_data;
-
-	/*
 	 * Set to TRUE if a blocking operation was
 	 * interrupted by a signal:
 	 */
@@ -667,7 +619,7 @@
 #define PTHREAD_FLAGS_IN_PRIOQ	0x0008	/* in priority queue using pqe link */
 #define PTHREAD_FLAGS_IN_WORKQ	0x0010	/* in work queue using qe link */
 #define PTHREAD_FLAGS_IN_FILEQ	0x0020	/* in file lock queue using qe link */
-#define PTHREAD_FLAGS_IN_FDQ	0x0040	/* in fd lock queue using qe link */
+			     /*	0x0040	   Unused. */
 #define PTHREAD_FLAGS_IN_CONDQ	0x0080	/* in condition queue using sqe link*/
 #define PTHREAD_FLAGS_IN_MUTEXQ	0x0100	/* in mutex queue using sqe link */
 #define	PTHREAD_FLAGS_SUSPENDED	0x0200	/* thread is suspended */
@@ -824,42 +776,6 @@
 ;
 #endif
 
-/*
- * Standard I/O file descriptors need special flag treatment since
- * setting one to non-blocking does all on *BSD. Sigh. This array
- * is used to store the initial flag settings.
- */
-SCLASS int	_pthread_stdio_flags[3];
-
-/* File table information: */
-SCLASS struct fd_table_entry **_thread_fd_table
-#ifdef GLOBAL_PTHREAD_PRIVATE
-= NULL;
-#else
-;
-#endif
-
-/* Table for polling file descriptors: */
-SCLASS struct pollfd *_thread_pfd_table
-#ifdef GLOBAL_PTHREAD_PRIVATE
-= NULL;
-#else
-;
-#endif
-
-SCLASS const int dtablecount
-#ifdef GLOBAL_PTHREAD_PRIVATE
-= 4096/sizeof(struct fd_table_entry);
-#else
-;
-#endif
-SCLASS int    _thread_dtablesize        /* Descriptor table size.           */
-#ifdef GLOBAL_PTHREAD_PRIVATE
-= 0;
-#else
-;
-#endif
-
 SCLASS int    _clock_res_usec		/* Clock resolution in usec.	*/
 #ifdef GLOBAL_PTHREAD_PRIVATE
 = CLOCK_RES_USEC;
@@ -926,16 +842,6 @@
 /* Undefine the storage class specifier: */
 #undef  SCLASS
 
-#ifdef _LOCK_DEBUG
-#define	_FD_LOCK(_fd,_type,_ts)		_thread_fd_lock_debug(_fd, _type, \
-						_ts, __FILE__, __LINE__)
-#define _FD_UNLOCK(_fd,_type)		_thread_fd_unlock_debug(_fd, _type, \
-						__FILE__, __LINE__)
-#else
-#define	_FD_LOCK(_fd,_type,_ts)		_thread_fd_lock(_fd, _type, _ts)
-#define _FD_UNLOCK(_fd,_type)		_thread_fd_unlock(_fd, _type)
-#endif
-
 /*
  * Function prototype definitions.
  */
@@ -944,15 +850,12 @@
 char    *__ttyname_r_basic(int, char *, size_t);
 char    *ttyname_r(int, char *, size_t);
 void	_cond_wait_backout(pthread_t);
-void	_fd_lock_backout(pthread_t);
 int     _find_thread(pthread_t);
 struct pthread *_get_curthread(void);
 void	_set_curthread(struct pthread *);
 void	*_thread_stack_alloc(size_t, size_t);
 void	_thread_stack_free(void *, size_t, size_t);
 int     _thread_create(pthread_t *,const pthread_attr_t *,void *(*start_routine)(void *),void *,pthread_t);
-int     _thread_fd_lock(int, int, struct timespec *);
-int     _thread_fd_lock_debug(int, int, struct timespec *,char *fname,int lineno);
 int	_mutex_cv_lock(pthread_mutex_t *);
 int	_mutex_cv_unlock(pthread_mutex_t *);
 void	_mutex_lock_backout(pthread_t);
@@ -988,9 +891,6 @@
 #endif
 void    _thread_exit(char *, int, char *);
 void    _thread_exit_cleanup(void);
-void    _thread_fd_unlock(int, int);
-void    _thread_fd_unlock_debug(int, int, char *, int);
-void    _thread_fd_unlock_owned(pthread_t);
 void    *_thread_cleanup(pthread_t);
 void    _thread_cleanupspecific(void);
 void    _thread_dump_info(void);
@@ -1005,19 +905,11 @@
 void    _thread_kern_sig_undefer(void);
 void    _thread_start(void);
 void	_thread_seterrno(pthread_t, int);
-int     _thread_fd_table_init(int fd);
 pthread_addr_t _thread_gc(pthread_addr_t);
 void	_thread_enter_cancellation_point(void);
 void	_thread_leave_cancellation_point(void);
 void	_thread_cancellation_point(void);
 
-/* #include <sys/acl.h> */
-#ifdef _SYS_ACL_H
-int	__sys___acl_aclcheck_fd(int, acl_type_t, struct acl *);
-int	__sys___acl_delete_fd(int, acl_type_t);
-int	__sys___acl_get_fd(int, acl_type_t, struct acl *);
-int	__sys___acl_set_fd(int, acl_type_t, struct acl *);
-#endif
 
 /* #include <sys/aio.h> */
 #ifdef _SYS_AIO_H_

==== //depot/projects/kse/lib/libc_r/uthread/uthread_cancel.c#3 (text+ko) ====

@@ -44,10 +44,6 @@
 				break;
 
 			case PS_SPINBLOCK:
-			case PS_FDR_WAIT:
-			case PS_FDW_WAIT:
-			case PS_POLL_WAIT:
-			case PS_SELECT_WAIT:
 				/* Remove these threads from the work queue: */
 				if ((pthread->flags & PTHREAD_FLAGS_IN_WORKQ)
 				    != 0)
@@ -80,9 +76,6 @@
 			case PS_SUSPENDED:
 			case PS_MUTEX_WAIT:
 			case PS_COND_WAIT:
-			case PS_FDLR_WAIT:
-			case PS_FDLW_WAIT:
-			case PS_FILE_WAIT:
 				/*
 				 * Threads in these states may be in queues.
 				 * In order to preserve queue integrity, the

==== //depot/projects/kse/lib/libc_r/uthread/uthread_close.c#3 (text+ko) ====

@@ -42,65 +42,12 @@
 __weak_reference(__close, close);
 
 int
-_close(int fd)
-{
-	int		flags;
-	int		ret;
-	struct stat	sb;
-	struct fd_table_entry	*entry;
-
-	/*
-	 * Lock the file descriptor while the file is closed and get
-	 * the file descriptor status:
-	 */
-	if (((ret = _FD_LOCK(fd, FD_RDWR, NULL)) == 0) &&
-	    ((ret = __sys_fstat(fd, &sb)) == 0)) {
-		/*
-		 * Check if the file should be left as blocking.
-		 *
-		 * This is so that the file descriptors shared with a parent
-		 * process aren't left set to non-blocking if the child
-		 * closes them prior to exit.  An example where this causes
-		 * problems with /bin/sh is when a child closes stdin.
-		 *
-		 * Setting a file as blocking causes problems if a threaded
-		 * parent accesses the file descriptor before the child exits.
-		 * Once the threaded parent receives a SIGCHLD then it resets
-		 * all of its files to non-blocking, and so it is then safe
-		 * to access them.
-		 *
-		 * Pipes are not set to blocking when they are closed, as
-		 * the parent and child will normally close the file
-		 * descriptor of the end of the pipe that they are not
-		 * using, which would then cause any reads to block
-		 * indefinitely.
-		 */
-		if ((S_ISREG(sb.st_mode) || S_ISCHR(sb.st_mode)) && (_thread_fd_table[fd]->flags & O_NONBLOCK) == 0) {
-			/* Get the current flags: */
-			flags = __sys_fcntl(fd, F_GETFL, NULL);
-			/* Clear the nonblocking file descriptor flag: */
-			__sys_fcntl(fd, F_SETFL, flags & ~O_NONBLOCK);
-		}
-
-		/* XXX: Assumes well behaved threads. */
-		/* XXX: Defer real close to avoid race condition */
-		entry = _thread_fd_table[fd];
-		_thread_fd_table[fd] = NULL;
-		free(entry);
-
-		/* Close the file descriptor: */
-		ret = __sys_close(fd);
-	}
-	return (ret);
-}
-
-int
 __close(int fd)
 {
 	int	ret;
 
 	_thread_enter_cancellation_point();
-	ret = _close(fd);
+	ret = __sys_close(fd);
 	_thread_leave_cancellation_point();
 	
 	return ret;

==== //depot/projects/kse/lib/libc_r/uthread/uthread_create.c#4 (text+ko) ====

@@ -167,8 +167,6 @@
 			new_thread->specific = NULL;
 			new_thread->cleanup = NULL;
 			new_thread->flags = 0;
-			new_thread->poll_data.nfds = 0;
-			new_thread->poll_data.fds = NULL;
 			new_thread->continuation = NULL;
 
 			/*

==== //depot/projects/kse/lib/libc_r/uthread/uthread_exit.c#3 (text+ko) ====

@@ -45,30 +45,6 @@
 
 __weak_reference(_pthread_exit, pthread_exit);
 
-void _exit(int status)
-{
-	int		flags;
-	int             i;
-
-	/*
-	 * Enter a loop to set all file descriptors to blocking
-	 * if they were not created as non-blocking:
-	 */
-	for (i = 0; i < _thread_dtablesize; i++) {
-		/* Check if this file descriptor is in use: */
-		if (_thread_fd_table[i] != NULL &&
-			!(_thread_fd_table[i]->flags & O_NONBLOCK)) {
-			/* Get the current flags: */
-			flags = __sys_fcntl(i, F_GETFL, NULL);
-			/* Clear the nonblocking file descriptor flag: */
-			__sys_fcntl(i, F_SETFL, flags & ~O_NONBLOCK);
-		}
-	}
-
-	/* Call the _exit syscall: */
-	__sys_exit(status);
-}
-
 void
 _thread_exit(char *fname, int lineno, char *string)
 {
@@ -108,9 +84,6 @@
 	 * internal to the threads library, including file and fd locks,
 	 * are not visible to the application and need to be released.
 	 */
-	/* Unlock all owned fd locks: */
-	_thread_fd_unlock_owned(curthread);
-
 	/* Unlock all private mutexes: */
 	_mutex_unlock_private(curthread);
 
@@ -151,12 +124,6 @@
 		_thread_cleanupspecific();
 	}
 
-	/* Free thread-specific poll_data structure, if allocated: */
-	if (curthread->poll_data.fds != NULL) {
-		free(curthread->poll_data.fds);
-		curthread->poll_data.fds = NULL;
-	}
-
 	/*
 	 * Lock the garbage collector mutex to ensure that the garbage
 	 * collector is not using the dead thread list.

==== //depot/projects/kse/lib/libc_r/uthread/uthread_fcntl.c#3 (text+ko) ====

@@ -40,107 +40,6 @@
 __weak_reference(__fcntl, fcntl);
 
 int
-_fcntl(int fd, int cmd,...)
-{
-	int             flags = 0;
-	int		nonblock;
-	int             oldfd;
-	int             ret;
-	va_list         ap;
-
-	/* Lock the file descriptor: */
-	if ((ret = _FD_LOCK(fd, FD_RDWR, NULL)) == 0) {
-		/* Initialise the variable argument list: */
-		va_start(ap, cmd);
-
-		/* Process according to file control command type: */
-		switch (cmd) {
-		/* Duplicate a file descriptor: */
-		case F_DUPFD:
-			/*
-			 * Get the file descriptor that the caller wants to
-			 * use: 
-			 */
-			oldfd = va_arg(ap, int);
-
-			/* Initialise the file descriptor table entry: */
-			if ((ret = __sys_fcntl(fd, cmd, oldfd)) < 0) {
-			}
-			/* Initialise the file descriptor table entry: */
-			else if (_thread_fd_table_init(ret) != 0) {
-				/* Quietly close the file: */
-				__sys_close(ret);
-
-				/* Reset the file descriptor: */
-				ret = -1;
-			} else {
-				/*
-				 * Save the file open flags so that they can
-				 * be         checked later: 
-				 */
-				_thread_fd_table[ret]->flags = _thread_fd_table[fd]->flags;
-			}
-			break;
-		case F_SETFD:
-			flags = va_arg(ap, int);
-			ret = __sys_fcntl(fd, cmd, flags);
-			break;
-		case F_GETFD:
-			ret = __sys_fcntl(fd, cmd, 0);
-			break;
-		case F_GETFL:
-			ret = _thread_fd_table[fd]->flags;
-			break;
-		case F_SETFL:
-			/*
-			 * Get the file descriptor flags passed by the
-			 * caller:
-			 */
-			flags = va_arg(ap, int);
-
-			/*
-			 * Check if the user wants a non-blocking file
-			 * descriptor:
-			 */
-			nonblock = flags & O_NONBLOCK;
-
-			/* Set the file descriptor flags: */
-			if ((ret = __sys_fcntl(fd, cmd, flags | O_NONBLOCK)) != 0) {
-
-			/* Get the flags so that we behave like the kernel: */
-			} else if ((flags = __sys_fcntl(fd,
-			    F_GETFL, 0)) == -1) {
-				/* Error getting flags: */
-				ret = -1;
-
-			/*
-			 * Check if the file descriptor is non-blocking
-			 * with respect to the user:
-			 */
-			} else if (nonblock)
-				/* A non-blocking descriptor: */
-				_thread_fd_table[fd]->flags = flags | O_NONBLOCK;
-			else
-				/* Save the flags: */
-				_thread_fd_table[fd]->flags = flags & ~O_NONBLOCK;
-			break;
-		default:
-			/* Might want to make va_arg use a union */
-			ret = __sys_fcntl(fd, cmd, va_arg(ap, void *));
-			break;
-		}
-
-		/* Free variable arguments: */
-		va_end(ap);
-
-		/* Unlock the file descriptor: */
-		_FD_UNLOCK(fd, FD_RDWR);
-	}
-	/* Return the completion status: */
-	return (ret);
-}
-
-int
 __fcntl(int fd, int cmd,...)
 {
 	int	ret;
@@ -153,14 +52,14 @@
 		case F_DUPFD:
 		case F_SETFD:
 		case F_SETFL:
-			ret = _fcntl(fd, cmd, va_arg(ap, int));
+			ret = __sys_fcntl(fd, cmd, va_arg(ap, int));
 			break;
 		case F_GETFD:
 		case F_GETFL:
-			ret = _fcntl(fd, cmd);
+			ret = __sys_fcntl(fd, cmd);
 			break;
 		default:
-			ret = _fcntl(fd, cmd, va_arg(ap, void *));
+			ret = __sys_fcntl(fd, cmd, va_arg(ap, void *));
 	}
 	va_end(ap);
 

==== //depot/projects/kse/lib/libc_r/uthread/uthread_fork.c#3 (text+ko) ====

@@ -146,27 +146,6 @@
 
 			/* Initialize the scheduling switch hook routine: */
 			_sched_switch_hook = NULL;
-
-			/* Clear out any locks in the file descriptor table: */
-			for (i = 0; i < _thread_dtablesize; i++) {
-				if (_thread_fd_table[i] != NULL) {
-					/* Initialise the file locks: */
-					memset(&_thread_fd_table[i]->lock, 0,
-					    sizeof(_thread_fd_table[i]->lock));
-					_thread_fd_table[i]->r_owner = NULL;
-					_thread_fd_table[i]->w_owner = NULL;
-					_thread_fd_table[i]->r_fname = NULL;
-					_thread_fd_table[i]->w_fname = NULL;
-					_thread_fd_table[i]->r_lineno = 0;;
-					_thread_fd_table[i]->w_lineno = 0;;
-					_thread_fd_table[i]->r_lockcount = 0;;
-					_thread_fd_table[i]->w_lockcount = 0;;
-
-					/* Initialise the read/write queues: */
-					TAILQ_INIT(&_thread_fd_table[i]->r_queue);
-					TAILQ_INIT(&_thread_fd_table[i]->w_queue);
-				}
-			}
 		}
 	}
 
@@ -197,8 +176,5 @@
 	if (thread->specific != NULL)
 		free(thread->specific);
 
-	if (thread->poll_data.fds != NULL)
-		free(thread->poll_data.fds);
-
 	free(thread);
 }

==== //depot/projects/kse/lib/libc_r/uthread/uthread_fsync.c#3 (text+ko) ====

@@ -38,24 +38,12 @@
 __weak_reference(__fsync, fsync);
 
 int
-_fsync(int fd)
-{
-	int	ret;
-
-	if ((ret = _FD_LOCK(fd, FD_RDWR, NULL)) == 0) {
-		ret = __sys_fsync(fd);
-		_FD_UNLOCK(fd, FD_RDWR);
-	}
-	return (ret);
-}
-
-int
 __fsync(int fd)
 {
 	int	ret;
 
 	_thread_enter_cancellation_point();
-	ret = _fsync(fd);
+	ret = __sys_fsync(fd);
 	_thread_leave_cancellation_point();
 
 	return ret;

==== //depot/projects/kse/lib/libc_r/uthread/uthread_info.c#3 (text+ko) ====

@@ -59,13 +59,6 @@
 	{PS_SIGTHREAD	, "Waiting on signal thread"},
 	{PS_MUTEX_WAIT	, "Waiting on a mutex"},
 	{PS_COND_WAIT	, "Waiting on a condition variable"},
-	{PS_FDLR_WAIT	, "Waiting for a file read lock"},
-	{PS_FDLW_WAIT	, "Waiting for a file write lock"},
-	{PS_FDR_WAIT	, "Waiting for read"},
-	{PS_FDW_WAIT	, "Waiting for write"},
-	{PS_FILE_WAIT	, "Waiting for FILE lock"},
-	{PS_POLL_WAIT	, "Waiting on poll"},
-	{PS_SELECT_WAIT	, "Waiting on select"},
 	{PS_SLEEP_WAIT	, "Sleeping"},
 	{PS_WAIT_WAIT	, "Waiting process"},
 	{PS_SIGSUSPEND	, "Suspended, waiting for a signal"},
@@ -169,34 +162,6 @@
 			}
 		}
 
-		/* Output a header for file descriptors: */
-		snprintf(s, sizeof(s), "\n\n=============\nFILE DESCRIPTOR "
-		    "TABLE (table size %d)\n\n", _thread_dtablesize);
-		__sys_write(fd, s, strlen(s));
-
-		/* Enter a loop to report file descriptor lock usage: */
-		for (i = 0; i < _thread_dtablesize; i++) {
-			/*
-			 * Check if memory is allocated for this file
-			 * descriptor:
-			 */
-			if (_thread_fd_table[i] != NULL) {
-				/* Report the file descriptor lock status: */
-				snprintf(s, sizeof(s),
-				    "fd[%3d] read owner %p count %d [%s:%d]\n"
-				    "        write owner %p count %d [%s:%d]\n",
-				    i, _thread_fd_table[i]->r_owner,
-				    _thread_fd_table[i]->r_lockcount,
-				    _thread_fd_table[i]->r_fname,
-				    _thread_fd_table[i]->r_lineno,
-				    _thread_fd_table[i]->w_owner,
-				    _thread_fd_table[i]->w_lockcount,
-				    _thread_fd_table[i]->w_fname,
-				    _thread_fd_table[i]->w_lineno);
-				    __sys_write(fd, s, strlen(s));
-			}
-		}
-
 		/* Close the dump file: */
 		__sys_close(fd);
 	}
@@ -238,21 +203,6 @@
 		/* Process according to thread state: */
 		switch (pthread->state) {
 		/* File descriptor read lock wait: */
-		case PS_FDLR_WAIT:
-		case PS_FDLW_WAIT:
-		case PS_FDR_WAIT:
-		case PS_FDW_WAIT:
-			/* Write the lock details: */
-			snprintf(s, sizeof(s), "fd %d[%s:%d]",
-			    pthread->data.fd.fd,
-			    pthread->data.fd.fname,
-			    pthread->data.fd.branch);
-			__sys_write(fd, s, strlen(s));
-			snprintf(s, sizeof(s), "owner %pr/%pw\n",
-			    _thread_fd_table[pthread->data.fd.fd]->r_owner,
-			    _thread_fd_table[pthread->data.fd.fd]->w_owner);
-			__sys_write(fd, s, strlen(s));
-			break;
 		case PS_SIGWAIT:
 			break;
 		/*

==== //depot/projects/kse/lib/libc_r/uthread/uthread_init.c#5 (text+ko) ====

@@ -56,7 +56,6 @@
 #include <errno.h>
 #include <fcntl.h>
 #include <paths.h>
-#include <poll.h>
 #include <pthread.h>
 #include <signal.h>
 #include <stdio.h>
@@ -208,14 +207,6 @@
 			PANIC("Can't dup2");
 	}
 
-	/* Get the standard I/O flags before messing with them : */
-	for (i = 0; i < 3; i++) {
-		if (((_pthread_stdio_flags[i] =
-		    __sys_fcntl(i, F_GETFL, NULL)) == -1) &&
-		    (errno != EBADF))
-			PANIC("Cannot get stdio flags");
-	}
-
 	/* Allocate and initialize the ready queue: */
 	if (_pq_alloc(&_readyq, PTHREAD_MIN_PRIORITY, PTHREAD_LAST_PRIORITY) !=
 	    0) {
@@ -326,8 +317,6 @@
 		_thread_initial->last_active = (long) _sched_ticks;
 
 		/* Initialise the rest of the fields: */
-		_thread_initial->poll_data.nfds = 0;
-		_thread_initial->poll_data.fds = NULL;
 		_thread_initial->sig_defer_count = 0;
 		_thread_initial->specific = NULL;
 		_thread_initial->cleanup = NULL;
@@ -345,50 +334,6 @@
 			_clock_res_usec = clockinfo.tick > CLOCK_RES_USEC_MIN ?
 			    clockinfo.tick : CLOCK_RES_USEC_MIN;
 
-		/* Get the table size: */
-		if ((_thread_dtablesize = getdtablesize()) < 0) {
-			/*
-			 * Cannot get the system defined table size, so abort
-			 * this process.
-			 */
-			PANIC("Cannot get dtablesize");
-		}
-		/* Allocate memory for the file descriptor table: */
-		if ((_thread_fd_table = (struct fd_table_entry **) malloc(sizeof(struct fd_table_entry *) * _thread_dtablesize)) == NULL) {
-			/* Avoid accesses to file descriptor table on exit: */
-			_thread_dtablesize = 0;
-
-			/*
-			 * Cannot allocate memory for the file descriptor
-			 * table, so abort this process.
-			 */
-			PANIC("Cannot allocate memory for file descriptor table");
-		}
-		/* Allocate memory for the pollfd table: */
-		if ((_thread_pfd_table = (struct pollfd *) malloc(sizeof(struct pollfd) * _thread_dtablesize)) == NULL) {
-			/*
-			 * Cannot allocate memory for the file descriptor
-			 * table, so abort this process.
-			 */
-			PANIC("Cannot allocate memory for pollfd table");
-		} else {
-			/*
-			 * Enter a loop to initialise the file descriptor
-			 * table:
-			 */
-			for (i = 0; i < _thread_dtablesize; i++) {
-				/* Initialise the file descriptor table: */
-				_thread_fd_table[i] = NULL;
-			}
-
-			/* Initialize stdio file descriptor table entries: */
-			for (i = 0; i < 3; i++) {
-				if ((_thread_fd_table_init(i) != 0) &&
-				    (errno != EBADF))
-					PANIC("Cannot initialize stdio file "
-					    "descriptor table entry");
-			}
-		}
 	}
 
 	/* Initialise the garbage collector mutex and condition variable. */

==== //depot/projects/kse/lib/libc_r/uthread/uthread_kern.c#4 (text+ko) ====

@@ -59,7 +59,7 @@
 
 /* Static function prototype definitions: */
 static void
-thread_kern_poll(int wait_reqd);
+thread_kern_idle(void);
 
 static void
 dequeue_signals(void);
@@ -191,9 +191,6 @@
 			 * operations or timeouts:
 			 */
 			case PS_DEADLOCK:
-			case PS_FDLR_WAIT:
-			case PS_FDLW_WAIT:
-			case PS_FILE_WAIT:
 			case PS_JOIN:
 			case PS_MUTEX_WAIT:
 			case PS_SIGSUSPEND:
@@ -231,41 +228,9 @@
 				_spinblock_count++;
 
 				/* FALLTHROUGH */
-			case PS_FDR_WAIT:
-			case PS_FDW_WAIT:
-			case PS_POLL_WAIT:
-			case PS_SELECT_WAIT:
-				/* Restart the time slice: */
-				curthread->slice_usec = -1;
-	
-				/* Insert into the waiting queue: */
-				PTHREAD_WAITQ_INSERT(curthread);
-	
-				/* Insert into the work queue: */
-				PTHREAD_WORKQ_INSERT(curthread);
-				break;
 			}
 		}
 
-		/*
-		 * Avoid polling file descriptors if there are none
-		 * waiting:
-		 */
-		if (TAILQ_EMPTY(&_workq) != 0) {
-		}
-		/*
-		 * Poll file descriptors only if a new scheduling signal
-		 * has occurred or if we have no more runnable threads.
-		 */
-		else if (((current_tick = _sched_ticks) != last_tick) ||
-		    ((curthread->state != PS_RUNNING) &&
-		    (PTHREAD_PRIOQ_FIRST() == NULL))) {
-			/*
-			 * Poll file descriptors to update the state of threads
-			 * waiting on file I/O where data may be available:
-			 */
-			thread_kern_poll(0);
-		}
 		last_tick = current_tick;
 
 		/*
@@ -281,25 +246,16 @@
 		    (pthread->wakeup_time.tv_sec < ts.tv_sec) ||
 		    ((pthread->wakeup_time.tv_sec == ts.tv_sec) &&
 		    (pthread->wakeup_time.tv_nsec <= ts.tv_nsec)))) {
-			switch (pthread->state) {
-			case PS_POLL_WAIT:
-			case PS_SELECT_WAIT:
-				/* Return zero file descriptors ready: */
-				pthread->data.poll_data->nfds = 0;
-				/* fall through */
-			default:
-				/*
-				 * Remove this thread from the waiting queue
-				 * (and work queue if necessary) and place it
-				 * in the ready queue.
-				 */
-				PTHREAD_WAITQ_CLEARACTIVE();
-				if (pthread->flags & PTHREAD_FLAGS_IN_WORKQ)
-					PTHREAD_WORKQ_REMOVE(pthread);
-				PTHREAD_NEW_STATE(pthread, PS_RUNNING);
-				PTHREAD_WAITQ_SETACTIVE();
-				break;
-			}
+			/*
+			 * Remove this thread from the waiting queue
+			 * (and work queue if necessary) and place it
+			 * in the ready queue.
+			 */
+			PTHREAD_WAITQ_CLEARACTIVE();
+			if (pthread->flags & PTHREAD_FLAGS_IN_WORKQ)
+				PTHREAD_WORKQ_REMOVE(pthread);
+			PTHREAD_NEW_STATE(pthread, PS_RUNNING);
+			PTHREAD_WAITQ_SETACTIVE();
 			/*
 			 * Flag the timeout in the thread structure:
 			 */
@@ -379,7 +335,7 @@
 			 * There are no threads ready to run, so wait until
 			 * something happens that changes this condition:
 			 */
-			thread_kern_poll(1);
+			thread_kern_idle();
 
 			/*
 			 * This process' usage will likely be very small
@@ -486,9 +442,8 @@
 }
 
 static void
-thread_kern_poll(int wait_reqd)

>>> TRUNCATED FOR MAIL (1000 lines) <<<

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe p4-projects" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200208020726.g727Q6vi062600>