summaryrefslogtreecommitdiffstats
path: root/lib/libpthread/uthread/pthread_private.h (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Make openat(), pread(), preadv(), pwrite(), and pwritev() cancellationguenther2012-01-171-3/+8
| | | | | | points. ok fgsch@
* threads waiting on PS_FDW_WAIT state should not be interruptible iffgsch2011-10-071-1/+2
| | | | | | | | | SA_RESTART is set, with connect(2) being the exception thus getting its own state. as pointed by kurt, threads on this and PS_FDR_WAIT states need to be set to PS_RUNNING since the current signal dispatching code only looks at the current thread. ok kurt@
* For threads in PS_FDR_WAIT state, check SA_RESTART before marking it asfgsch2011-09-131-1/+2
| | | | | | | | interrupted, thus simulating the system call restart behaviour in the non-pthreads case. Add a state for kevent since it shouldn't be restarted regardless of SA_RESTART being present. guenther@ ok.
* Change basep parameter of getdirentries() to be off_t *, not long *millert2010-10-281-2/+2
| | | | | | | | so it works correctly with large offsets (and matches other systems). This requires adding a new getdirentries syscall, with the old one renamed to ogetdirentries. All in-tree consumers of getdirentries() have been updated. Bump libc and libpthread major numbers. OK and with deraadt@
* Fix PR 6376: restore more thread library state if execve fails,guenther2010-07-131-1/+2
| | | | | | | including the scheduling timer, sigmask, fd nonblocking status, and handling of the signals used by the thread library. ok marc@, additional testing by ajacoutot@
* Make SO_RCVTIMEO and SO_SNDTIMEO work with pthreads. Fixes at least some offgsch2010-01-031-2/+8
| | | | | the issues seen with www/varnish. With input and help from guenther@ and kurt@. guenther@ ok
* Make internal file descriptor handling async-signal safe by eliminatingkurt2009-12-061-9/+4
| | | | | | the use of spinlocks and malloc. All needed memory is allocated upfront and _thread_kern_sig_defer/undefer() is now used to protect critical sections. okay guenther@
* define ENOTSUP EOPNOTSUPP is no longer neededderaadt2009-10-271-6/+1
|
* Increase default thread stack size to 256K on 32bit archs and 512K onkurt2009-04-211-2/+7
| | | | | 64bit archs to accommodate the growing number of ports that put large buffers on the stack. Supported by many with no objections.
* Add pthread_attr_[sg]etguardsize() to match rthread, including manpagesguenther2008-12-181-3/+4
| | | | | | Bump lib minor ok otto@ kurt@ marc@; doc review by jmc@
* make pthread vfork() not call fork(), but actually call vfork(). ourderaadt2007-11-201-1/+2
| | | | | | | vfork() has only one semantic: "parent stalls until child does execve or exit" and no other semantic. it is unfair to act as if pthread vfork() suddenly lacks that semantic. ok kurt millert kettenis beck
* Initialize the locks in key_table. On hppa _SPINLOCK_LOCKED is 0, so ankettenis2007-07-201-1/+2
| | | | | | | uninitialized lock ends up in a locked state. This lead to a deadlock if we called pthread_key_create(). ok marc@, kurt@
* _FD_LOCK/UNLOCK() is libpthread specific and not needed for librthread, sokurt2007-06-051-2/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | isolate its usage to libpthread only and replace with generic non-static mutex support in the one place it is needed: - remove _FD_LOCK/UNLOCK from lseek and ftruncate in libc and make the functions weak so that libpthread can override with its own new versions that do the locking. - remove _thread_fd_lock/unlock() weak functions from libc and adjust libpthread for the change. - add generic _thread_mutex_lock/unlock/destroy() weak functions in libc to support non-static mutexes in libc and add libpthread and librthread implementations for them. libc can utilize non-static mutexes via the new _MUTEX_LOCK/UNLOCK/DESTROY() macros. Actually these new macros can support both static and non-static mutexes but currently only using them for non-static. - make opendir/closedir/readdir/readdir_r/seekdir/telldir() thread-safe for both thread libraries by using a non-static mutex in the struct _dirdesc (typedef DIR), utilizing it in the *dir functions and remove remaining and incorrect _FD_LOCK/UNLOCK() use in libc. - add comments to both thread libraries to indicate libc depends on the current implementation of static mutex initialization. suggested by marc@ - major bump libc and libpthread due to function removal, structure change and weak symbol conversions. okay marc@, tedu@
* clean up lint warnings related to the nfds_t type. okay marc@ millert@kurt2007-05-211-3/+11
|
* file descriptors are ints. make branch an int too for better structurekurt2007-05-011-3/+3
| | | | allignment. okay marc@
* more lint warning reductions. use int for all priority vars. okay marc@kurt2007-04-271-4/+4
|
* fix thread_continuation_t typedef and use passed curthread instead ofkurt2007-04-271-2/+2
| | | | calling _get_curthread() again. fixes some lint warnings. okay marc@
* Remove unused function _thread_fd_unlock_owned() andkurt2007-04-271-3/+1
| | | | merge _thread_fd_unlock_thread() into _thread_fd_unlock(). okay marc@
* Use rlimit nofiles max to size fd/fdp tables instead of cur. Fixeskurt2007-04-271-2/+9
| | | | applications that increase nofiles using setrlimit(2). ok marc@
* remove unused var. okay marc@kurt2007-04-261-7/+1
|
* Remove duplicate definition of _POSIX_THREAD_ATTR_STACKSIZE and quietkurt2007-03-201-4/+1
| | | | build warnings noticed by david@. okay millert@ marc@
* Last Part of file descriptor race and deadlock corrections.kurt2006-10-031-1/+7
| | | | | | | | When a fd enters the closing state prevent any threads from polling the fd and reschedule the thread with the closing_fd flag set. This fixes a class of deadlocks where a thread is blocked waiting for data (that may never arrive) and a later thread calls close() or dup2() on the fd. okay brad@
* Part 2 of file descriptor race and deadlock corrections.kurt2006-09-261-4/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Adjust design of file descriptor table to eliminate races with both opening and closing of file descriptor entries and eliminates one class of deadlocks. One nice side effect of this change in design should be better performance for applications that open and close many file descriptors due to reduced fd_table_lock contention and fd entry reuse. - Add entry states to manage use of entry and eliminate some closing races. fd entries are not deallocated upon close() now. - Call _thread_fd_table_init with one of five discreet modes to properly initialize an entry and manage the state transition to open. - When closing an entry hold the entry spinlock locked across the state transition and the _thread_sys_close call to close another race. - Introduce a new lock type FD_RDWR_CLOSE that transitions either a closed entry or an open entry into closing state and then waits for a RDWR lock so that the lock queue can unwind normally. All subsequent fd lock attempts for that entry are rejected with EBADF until the fd is fully closed, or reopened by dup2(). Once a thread holds the FD_RDWR_LOCK it is safe to close() it or dup2() on it. - When a thread creates a new fd there is a window of time when another thread could attempt to use the fd before the creating thread has initialized the entry for it. This can result in improper status_flags for the entry, so record the entries init mode, detect when this has happened and correct the status_flags when needed. reviewed by marc@ & brad@, tested by several, okay brad@
* Part 1 of file descriptor race and deadlock corrections.kurt2006-09-221-4/+13
| | | | | | | | | | | | | | | | | | | | File status flags should be shared for dup'ed file descriptors. However fd_table_entry's should not be shared for dup'ed file descriptors so they can be independently be closed without interfering with dup'ed fd's. - split out file status flags into its own structure fs_flags to manage sharing of status flags between dup'ed file descriptors. - when duplicating a fd, initialize a new fd_table_entry for the new fd, but share the status flags via status_flags. - consolidate the code that sets the underlying system fd to be non-blocking to a new function _thread_fs_flags_init() - consolidate the code that sets the underlying system fd back to blocking into a new function _thread_fs_flags_replace() This change is needed as a prerequisite to the coming race and deadlock corrections. okay marc@
* Adapt things to use __type_t instead of _BSD_TYPE_T_millert2006-01-061-7/+7
| | | | | Add new sys/_types.h header Include machine/_types.h or sys/_types.h where applicable
* Add pthread_atfork(3)brad2005-10-301-1/+11
| | | | | | | From FreeBSD 'looks ok' fgsch@ miod@ man page reviewed by jmc@
* major bump to libc and libpthread to break the dependency of amarc2004-06-071-2/+2
| | | | | | particular implementation of libpthread for libc. libc no longer needs pthread.h to compile. OK millert@, brad@, tedu@
* Add a simple work-around for deadlocking on recursivebrad2004-02-011-1/+4
| | | | | | | | readlocks on a rwlock while there are writers waiting. From: FreeBSD's libc_r ok marc@
* threaded version of closefrommarc2004-01-151-1/+2
| | | | | pthread_stackseg_np added. Minor bump for these changes occurred a day or so ago and will not be bumped again
* there is no pause() wrapper (thread_sys_pause) so remove the prototypebrad2003-12-311-2/+1
|
* missing proto for kqueue(); marc@ okmickey2003-11-101-1/+2
|
* Go back to using ITIMER_PROF for the non-profiled libpthread and usemillert2003-08-011-2/+2
| | | | | | | ITIMER_VIRTUAL for the profiled version. Fixes problems when programs linked with libpthread try to use ITIMER_VIRTUAL (and have no way of knowing that this will cause conflicts with the threads lib). marc@ OK
* remove variable never readmarc2003-07-081-2/+1
|
* Add support for blocking thread switches during dlopen and othermarc2003-05-131-1/+2
| | | | | | | | non-thread-safe dl functions. Only enabled for ELF architectures at this time as needed dlxxx support has not yet been added to the a.out run time loader. 'doesn't break xmms at least' tedu@. Tested by others with no comment
* fix bug that would leave an FD locked if dup'd, then closed.marc2003-02-141-1/+2
| | | | Also, for safety lock the _thread_fd_table when removing entries.
* Part 1 of thread fd handling fixes. In the new scheme fd_table_entriesmarc2003-02-041-13/+16
| | | | | | | | | | | | | | | | | for dup-ed fds are shared to ensure proper flag handling. A refcnt was added to control when entries should be freed. Specific changes: close: don't free entry unless refcnt is zero dup: rewrite to use new function _thread_fd_table_dup dup2: rewrite to use new function _thread_fd_table_dup fcntl: use _thread_fd_table_dup uthread_fd: initialize thread fd table, searching for dup-ed fds. Add function to share _thread_fd_table entries when an fd is dup-ed. uthread_init: make it readable. Call fd init functions. All current regression tests plus the mysql torture test pass. The new stdfiles regression test fails (I/O redirection problem). Part 2 is intended to fix that problem
* Create a siginfo_t for thread-to-thread kill.marc2003-01-311-11/+19
| | | | | Clean up (compiler warning elimination). Compile check options added but commented out as they have not been checked on all architectures, yet.
* pthreads signal handling improvements. With these changes allmarc2003-01-271-12/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | of the thread regressions tests pass on i386, sparc, sparc64 (save the siginfo test on sparc64 due to a kernel issue) and alpha. The tests should also pass on ppc. In addition, it fixes the problems with the "mysql torture test" provided by one of our users. The python port also appears to work correctly with these changes. Summary of changes: * check_pending removed from thread structure, no longer used. * unused elements of sigstatus structure removed. The sigstatus structure is now used to keep track of siginfo data instead of defining a local array in uthread_sig.c. * _thread_kern_sched_sig removed * _thread_sig_process goes away -- can't have a lock active when signal handlers are called. Functions now call _thread_sig_handle directly. * _thread_clear_pending now used lib wide to clear pending flags. It was named _clean_pending_flag and only used in uthread_sig.c. The function clears both per thread signals, and per process signals. * _thread_sig_handle now returns a value. * unused debugging macros removed from the thread kernel * dispatch pending signals after switching to a thread providing that signal handling hasn't been deferred by the thread. * process thread switchhooks before dispatching pending sigs * check for thread cancellation before dispatching pending sigs * re-wrote pthread-kill to do the correct thing. It now does minimal thread-kill-specific processing and then calls the existing code in uthread_sig to process the generated signal. * shut the compiler up when compiling uthread_mutex.c * no more "signal_lock". It does more harm than good. * keep track of "per-process" signals. * don't bother saving siginfo_t data for the scheduling signal. * per posix: SIGSTOP cleared when SIGCONT received and vice versa. * add _dispatch_signal to properly dispatch a signal to a thread. It sets the appropriate signal mask, something that was missing in the previous implementation. This fixes several bugs. The previous method held a lock. If the signal handler longjmp-ed the lock was never cleared and no more signals were processed.
* save and restore fp state when switching threads. This, withmarc2003-01-241-2/+2
| | | | | | | | | | | an arch/i386 patch previously commited and arch/sparc64 patches from jason@ make the preemption_float test pass on those two architectures. Do not run signal handlers for a thread until the thread has been made current, ensuring the proper context. Solves several (if not all) of the '_pq_insert_tail: Already in priority queue' problems.
* add a debugging function not normally calledmarc2002-12-111-1/+2
|
* remove unused data member from pthread_cond.marc2002-12-081-2/+1
|
* get rid of compiler warningsmarc2002-11-121-2/+2
|
* removes duplicate functions and factor out common code so the needed (butmarc2002-10-301-12/+2
| | | | | | | | missing) _thread_fd_unlock_owned function can be added with minimal pain. The incorrect special handling of the stdio fds was also removed. Tested with the libc_r regression tests and the mysql regression tests. No complaints from any developers
* signal handling changes. This corrects several signalmarc2002-10-301-4/+6
| | | | | | | handling errors in the threads library. Most of the libc_r regression tests are now ok. thread specific kill semantics are still not correct. No negative comments after posting to tech@ a week or so ago. siginfo test fails on sparc64 due to sparc64 oddity.
* account for the process signal mask when dealing with signals; testedfgsch2002-02-211-1/+12
| | | | a while ago by marc@ and brad@
* Instead of ifdef around ENOTSUP, move it to pthread_private.h and makefgsch2002-01-191-1/+6
| | | | it EOPNOTSUPP.
* More changes from FreeBSD, including:fgsch2001-12-311-14/+15
| | | | | | | | | o Only poll file descriptors when needed. o Change the way timing is achieved, counting scheduling ticks instead of calculating the elapsed time via gettimeofday(). o Prevent an overflow when polling. o Use curthread instead of _thread_run. o Remove extra spaces; indent.
* More sync.fgsch2001-12-191-19/+53
|
* More sync with freebsd code; join related code this time.fgsch2001-12-111-6/+16
|
* Partially sync with FreeBSD; mostly pthread_cancel(3) related changes.fgsch2001-12-081-14/+11
| | | | make includes is needed in case you want to play.