summaryrefslogtreecommitdiff
path: root/util-misc
Commit message (Collapse)AuthorAgeFilesLines
* Remove trailing whitespaces in *.c.Ivan Zhakov2022-11-205-56/+56
| | | | git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1905414 13f79535-47bb-0310-9956-ffa450edef68
* Follow up to r1884109: Fix synchronization in thread_pool_cleanup().Yann Ylavic2021-04-261-20/+16
| | | | | | | | | Ask each thread to signal its task completion individually when being waited in wait_on_busy_threads(), and ignore threads that have already finished their task (elt->current_owner == NULL). git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1889217 13f79535-47bb-0310-9956-ffa450edef68
* apr_thread_pool: don't detach worker threads (and always join them).Yann Ylavic2020-12-041-156/+220
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Detached threads are out of control and don't give the user a way to synchronize when the program ends (or when the thread_pool is destroyed). Rework the synchronization logic so that dead threads are always joined. This is done by adding dead_thds ring and a join_dead_threads() function called from several places: on termination when the thread_pool is destroyed, on resizing with apr_thread_pool_{thread,idle}_max_set() when stopping off limits threads, on maintenance when a task is added/cancelled. Since join_dead_threads() waits for threads already dead (not the idle/busy ones asked to die) the operation is not blocking indefinitely, so there is no indefinite (nor much) overhead added to these places due to waiting for dead threads. The thread_pool_func() worker function is reworked to have a single point of exit, and to always update the rings and counters accurately according to the thread state, which allows for simpler maintenance and/or termination from the other functions. The threads now put themselves into the (new) dead_thds ring before exit, and the apr_thread_pool_{thread,idle}_max_set() functions don't modify the idle or busy rings concurrently with the thread_pool_func() workers anymore. They only ask the threads to stop and put themselves in dead_thds. To join all the threads in thread_pool_cleanup(), cancel all the tasks and wait for the busy threads handling them to die/idle (thanks to the new "work_done" condition variable triggered by the thread after its task), then stop all the remaining threads by calling apr_thread_pool_thread_max_set(0), and finally wait for the last thread to exit (thanks to the new "all_done" condition var triggered by the last thread exiting, replacing the spin wait). So destroying the thread_pool (or a parent pool) may wait (indefinitely) for all the active tasks to complete, which is the purpose of this commit: avoid undefined behaviour in this case. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1884098 13f79535-47bb-0310-9956-ffa450edef68
* apu_dso_init: Fix pool lifetime and introduce a reference count. Graham Leggett2019-06-231-16/+32
| | | | | | | | apu_dso_init() can now be called more than once (from multiple modules) and from unrelated pools (usually seen in unit tests). git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1861957 13f79535-47bb-0310-9956-ffa450edef68
* * util-misc/apr_thread_pool.cIvan Zhakov2019-05-271-1/+1
| | | | | | | | (apr_thread_pool_thread_max_set): Use apr_size_t instead of unsigned int to avoid compiler warning. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1860156 13f79535-47bb-0310-9956-ffa450edef68
* Simplify apr_errprintf() to return a structure instead of a status.Graham Leggett2018-09-011-11/+9
| | | | git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1839815 13f79535-47bb-0310-9956-ffa450edef68
* Add apr_errprintf() as a convenience function to create andGraham Leggett2018-08-191-0/+45
| | | | | | | populate apu_err_t. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1838375 13f79535-47bb-0310-9956-ffa450edef68
* apr_reslist: put common code in push_resource().Yann Ylavic2018-06-211-12/+13
| | | | git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1834064 13f79535-47bb-0310-9956-ffa450edef68
* apr_reslist: don't release/re-acquire the mutex in apr_reslist_release().Yann Ylavic2018-06-211-20/+20
| | | | | | | | We can hold the mutex for the whole release time by adding and using an unlocked reslist_maintain() helper, and ensure more fairness for the releaser. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1834061 13f79535-47bb-0310-9956-ffa450edef68
* apr_reslist: add apr_reslist_acquire_ex().Yann Ylavic2018-06-211-8/+31
| | | | | | | | | Allows to control acquire order, either LIFO (default and current behaviour) or FIFO. Associated test upcoming... git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1834034 13f79535-47bb-0310-9956-ffa450edef68
* apr_reslist: always expire oldest entries first.Yann Ylavic2018-06-211-13/+20
| | | | | | | | | When a resource is to be acquired, we should check for expiring entries starting from the oldest to the youngest one, otherwise it's only when the latter expires that all of the resources are killed in a batch. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1834030 13f79535-47bb-0310-9956-ffa450edef68
* apr_reslist: follow up to r1834023: avoid unnecessary apr_time_now() calls.Yann Ylavic2018-06-211-3/+7
| | | | | | | When ttl=0 is configured, we never need to check for expiry. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1834024 13f79535-47bb-0310-9956-ffa450edef68
* apr_reslist: fix release of resource with zero/no TTL.Yann Ylavic2018-06-211-2/+4
| | | | | | | | | | | | Ignore expiry when ttl=0 in apr_reslist_maintain(), like apr_reslist_acquire(). While ttl=0 is supposed to mean no TTL/expiry, apr_reslist_maintain() hence apr_reslist_release() were destroying all resources above smax in this case. Corresponding test already committed in r1834022. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1834023 13f79535-47bb-0310-9956-ffa450edef68
* apr_crypto: follow up to r1833359: fix some root pool scopes (possible leaks).Yann Ylavic2018-06-141-3/+14
| | | | | | | | | | | | | | | | Keep the root pool scope for things that need it only (global lists of drivers or libs), but otherwise use the passed in pool (crypto libs, default PRNG, errors). This allows the caller to control the scope of initialization functions, and for instance be able to re-initialize when apr_crypto is unloaded/reloaded from a DSO attached to the passed-in pool (e.g. mod_ssl in httpd). apu_dso_load() needs to return its handles when called multiple times (EINIT), it's not the caller's job (like crypto drivers) to maintain them. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1833525 13f79535-47bb-0310-9956-ffa450edef68
* Revert apr_reslist_fifo_set() (r1828289 and follow ups).Yann Ylavic2018-04-131-25/+3
| | | | | | | | | Will re-implement the feature through apr_reslist_acquire_fifo(), as proposed by Bill. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1829102 13f79535-47bb-0310-9956-ffa450edef68
* reslist: follow up to r1828289: enfore empty list requirement when setting fifo.Yann Ylavic2018-04-061-1/+7
| | | | | | | | | The doxygen remark wasn't enough as noted by Ruediger. [Reverted by r1829102] git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1828492 13f79535-47bb-0310-9956-ffa450edef68
* reslist: follow up to r1828289: adjust maintenance top too.Yann Ylavic2018-04-041-2/+7
| | | | | | | | | Also, clarify in doxygen when apr_reslist_fifo_set() should be called. [Reverted by r1829102] git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1828369 13f79535-47bb-0310-9956-ffa450edef68
* reslist: follow up to r1828289: name fifo arg according to doxygen.Yann Ylavic2018-04-041-2/+2
| | | | | | | [Reverted by r1829102] git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1828367 13f79535-47bb-0310-9956-ffa450edef68
* reslist: Add apr_reslist_fifo_set().Yann Ylavic2018-04-031-1/+12
| | | | | | | | | This allows to reuse resources in FIFO mode instead of the default LIFO mode. [Reverted by r1829102] git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1828289 13f79535-47bb-0310-9956-ffa450edef68
* apr_queue: Add apr_queue_timedpush() and apr_queue_timedpop() toYann Ylavic2015-03-161-79/+56
| | | | | | | | | | | support timedout operations. PR 56951. Signed-off-by: Anthony Minessale <anthm freeswitch.org> Signed-off-by: Travis Cross <tc traviscross.com> Reviewed/Modified: ylavic git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1667073 13f79535-47bb-0310-9956-ffa450edef68
* fix some minor bugs and useless assignments so that clang scan-buildJeff Trawick2013-10-231-0/+3
| | | | | | | is a little quieter git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1534882 13f79535-47bb-0310-9956-ffa450edef68
* Include apr_version.h to get the value of APR_MAJOR_VERSIONJeff Trawick2013-08-231-0/+1
| | | | | | | | so that we don't go looking in <searchpath>/apr-APR_MAJOR_VERSION for APU DSOs. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1516839 13f79535-47bb-0310-9956-ffa450edef68
* Followup fix for incomplete patch with r1479836.Guenter Knauf2013-05-071-4/+3
| | | | git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1479853 13f79535-47bb-0310-9956-ffa450edef68
* Fix forever loop on NetWare when trying to get parent pool.Guenter Knauf2013-05-071-2/+4
| | | | git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1479836 13f79535-47bb-0310-9956-ffa450edef68
* kill the threads in the thread pool in a pre-cleanupStefan Fritsch2013-03-231-3/+3
| | | | | | | | | | | This makes sure that the threads are killed when we start destroying any sub-pools they may be using. This is the last missing part to make the test suite run successfully with full pool debugging enabled. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1460185 13f79535-47bb-0310-9956-ffa450edef68
* thread_pool/reslist: take ownership of the pool when we lock the mutexStefan Fritsch2013-03-232-0/+14
| | | | | | | | (except in cases where there is no chance that the pool is used) git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1460183 13f79535-47bb-0310-9956-ffa450edef68
* Remove variables that we assign but never read.Graham Leggett2011-11-281-3/+2
| | | | git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1207680 13f79535-47bb-0310-9956-ffa450edef68
* Fix thread unsafe pool usage. This is a potential culprit for the occasionalStefan Fritsch2011-05-221-5/+10
| | | | | | | testreslist failures. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1126207 13f79535-47bb-0310-9956-ffa450edef68
* replace expensive % with faster (2-4x) functional equiv.Jim Jagielski2011-01-271-4/+12
| | | | git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1064276 13f79535-47bb-0310-9956-ffa450edef68
* apr_thread_pool: Fix some potential deadlock situations.Jeff Trawick2010-09-281-24/+6
| | | | | | | | | | | | The use of two mutexes allowed race conditions between releasing one and acquiring another. PR: 49709 Submitted by: Joe Mudd <Joe.Mudd sas.com> Reviewed by: henryjen, trawick git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1002105 13f79535-47bb-0310-9956-ffa450edef68
* apr_thread_pool_create: Fix pool corruption caused by multithread use of the ↵Jeff Trawick2010-09-271-0/+6
| | | | | | | | | | | | | pool when multiple initial threads are created. PR: 47843 Submitted by: Alex Korobka <akorobka fxcm.com> Reviewed by: trawick git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1001685 13f79535-47bb-0310-9956-ffa450edef68
* - remove unused assignmentPhilip M. Gollucci2010-08-051-1/+1
| | | | | | | | Reported by: clang static analyzer git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@982736 13f79535-47bb-0310-9956-ffa450edef68
* Renamed _self var since (Open)Watcom recognizes this as reserved.Guenter Knauf2010-08-031-7/+7
| | | | git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@981753 13f79535-47bb-0310-9956-ffa450edef68
* Refactor away apu_version legacy cruftWilliam A. Rowe Jr2009-12-212-38/+0
| | | | git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@892985 13f79535-47bb-0310-9956-ffa450edef68
* Refactoring to drop apr_config.h, renamed APU_MODULE_DECLARE_DATAWilliam A. Rowe Jr2009-12-171-2/+1
| | | | git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@891835 13f79535-47bb-0310-9956-ffa450edef68
* SECURITY: CVE-2009-2412 (cve.mitre.org)William A. Rowe Jr2009-08-041-9/+20
| | | | | | | | | | | | | | | | | | | | Fix overflow in pools and rmm, where size alignment was taking place. Reported by: Matt Lewis <mattlewis@google.com> * CHANGES Add entry for CVE-2009-2412. * memory/unix/apr_pools.c (allocator_alloc, apr_palloc): Check for overflow after aligning size. (apr_pcalloc): Drop aligning of size; clearing what the caller asked for should suffice. * util-misc/apr_rmm.c (apr_rmm_malloc, apr_rmm_calloc, apr_rmm_realloc): Check for overflow after aligning size. Submitted by: Matt Lewis <mattlewis@google.com>, Sander Striker git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@800730 13f79535-47bb-0310-9956-ffa450edef68
* Convert various APU_DECLARE into APR_DECLARE.Bojan Smojver2009-07-166-57/+57
| | | | git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@794523 13f79535-47bb-0310-9956-ffa450edef68
* apr_queue_trypush() doesn't block if the queue is full.Bojan Smojver2009-06-141-3/+3
| | | | | | Patch by Neil Conway <nrc cs.berkeley.edu>. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@784520 13f79535-47bb-0310-9956-ffa450edef68
* Fix race conditions in initialisation of DBD, DBM and DSO.Bojan Smojver2009-06-101-1/+10
| | | | | | For 2.0, this is just a temporary solution, until this is re-engineered. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@783580 13f79535-47bb-0310-9956-ffa450edef68
* APR->APU conversion of DSO buildfoo; rename --disable-util-dso toJoe Orton2009-03-241-1/+1
| | | | | | | | | | | | | | | | | | | | | --disable-modular-dso: * configure.in, Makefile.in: Use APR_DSO_MODULES for set of DSOs to build. * util-misc/apu_dso.c, include/private/apu_internal.h: Use macro APR_HAVE_MODULAR_DSO to determine whether modular DSO build is used. * build/dso.m4 (APR_MODULAR_DSO): Renamed from APU_CHECK_UTIL_DSO. Define APR_HAVE_MODULAR_DSO if modular DSO biuld is used. Add to LIBS not APRUTIL_LIBS. Rename configure flag to --disable-modular-dso to disable modular DSO build. * ldap/*.c, dbm/*.c, dbd/*.c, crypto/*.c: Adjust to use APR_HAVE_MODULAR_DSO. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@757884 13f79535-47bb-0310-9956-ffa450edef68
* * Makefile.in, configure.in: s/APU/APR/ in DSO handling code.Joe Orton2009-03-241-8/+8
| | | | | | | | | Use default install prefix of $libdir/apr-$major/ * util-misc/apu_dso.c: Update likewise. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@757845 13f79535-47bb-0310-9956-ffa450edef68
* Merge APR-Util trunk into APR.Paul Querna2009-03-247-0/+3146
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@757704 13f79535-47bb-0310-9956-ffa450edef68