summaryrefslogtreecommitdiffstats
path: root/lib/libthr/thread/thr_fork.c
Commit message (Collapse)AuthorAgeFilesLines
* Fix known issues which blow up the process after dlopen("libthr.so")kib2015-01-181-4/+2
| | | | | | | | | | | | | | | | | | | | | (or loading a dso linked to libthr.so into process which was not linked against threading library). MFC r276630: Remove interposing, fix malloc, reinstall signal handlers wrappers on libthr load. MFC r276681: Avoid calling internal libc function through PLT or accessing data though GOT. MFC r277032: Reduce the size of the interposing table and amount of cancellation-handling code in the libthr. MFC note: r276646 ("do not erronously export 'openat' symbol from rtld") is not applicable to stable/10 yet, since PATHFDS support was not merged.
* MFC r266609:kib2014-06-071-3/+10
| | | | Change the _rtld_atfork() to lock the bind lock in write mode.
* Eliminate redundant code, _thr_spinlock_init() has already been calleddavidxu2012-08-231-3/+0
| | | | in init_private(), don't call it again in fork() wrapper.
* In most cases, cancel_point and cancel_async needn't be checked again,davidxu2010-09-241-1/+2
| | | | because cancellation is almostly checked at cancellation points.
* Because atfork lock is held while forking, a thread cancellation triggereddavidxu2010-09-191-2/+7
| | | | by atfork handler is unsafe, use intenal flag no_cancel to disable it.
* Convert thread list lock from mutex to rwlock.davidxu2010-09-131-2/+2
|
* In function __pthread_cxa_finalize(), also make code for removingdavidxu2010-09-011-1/+8
| | | | atfork handler be async-signal safe.
* pthread_atfork should acquire writer lock and protect the codedavidxu2010-09-011-1/+3
| | | | with critical region.
* Change atfork lock from mutex to rwlock, also make mutexes used by malloc()davidxu2010-09-011-19/+22
| | | | | | | | module private type, when private type mutex is locked/unlocked, thread critical region is entered or leaved. These changes makes fork() async-signal safe which required by POSIX. Note that user's atfork handler still needs to be async-signal safe, but it is not problem of libthr, it is user's responsiblity.
* Add signal handler wrapper, the reason to add it becauses there aredavidxu2010-09-011-0/+6
| | | | | | | | | | | | | | | | | | | | | | | 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.
* Unregister thread specific data destructor when a corresponding dsodavidxu2010-08-271-0/+1
| | | | is unloaded.
* On shared object unload, in __cxa_finalize, call and clear all installedkib2010-08-231-0/+22
| | | | | | | | | | | | | | | | | | | | | | atexit and __cxa_atexit handlers that are either installed by unloaded dso, or points to the functions provided by the dso. Use _rtld_addr_phdr to locate segment information from the address of private variable belonging to the dso, supplied by crtstuff.c. Provide utility function __elf_phdr_match_addr to do the match of address against dso executable segment. Call back into libthr from __cxa_finalize using weak __pthread_cxa_finalize symbol to remove any atfork handler which function points into unloaded object. The rtld needs private __pthread_cxa_finalize symbol to not require resolution of the weak undefined symbol at initialization time. This cannot work, since rtld is relocated before sym_zero is set up. Idea by: kan Reviewed by: kan (previous version) MFC after: 3 weeks
* These are some cosmetic changes to improve the clarity of libthr's fork ↵green2009-05-111-9/+9
| | | | implementation.
* Forcibly unlock the malloc() locks in the child process after fork(),kib2009-03-191-1/+4
| | | | | | | by temporary pretending that the process is still multithreaded. Current malloc lock primitives do nothing for singlethreaded process. Reviewed by: davidxu, deischen
* Provide custom simple allocator for rtld locks in libthr. The allocatorkib2008-12-021-1/+1
| | | | | | | | | does not use any external symbols, thus avoiding possible recursion into rtld to resolve symbols, when called. Reviewed by: kan, davidxu Tested by: rink MFC after: 1 month
* Invoke _rtld_atfork_post earlier, before we reinitialize rtld lockskan2008-12-011-3/+4
| | | | | | | | | | | | by switching into single-thread mode. libthr ignores broken use of lock bitmaps used by default rtld locking implementation, this in turn turns lock handoff in _rtld_thread_init into NOP. This in turn makes child processes of forked multi-threaded programs to run with _thr_signal_block still in effect, with most signals blocked. Reported by: phk, kib
* Unlock the malloc() locks in the child process after fork(). This giveskib2008-11-291-0/+1
| | | | | | | | | | | | | us working malloc in the fork child of the multithreaded process. Although POSIX requires that only async-signal safe functions shall be operable after fork in multithreaded process, not having malloc lower the quality of our implementation. Tested by: rink Discussed with: kan, davidxu Reviewed by: kan MFC after: 1 month
* Add two rtld exported symbols, _rtld_atfork_pre and _rtld_atfork_post.kib2008-11-271-1/+10
| | | | | | | | | | | | | | Threading library calls _pre before the fork, allowing the rtld to lock itself to ensure that other threads of the process are out of dynamic linker. _post releases the locks. This allows the rtld to have consistent state in the child. Although child may legitimately call only async-safe functions, the call may need plt relocation resolution, and this requires working rtld. Reported and debugging help by: rink Reviewed by: kan, davidxu MFC after: 1 month (anyway, not before 7.1 is out)
* Remove 3rd clause, renumber, ok per emailimp2007-01-121-4/+1
|
* Eliminate atomic operations in thread cancellation functions, it shoulddavidxu2006-11-241-1/+1
| | | | reduce overheads of cancellation points.
* Don't inherit THR_FLAGS_NEED_SUSPEND for child process, child processdavidxu2006-10-141-0/+2
| | | | | only has one thread, setting the flag can cause the thread to be suspended and no another thread will resume it.
* Replace internal usage of struct umtx with umutex which can supportsdavidxu2006-09-061-6/+6
| | | | real-time if we want, no functionality is changed.
* WARNS level 4 cleanup.davidxu2006-04-041-0/+4
|
* In preparation for a new malloc implementation:jasone2006-01-121-10/+4
| | | | | | | | | | | | | * Add posix_memalign(). * Move calloc() from calloc.c to malloc.c. Add a calloc() implementation in rtld-elf in order to make the loader happy (even though calloc() isn't used in rtld-elf). * Add _malloc_prefork() and _malloc_postfork(), and use them instead of directly manipulating __malloc_lock. Approved by: phk, markm (mentor)
* Remove in-progress wait code to sync with libpthread's behavior.davidxu2006-01-031-30/+8
|
* Import my recent 1:1 threading working. some features improved includes:davidxu2005-04-021-0/+222
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
OpenPOWER on IntegriCloud