#
259065 |
|
07-Dec-2013 |
gjb |
- Copy stable/10 (r259064) to releng/10.0 as part of the 10.0-RELEASE cycle. - Update __FreeBSD_version [1] - Set branch name to -RC1
[1] 10.0-CURRENT __FreeBSD_version value ended at '55', so start releng/10.0 at '100' so the branch is started with a value ending in zero.
Approved by: re (implicit) Sponsored by: The FreeBSD Foundation |
#
256281 |
|
10-Oct-2013 |
gjb |
Copy head (r256279) to stable/10 as part of the 10.0-RELEASE cycle.
Approved by: re (implicit) Sponsored by: The FreeBSD Foundation
|
#
250154 |
|
01-May-2013 |
jilles |
Add accept4() system call.
The accept4() function, compared to accept(), allows setting the new file descriptor atomically close-on-exec and explicitly controlling the non-blocking status on the new socket. (Note that the latter point means that accept() is not equivalent to any form of accept4().)
The linuxulator's accept4 implementation leaves a race window where the new file descriptor is not close-on-exec because it calls sys_accept(). This implementation leaves no such race window (by using falloc() flags). The linuxulator could be fixed and simplified by using the new code.
Like accept(), accept4() is async-signal-safe, a cancellation point and permitted in capability mode.
|
#
212076 |
|
01-Sep-2010 |
davidxu |
Add signal handler wrapper, the reason to add it becauses there are some cases we want to improve: 1) if a thread signal got a signal while in cancellation point, it is possible the TDP_WAKEUP may be eaten by signal handler if the handler called some interruptibly system calls. 2) In signal handler, we want to disable cancellation. 3) When thread holding some low level locks, it is better to disable signal, those code need not to worry reentrancy, sigprocmask system call is avoided because it is a bit expensive. The signal handler wrapper works in this way: 1) libthr installs its signal handler if user code invokes sigaction to install its handler, the user handler is recorded in internal array. 2) when a signal is delivered, libthr's signal handler is invoke, libthr checks if thread holds some low level lock or is in critical region, if it is true, the signal is buffered, and all signals are masked, once the thread leaves critical region, correct signal mask is restored and buffered signal is processed. 3) before user signal handler is invoked, cancellation is temporarily disabled, after user signal handler is returned, cancellation state is restored, and pending cancellation is rescheduled.
|
#
211524 |
|
20-Aug-2010 |
davidxu |
In current implementation, thread cancellation is done in signal handler, which does not know what is the state of interrupted system call, for example, open() system call opened a file and the thread is still cancelled, result is descriptor leak, there are other problems which can cause resource leak or undeterminable side effect when a thread is cancelled. However, this is no longer true in new implementation.
In defering mode, a thread is canceled if cancellation request is pending and later the thread enters a cancellation point, otherwise, a later pthread_cancel() just causes SIGCANCEL to be sent to the target thread, and causes target thread to abort system call, userland code in libthr then checks cancellation state, and cancels the thread if needed. For example, the cancellation point open(), the thread may be canceled at start, but later, if it opened a file descriptor, it is not canceled, this avoids file handle leak. Another example is read(), a thread may be canceled at start of the function, but later, if it read some bytes from a socket, the thread is not canceled, the caller then can decide if it should still enable cancelling or disable it and continue reading data until it thinks it has read all bytes of a packet, and keeps a protocol stream in health state, if user ignores partly reading of a packet without disabling cancellation, then second iteration of read loop cause the thread to be cancelled. An exception is that the close() cancellation point always closes a file handle despite whether the thread is cancelled or not.
The old mechanism is still kept, for a functions which is not so easily to fix a cancellation problem, the rough mechanism is used.
Reviewed by: kib@
|
#
211522 |
|
20-Aug-2010 |
davidxu |
According to specification, function fcntl() is a cancellation point only when cmd argument is F_SETLKW.
|
#
198508 |
|
27-Oct-2009 |
kib |
Current pselect(3) is implemented in usermode and thus vulnerable to well-known race condition, which elimination was the reason for the function appearance in first place. If sigmask supplied as argument to pselect() enables a signal, the signal might be delivered before thread called select(2), causing lost wakeup. Reimplement pselect() in kernel, making change of sigmask and sleep atomic.
Since signal shall be delivered to the usermode, but sigmask restored, set TDP_OLDMASK and save old mask in td_oldsigmask. The TDP_OLDMASK should be cleared by ast() in case signal was not gelivered during syscall execution.
Reviewed by: davidxu Tested by: pho MFC after: 1 month
|
#
197968 |
|
11-Oct-2009 |
jilles |
Make openat(2) a cancellation point.
This is required by POSIX and matches open(2).
Reviewed by: kib, jhb MFC after: 1 month
|
#
189553 |
|
09-Mar-2009 |
davidxu |
Don't ignore other fcntl functions, directly call __sys_fcntl if WITHOUT_SYSCALL_COMPAT is not defined.
Reviewed by: deischen
|
#
189549 |
|
09-Mar-2009 |
davidxu |
Don't reference non-existent __fcntl_compat if WITHOUT_SYSCALL_COMPAT is defined.
Submitted by: Pawel Worach "pawel dot worach at gmail dot com"
|
#
179434 |
|
30-May-2008 |
dfr |
Call the fcntl compatiblity wrapper from the thread library fcntl wrappers so that they get the benefit of the (limited) forward ABI compatibility.
MFC after: 1 week
|
#
174805 |
|
20-Dec-2007 |
davidxu |
Remove vfork() overloading, it is no longer needed.
|
#
165967 |
|
12-Jan-2007 |
imp |
Remove 3rd clause, renumber, ok per email
|
#
164583 |
|
24-Nov-2006 |
davidxu |
Eliminate atomic operations in thread cancellation functions, it should reduce overheads of cancellation points.
|
#
160662 |
|
25-Jul-2006 |
davidxu |
1. Don't override underscore version of aio_suspend(), system(), wait(), waitpid() and usleep(), they are internal versions and should not be cancellation points. 2. Make wait3() as a cancellation point. 3. Move raise() and pause() into file thr_sig.c. 4. Add functions _sigsuspend, _sigwait, _sigtimedwait and _sigwaitinfo, remove SIGCANCEL bit in wait-set for those functions, the signal is used internally to implement thread cancellation.
|
#
157457 |
|
04-Apr-2006 |
davidxu |
WARNS level 4 cleanup.
|
#
151972 |
|
02-Nov-2005 |
davidxu |
Remove a redundant _get_curthread() call.
|
#
151968 |
|
02-Nov-2005 |
davidxu |
In raise(), use a shortcut to directly send signal to current thread.
|
#
148658 |
|
02-Aug-2005 |
deischen |
Add a cancellation point for usleep().
While here, fix sleep() so that it is also a cancellation point (a missing weak reference prevented that).
|
#
144518 |
|
01-Apr-2005 |
davidxu |
Import my recent 1:1 threading working. some features improved includes: 1. fast simple type mutex. 2. __thread tls works. 3. asynchronous cancellation works ( using signal ). 4. thread synchronization is fully based on umtx, mainly, condition variable and other synchronization objects were rewritten by using umtx directly. those objects can be shared between processes via shared memory, it has to change ABI which does not happen yet. 5. default stack size is increased to 1M on 32 bits platform, 2M for 64 bits platform. As the result, some mysql super-smack benchmarks show performance is improved massivly.
Okayed by: jeff, mtm, rwatson, scottl
|
#
135301 |
|
16-Sep-2004 |
mtm |
Implement cancellation points in libc interfaces, as specified by POSIX.
|
#
131181 |
|
27-Jun-2004 |
mtm |
Implement pthread_atfork in libthr. This is mostly from deichen's work in libpthread.
Submitted by: Dan Nelson <dnelson@allantgroup.com>
|
#
129484 |
|
20-May-2004 |
mtm |
Make libthr async-signal-safe without costly signal masking. The guidlines I followed are: Only 3 functions (pthread_cancel, pthread_setcancelstate, pthread_setcanceltype) are required to be async-signal-safe by POSIX. None of the rest of the pthread api is required to be async-signal-safe. This means that only the three mentioned functions are safe to use from inside signal handlers. However, there are certain system/libc calls that are cancellation points that a caller may call from within a signal handler, and since they are cancellation points calls have to be made into libthr to test for cancellation and exit the thread if necessary. So, the cancellation test and thread exit code paths must be async-signal-safe as well. A summary of the changes follows:
o Almost all of the code paths that masked signals, as well as locking the pthread structure now lock only the pthread structure. o Signals are masked (and left that way) as soon as a thread enters pthread_exit(). o The active and dead threads locks now explicitly require that signals are masked. o Access to the isdead field of the pthread structure is protected by both the active and dead list locks for writing. Either one is sufficient for reading. o The thread state and type fields have been combined into one three-state switch to make it easier to read without requiring a lock. It doesn't need a lock for writing (and therefore for reading either) because only the current thread can write to it and it is an integer value. o The thread state field of the pthread structure has been eliminated. It was an unnecessary field that mostly duplicated the flags field, but required additional locking that would make a lot more code paths require signal masking. Any truly unique values (such as PS_DEAD) have been reborn as separate members of the pthread structure. o Since the mutex and condvar pthread functions are not async-signal-safe there is no need to muck about with the wait queues when handling a signal ... o ... which also removes the need for wrapping signal handlers and sigaction(2). o The condvar and mutex async-cancellation code had to be revised as a result of some of these changes, which resulted in semi-unrelated changes which would have been difficult to work on as a separate commit, so they are included as well.
The only part of the changes I am worried about is related to locking for the pthread joining fields. But, I will take a closer look at them once this mega-patch is committed.
|
#
127486 |
|
27-Mar-2004 |
mtm |
o Since we're not using signals for thread synchronization anymore, sigprocmask no longer needs to be wrapped. o raise(3) is applied to the calling thread in a threaded program. o In the sigaction wrapper reference the correct structure. o Don't treat SIGTHR especially anymore (infact it won't exist in a little while).
|
#
123348 |
|
09-Dec-2003 |
mtm |
o Add a wrapper around sigaction(2), so we can insert our own wrapper around signals. o Lock the process global signal action table.
|
#
123347 |
|
09-Dec-2003 |
mtm |
Enable cancellation points around some syscalls.
|
#
115260 |
|
23-May-2003 |
mtm |
Make WARNS2 clean. The fixes mostly included: o removed unused variables o explicit inclusion of header files o prototypes for externally defined functions
Approved by: re/blanket libthr
|
#
112918 |
|
01-Apr-2003 |
jeff |
- Add libthr but don't hook it up to the regular build yet. This is an adaptation of libc_r for the thr system call interface. This is beta quality code.
|