summaryrefslogtreecommitdiff
path: root/threadproc
Commit message (Collapse)AuthorAgeFilesLines
* Revert r1897210, r1897211 and r1884103.ylavic2022-06-305-272/+99
| | | | | | | | Per https://lists.apache.org/thread/w0wmkpngyffv8t5r22xvt3romxn41ycw git-svn-id: https://svn.apache.org/repos/asf/apr/apr/branches/1.7.x@1902369 13f79535-47bb-0310-9956-ffa450edef68
* apr_thread: Follow up to r1897210: 1.7.x has a _WIN32_WCE error path too.ylavic2022-01-191-1/+3
| | | | | | | | | | Destroy the pool if Windows' apr_thread_crate() fails on _WIN32_WCE, the merge in r1897210 applied its changes to the other case (known to trunk) only. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/branches/1.7.x@1897211 13f79535-47bb-0310-9956-ffa450edef68
* apr_thread: Follow up to r1884078: Unmanaged pools for attached threads too.ylavic2022-01-195-225/+155
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | [Note 1.7.x: this removes apr__pool_unmanage() thus r1884103's ABI issues] r1884078 fixed lifetime issues with detached threads by using unmanaged pool destroyed by the thread itself on exit, with no binding to the parent pool. This commit makes use of unmanaged pools for attached threads too, they needed their own allocator anyway due to apr_thread_detach() being callable anytime later. apr__pool_unmanage() was a hack to detach a subpool from its parent, but if a subpool needs its own allocator for this to work correctly there is no point in creating a subpool for threads (no memory reuse on destroy for short living threads for instance). Since an attached thread has its own lifetime now, apr_thread_join() must be called to free its resources/pool, though it's no different than before when destroying the parent pool was UB if the thread was still running (i.e. not joined yet). Let's acknoledge that threads want no binding with the pool passed to them at creation time, besides the abort_fn which they can steal :) Merges r1897179 from trunk. Submitted by: ylavic git-svn-id: https://svn.apache.org/repos/asf/apr/apr/branches/1.7.x@1897210 13f79535-47bb-0310-9956-ffa450edef68
* Merge r936323, r1460182, r1884077, r1884078 from trunk:ylavic2020-12-045-37/+278
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | OS/2: Clean up a thread's pool when it terminates. <not backported in 1.7.x> Add apr_pool_owner_set function to allow use of pool debugging with threads Actually this function has been mentioned in the docs for over 10 years but has never been implemented. </not backported in 1.7.x> Also consistently destroy the thread's pool when it exits normally, not only on apr_thread_exit(). This was already done on OS2. Other platforms than unix are untested. apr_thread: destroy the thread's pool at _join() time, unless _detach()ed. Destroying a joinable thread pool from apr_thread_exit() or when the thread function returns, i.e. from inside the thread itself, is racy or deadlocky with APR_POOL_DEBUG, with the parent pool being destroyed. This commit adds a ->detached flag in each arch's apr_thread_t struct to track whether a thread is detached (either at _create() or _detach() time). If detached, the pool is destroyed when the thread exits, otherwise when the thread is joined with apr_thread_join(). apr_thread: use unmanaged pools for detached threads. A detached thread is by definition out of control, unjoinable, unmanaged, and it can terminate/exit after its parent pool is detroyed. To avoid use-after-free in this case, let's use an unmanaged pool for detached threads, either by creating an unmanaged pool from the start if the thread is created detached, or by "unmanaging" the pool if the thread is detached later with apr_thread_detach(). To "umanage" the pool, provide a new internal helper, apr__pool_unmanage() which takes care of removing the pool from its parent's list. Submitted by: bjh, sf, ylavic, ylavic git-svn-id: https://svn.apache.org/repos/asf/apr/apr/branches/1.7.x@1884103 13f79535-47bb-0310-9956-ffa450edef68
* Merge r1854123 from trunk:ylavic2019-03-071-6/+0
| | | | | | | | | | Signals: Allow handling of SIGUSR2 in apr_signal_thread. It's not like users have so many free signals to play with, let's increase this number by 100% here, not so bad :) git-svn-id: http://svn.apache.org/repos/asf/apr/apr/branches/1.7.x@1854995 13f79535-47bb-0310-9956-ffa450edef68
* Backport r1710307jailletc362015-10-241-3/+3
| | | | git-svn-id: http://svn.apache.org/repos/asf/apr/apr/branches/1.6.x@1710308 13f79535-47bb-0310-9956-ffa450edef68
* Fixed type; fixed comments.fuankg2014-07-161-4/+4
| | | | git-svn-id: http://svn.apache.org/repos/asf/apr/apr/branches/1.6.x@1611061 13f79535-47bb-0310-9956-ffa450edef68
* Backport r741867 from trunk, which fixes a logic error.sf2014-05-141-1/+1
| | | | | | | | | | The original commit message was: Fix typo git-svn-id: http://svn.apache.org/repos/asf/apr/apr/branches/1.6.x@1594689 13f79535-47bb-0310-9956-ffa450edef68
* Merge r741862, r741866 from trunk:jim2014-04-285-1/+61
| | | | | | | | | Add object perms set macros and implement them for shm and mutex Submitted by: mturk, rpluem Reviewed/backported by: jim git-svn-id: http://svn.apache.org/repos/asf/apr/apr/branches/1.6.x@1590617 13f79535-47bb-0310-9956-ffa450edef68
* merge r1384764 from trunk:trawick2013-10-211-2/+2
| | | | | | | spelling fix git-svn-id: http://svn.apache.org/repos/asf/apr/apr/branches/1.5.x@1534104 13f79535-47bb-0310-9956-ffa450edef68
* merge r1372093 from trunk:trawick2013-10-211-0/+1
| | | | | | | release critical section before returning on error path git-svn-id: http://svn.apache.org/repos/asf/apr/apr/branches/1.5.x@1534103 13f79535-47bb-0310-9956-ffa450edef68
* revret 1533105jim2013-10-175-62/+1
| | | | git-svn-id: http://svn.apache.org/repos/asf/apr/apr/branches/1.5.x@1533107 13f79535-47bb-0310-9956-ffa450edef68
* Merge r1533104 from trunk:jim2013-10-175-1/+62
| | | | | | | | | it should really handle src==NULL Reviewed/backported by: jim git-svn-id: http://svn.apache.org/repos/asf/apr/apr/branches/1.5.x@1533105 13f79535-47bb-0310-9956-ffa450edef68
* definAtelyrjung2013-10-031-1/+1
| | | | | | | Backport of r1213382 from trunk. git-svn-id: http://svn.apache.org/repos/asf/apr/apr/branches/1.5.x@1528818 13f79535-47bb-0310-9956-ffa450edef68
* Followup on r1481263: use already existingrjung2013-05-111-1/+1
| | | | | | | | | | platform independent macro instead of pthread define. Backport of r1481265 from trunk. git-svn-id: http://svn.apache.org/repos/asf/apr/apr/branches/1.5.x@1481266 13f79535-47bb-0310-9956-ffa450edef68
* Use correct pthread constant.rjung2013-05-111-1/+1
| | | | | | | Backport of r1481262 from trunk. git-svn-id: http://svn.apache.org/repos/asf/apr/apr/branches/1.5.x@1481263 13f79535-47bb-0310-9956-ffa450edef68
* Clarify what happens to the proc structure used by apr_fork(). rjung2011-11-081-7/+3
| | | | | | | | | | | Set the proc->pid field to the pid of the newly created child. Note that a mere pid value provides little entropy to mix into the child random pool. Backport of r1198860 from trunk. git-svn-id: http://svn.apache.org/repos/asf/apr/apr/branches/1.5.x@1199082 13f79535-47bb-0310-9956-ffa450edef68
* backport r979891:sf2011-10-153-9/+9
| | | | | | | | | | | | | | Fix various issues found by cppcheck - error handling issues - use of uninitialized data - null pointer dereference - unused variables - memory/fd leaks - broken code in threadproc/beos/proc.c git-svn-id: http://svn.apache.org/repos/asf/apr/apr/branches/1.5.x@1183724 13f79535-47bb-0310-9956-ffa450edef68
* Backport r1183685:sf2011-10-151-3/+6
| | | | | | | | | | | | Don't close any of the new stdin/stdout/stderr FDs in the child if it already has the correct FD. PR: 51995 Submitted by: Dan Ports <drkp csail mit edu>] git-svn-id: http://svn.apache.org/repos/asf/apr/apr/branches/1.5.x@1183706 13f79535-47bb-0310-9956-ffa450edef68
* merge trunk revs 1083169, 1083177, 1083178, 1083183, and 1083227trawick2011-03-212-2/+3
| | | | | | | | | | to resolve some gcc warnings and dead code on Windows (the testlfsabi change from r1083183 is omitted, as the testcases aren't in this branch) git-svn-id: http://svn.apache.org/repos/asf/apr/apr/branches/1.5.x@1083869 13f79535-47bb-0310-9956-ffa450edef68
* Fixed NetWare prototype warnings.fuankg2011-03-102-5/+4
| | | | git-svn-id: http://svn.apache.org/repos/asf/apr/apr/branches/1.5.x@1080082 13f79535-47bb-0310-9956-ffa450edef68
* Fixed compilation when APR_HAVE_STRUCT_RLIMIT=0.fuankg2011-03-102-4/+21
| | | | git-svn-id: http://svn.apache.org/repos/asf/apr/apr/branches/1.5.x@1080074 13f79535-47bb-0310-9956-ffa450edef68
* Axed C++ comments and tabs.fuankg2011-02-181-27/+26
| | | | git-svn-id: http://svn.apache.org/repos/asf/apr/apr/branches/1.5.x@1071966 13f79535-47bb-0310-9956-ffa450edef68
* Merge r783722 from trunk:rpluem2009-06-113-3/+3
| | | | | | | | | | | | * We need to disable inheritance in the case of success like in the cases for stdout and stdin. Fixes the same issue fixed for unix in r783398 Submitted by: rpluem Reviewed by: rpluem git-svn-id: http://svn.apache.org/repos/asf/apr/apr/branches/1.4.x@783725 13f79535-47bb-0310-9956-ffa450edef68
* Merge r783398 from trunk:rpluem2009-06-101-1/+1
| | | | | | | | | | | * We need to disable inheritance in the case of success like in the cases for stdout and stdin. Submitted by: rpluem Reviewed by: rpluem git-svn-id: http://svn.apache.org/repos/asf/apr/apr/branches/1.4.x@783399 13f79535-47bb-0310-9956-ffa450edef68
* Clear up this wording a bitwrowe2008-11-231-2/+2
| | | | git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@720054 13f79535-47bb-0310-9956-ffa450edef68
* mplement apr_proc_wait_all_procs for windowsmturk2008-04-171-15/+126
| | | | git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@649208 13f79535-47bb-0310-9956-ffa450edef68
* Check for bogus (negative) signal numbersmartin2008-02-011-2/+2
| | | | git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@617375 13f79535-47bb-0310-9956-ffa450edef68
* Simplify handling of z/OS pthread API nuances. Beyond thetrawick2007-11-192-13/+17
| | | | | | | | | | | | | simplification, it fixes a compile error in the call to pthread_yield() on z/OS. Submitted by: David Jones I modified it slightly to use AC_DEFINE() as suggested by jorton. git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@596402 13f79535-47bb-0310-9956-ffa450edef68
* Fix mismatch, using child_err when dealing with stdout.bjh2007-10-311-1/+1
| | | | git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@590849 13f79535-47bb-0310-9956-ffa450edef68
* OS/2: Fix condition for restoring std handles after spawning a process.bjh2007-10-311-6/+15
| | | | | | | | We still need to restore the std handles if "no file" (filedes == -1) is passed to the child. git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@590848 13f79535-47bb-0310-9956-ffa450edef68
* Fix build breakage due to syntax errors in threadproc/os2/proc.c.bjh2007-10-301-9/+10
| | | | | | | | I haven't yet verified that the code works but this is a step in the right direction. git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@590037 13f79535-47bb-0310-9956-ffa450edef68
* Fix up a few netware'isms and missing brackets left over from the refactoring.bnicholes2007-10-161-6/+10
| | | | git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@585260 13f79535-47bb-0310-9956-ffa450edef68
* Backport the std handling improvements to Netware, OS2, BeOS.wrowe2007-10-153-285/+384
| | | | | | | | | | | | | | | | | | | | | These may need massaging and do need review by their respective communities. Note that someone from the OS2 community needs to ping me with resolving the missing apr_arch_inherit.h mess; this should be very easy to translate into DosSetFHState(handle, OPEN_FLAGS_NOINHERIT); bits, but to more thoroughly resolve the issue, we should take it a step further and consider the NT implementation which toggles inheritance on only for handles as they hit proc_create, so that you don't have cross-process handle leakage into the wrong processes. git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@584928 13f79535-47bb-0310-9956-ffa450edef68
* Here's my recommendation; upon opening the pipes, always set the parent-endwrowe2007-10-141-15/+18
| | | | | | | | | | | | of the pipe to uninherited. Let it be closed upon cleanup_for_exec. The later dup2() for the parent pipe does not automagically become inherited again, and later dup()'s are never inherited by default. There's no longer an explicit need to close the parent-end in proc_create git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@584570 13f79535-47bb-0310-9956-ffa450edef68
* apr_file_dup() varies from dup2 by not setting the child handle aswrowe2007-10-141-12/+30
| | | | | | | | | | | | | | | inherited. Solve this by setting the duplicated handle to inherit. once finished with the fork(), now that we don't waste pipe creation resources on a single handle, watch out for closing the parent handle inside the child. in fact I believe that toggling parent_* handles apr_file_inherit_unset way back in apr_procattr_io_set / apr_procattr_child_*_set would be more efficient; comments? git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@584569 13f79535-47bb-0310-9956-ffa450edef68
* Solve two potential problems with one shot.wrowe2007-10-141-77/+66
| | | | | | | | | | | | | | | | | | First; we absolutely do NOT want to waste our time creating a pipe, when the caller has their own file descriptors all set up to give to the child process (and use itself). We can also presume a single ended pipe is about as interesting as the sound of one hand clapping. Create the pipe only when we don't already have any child/parent pipes set up, and when the caller passes no files for us to use. Otherwise, we simply dup for our own use rather than dup2. Second; we absolutely cannot dup2 into the static 'no_file' special fd, so we'll guard against this and also dup, instead, for this case. git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@584500 13f79535-47bb-0310-9956-ffa450edef68
* With the correction of setting ->timeout = 0 way up in thewrowe2007-10-141-55/+9
| | | | | | | | apr_file_pipe_create_ex() for win32, many lines are redundant. Thanks to Eric for picking up on this mess in the first place! git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@584496 13f79535-47bb-0310-9956-ffa450edef68
* * Remove unnecessary assignment of pool attribute.rpluem2007-10-135-5/+0
| | | | | | | | Submitted by: Lucian Adrian Grijincu <lucian.grijincu gmail.com> Reviewed by: rpluem git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@584411 13f79535-47bb-0310-9956-ffa450edef68
* apr_procattr_io_set() on Windows: Set pipe handles non-blocking astrawick2007-10-101-3/+51
| | | | | | | | | | | appropriate based on the input parameters. PR: 43522 Submitted by: Eric Covener <covener gmail.com> Reviewed by: trawick git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@583421 13f79535-47bb-0310-9956-ffa450edef68
* Close the standard handle in the child, *when* we tagged it with fd -1wrowe2007-10-011-3/+3
| | | | | | | | | | (we aren't trying to close our child_fd's here). Submitted by: David Glasser <glasser@davidglasser.net> git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@581089 13f79535-47bb-0310-9956-ffa450edef68
* Had inverted the logic for closing the handles in the parent, thanks to glasserwrowe2007-10-011-6/+6
| | | | | | | for pointing this out to me on #irc. git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@581042 13f79535-47bb-0310-9956-ffa450edef68
* Thanks for catching the unbalanced parens, jerenkrantz.wrowe2007-09-291-3/+3
| | | | | | These can be reduced further and still remain legible. git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@580632 13f79535-47bb-0310-9956-ffa450edef68
* Fix compile errors introduced in r580486 due to missing ()s.jerenkrantz2007-09-291-6/+6
| | | | git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@580591 13f79535-47bb-0310-9956-ffa450edef68
* Undo the 'fix' to the unix flaw. Yes, there still are flaws;wrowe2007-09-281-36/+12
| | | | | | | | | | if we use apr_procattr_stderr_set() it will not close out the previous handle parked there by _io_set(). But it also does not attempt to touch the _io_set() no_file STATIC apr_file_t's so there is nothing to otherwise fix here immediately. git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@580515 13f79535-47bb-0310-9956-ffa450edef68
* Introduce APR_NO_FILE as an option for any of the three stdio streamswrowe2007-09-281-21/+68
| | | | | | | | | | | | to cause the specified streams to be closed to the child process, when the caller has chosen that flag via apr_procattr_io_set(). ALSO; solve a serious flaw where we attempted to dup2 to a non existant file if the user had not already called apr_procattr_io_set()! The Unix implementation. git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@580486 13f79535-47bb-0310-9956-ffa450edef68
* Introduce APR_NO_FILE as an option for any of the three stdio streamswrowe2007-09-281-22/+44
| | | | | | | | | | to cause the specified streams to be closed to the child process, when the caller has chosen that flag via apr_procattr_io_set(). This is the nonportable flavor targeting 1.2.12; unix 1.3.0 specific commit to follow. git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@580484 13f79535-47bb-0310-9956-ffa450edef68
* Fix cut and paste typo which scuttled the last release, thiswrowe2007-09-041-2/+2
| | | | | | | caused StdOutput to never be inherited (something not noticed, nor particularly interesting in httpd, which is how I missed it). git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@572457 13f79535-47bb-0310-9956-ffa450edef68
* Fix r569890 - this error did not hit 1.2 or 0.9 branches,wrowe2007-09-011-2/+2
| | | | | | | | thankfully. Submitted by: Steven Narin <steven.narin googlemail.com> git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@571712 13f79535-47bb-0310-9956-ffa450edef68
* Correct r569882 typo; we must leave what we enter.wrowe2007-08-261-1/+1
| | | | git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@569890 13f79535-47bb-0310-9956-ffa450edef68