| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
| |
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1906943 13f79535-47bb-0310-9956-ffa450edef68
|
|
|
|
|
|
|
|
|
| |
* Introduce apr_thread_name_set() and apr_thread_name_get().
[1] https://bz.apache.org/bugzilla/show_bug.cgi?id=60587
[2] https://lists.apache.org/thread/z24logzc6v8tc0p2q3375cc10qo9y5yw
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1906889 13f79535-47bb-0310-9956-ffa450edef68
|
|
|
|
|
|
|
|
|
| |
* threadproc/win32/proc.c
(apr_proc_create): Close redirect pipes only on success to match pre-r1906885
behavior.
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1906888 13f79535-47bb-0310-9956-ffa450edef68
|
|
|
|
|
|
|
|
|
| |
* threadproc/win32/proc.c
(apr_proc_create): Use apr_wchar_t for pEnvBlock local variable and avoid
unnecessary casts.
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1906887 13f79535-47bb-0310-9956-ffa450edef68
|
|
|
|
| |
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1906886 13f79535-47bb-0310-9956-ffa450edef68
|
|
|
|
|
|
|
|
|
|
|
| |
threads on Windows.
* threadproc/win32/proc.c
(apr_proc_create): Close our side of pipes before releasing lock: otherwise
they could like to other process when apr_proc_create() is used from from
multiple threads.
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1906885 13f79535-47bb-0310-9956-ffa450edef68
|
|
|
|
|
|
|
|
|
|
|
| |
on Windows.
* threadproc/win32/proc.c
(apr_proc_create): Save last error immediately after CreateProcessAsUserW()/
CreateProcessW() call, otherwise it can be lost by later calls.
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1906863 13f79535-47bb-0310-9956-ffa450edef68
|
|
|
|
| |
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1905414 13f79535-47bb-0310-9956-ffa450edef68
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
When creating a thread, this allows to specify the "max_free" of its pool
allocator (i.e. apr_allocator_max_free_set), so that one can create thread
local subpools and have their memory usage regulated on cleanup/destroy.
One could achieve that already with:
apr_allocator_max_free_set(apr_thread_pool_get(thread), max_free);
in the thread startup function, but it's more convenient, simpler and race
free to handle that in the thread attribute itself at creation time.
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1902715 13f79535-47bb-0310-9956-ffa450edef68
|
|
|
|
| |
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1902583 13f79535-47bb-0310-9956-ffa450edef68
|
|
|
|
|
|
|
|
|
|
|
| |
* CHANGES: Add changelog entry.
* threadproc/win32/thread.c
(apr_thread_create): Create suspended thread, initialize apr_thread_t->td
and only after that resume thread.
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1902277 13f79535-47bb-0310-9956-ffa450edef68
|
|
|
|
|
|
|
|
|
| |
* threadproc/win32/thread.c(dummy_worker):
First cast to apr_uinptr_t before conversion pointer to int.
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1902198 13f79535-47bb-0310-9956-ffa450edef68
|
|
|
|
|
|
|
|
|
| |
* threadproc/win32/proc.c(apr_proc_create):
Don't assign const strings to "cmdline".
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1902197 13f79535-47bb-0310-9956-ffa450edef68
|
|
|
|
|
|
|
|
|
|
|
| |
* threadproc/win32/thread.c
(apr_thread_once): Pass NULL as lpContext argument in call to
InitOnceExecuteOnce(). According to documentation pointer stored in lpContext
should be DWORD aligned. We do not use lpContext argument and lpContext is
optional, so just use NULL.
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1902129 13f79535-47bb-0310-9956-ffa450edef68
|
|
|
|
|
|
|
|
| |
(apr_thread_create): Do not cast function pointer...
(dummy_worker): ... cast return value.
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1902077 13f79535-47bb-0310-9956-ffa450edef68
|
|
|
|
|
|
|
| |
(dummy_worker): Use correct calling convention (APR_THREAD_FUNC).
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1902076 13f79535-47bb-0310-9956-ffa450edef68
|
|
|
|
| |
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1902019 13f79535-47bb-0310-9956-ffa450edef68
|
|
|
|
|
|
|
|
|
| |
Fix compilation of apr_thread_current_create() for OS/2 and Windows.
Set *current to NULL on failure.
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1897879 13f79535-47bb-0310-9956-ffa450edef68
|
|
|
|
|
|
|
|
|
|
|
| |
thread_local variables are not (always?) reset on fork(), so APR (and the
user) needs a way to set the current_thread to NULL.
Use apr_thread_current_after_fork() in apr_proc_fork()'s child process.
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1897470 13f79535-47bb-0310-9956-ffa450edef68
|
|
|
|
|
|
|
|
| |
.. rather than a defined().
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1897447 13f79535-47bb-0310-9956-ffa450edef68
|
|
|
|
|
|
|
|
| |
It's not needed, when the thread exits it's not accessible anyway.
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1897445 13f79535-47bb-0310-9956-ffa450edef68
|
|
|
|
| |
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1897419 13f79535-47bb-0310-9956-ffa450edef68
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
All modern compilers provide a Thread Local Storage keyword that allows to
store per-thread data efficiently (C++11 's thread_local, C11's _Thread_local,
gcc/clang's __thread or MSVC's __declspec(thread)).
Use that to have an apr_thread_t pointer associated with each thread created
by apr_thread_create() or any native thread (like the process' initial thread)
that registered itself with the new apr_thread_current_create() function.
This mechanism allows to implement apr_thread_current() quite efficiently, if
available, otherwise the function returns NULL.
If available APR_HAS_THREAD_LOCAL is #define'd to 1 and the APR_THREAD_LOCAL
macro is the keyword usable to register TLS variables natively.
Both APR_HAS_THREAD_LOCAL and APR_THREAD_LOCAL are #undef'ined if the compiler
does not provide the mechanism.
This allows to test for the functionality at compile time.
When APR_HAS_THREAD_LOCAL, the user can load his/her own TLS data with:
apr_thread_data_get(&my_data, my_key, apr_thread_current());
and store them with:
apr_thread_data_set(my_data, my_key, my_data_cleanup,
apr_thread_current());
which can be nice to avoid the proliferation of native TLS keys.
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1897207 13f79535-47bb-0310-9956-ffa450edef68
|
|
|
|
|
|
|
|
|
| |
Make sure apr_thread_join() behaves correctly w.r.t. the returned value
and pool destroy for all archs.
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1897198 13f79535-47bb-0310-9956-ffa450edef68
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
apr_thread_create() was allocating the created apr_thread_t on the given pool,
which caused e.g. short-living threads to leak memory on that pool without a
way to clear it (while some threads are still running).
Change this by allocating the apr_thread_t on the thread's pool itself, which
is safe in the implementations of all archs because none uses the apr_thread_t
after the thread exits, and it's safe for the users provided they don't use the
apr_thread_t for detached threads or for attached threads after the call to
apr_thread_join(). These are hardly new requirements though.
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1897197 13f79535-47bb-0310-9956-ffa450edef68
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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 :)
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1897179 13f79535-47bb-0310-9956-ffa450edef68
|
|
|
|
| |
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1895508 13f79535-47bb-0310-9956-ffa450edef68
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1884078 13f79535-47bb-0310-9956-ffa450edef68
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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().
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1884077 13f79535-47bb-0310-9956-ffa450edef68
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
are now utf-8, utf-16, and utf-32, so we rename;
apr_conv_utf8_to_ucs2 -> apr_conv_utf8_to_utf16
apr_conv_ucs2_to_utf8 -> apr_conv_utf16_to_utf8
This patch notices an error message printing of an
internal password, which will no longer be echoed
to the error stream.
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@1869127 13f79535-47bb-0310-9956-ffa450edef68
|
|
|
|
|
|
|
| |
(apr_thread_yield): Remove Windows CE and Win9x compatibility code.
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@1868774 13f79535-47bb-0310-9956-ffa450edef68
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
on Windows.
* CMakeLists.txt
(single_source_programs): Add test/echoargs.c.
* test/echoargs.c: New test app for test_proc_args test.
* test/testproc.c
(test_proc_args): New test.
(testproc): Add test_proc_args to test list.
* threadproc/win32/proc.c
(quote_arg): New. Helper for apr_proc_create().
(apr_proc_create): Use quote_arg() helper to escape arguments in command
line.
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@1868477 13f79535-47bb-0310-9956-ffa450edef68
|
|
|
|
|
|
|
|
|
| |
* threadproc/win32/proc.c
(apr_proc_create): Do not share code to build CMDLINE in different situations.
SHELLCMD, .bat and regular executables have different rules for cmdline
escaping.
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@1868469 13f79535-47bb-0310-9956-ffa450edef68
|
|
|
|
|
|
| |
(apr_proc_create): Remove Windows 98 compatibility code.
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@1866714 13f79535-47bb-0310-9956-ffa450edef68
|
|
|
|
|
|
|
| |
(apr_proc_create): Remove compatibility code for command.com which is only
available on Windows 98 and bellow.
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@1866713 13f79535-47bb-0310-9956-ffa450edef68
|
|
|
|
| |
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@1862856 13f79535-47bb-0310-9956-ffa450edef68
|
|
|
|
|
|
|
|
|
|
|
|
| |
no useful (nor documented) semantic:
* include/apr_thread_proc.h (apr_thread_exit): Make void function;
mark with gcc noreturn attribute.
* threadproc/*/thread.c (apr_thread_exit): Update accordingly.
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@1862446 13f79535-47bb-0310-9956-ffa450edef68
|
|
|
|
|
|
|
|
|
|
|
| |
Windows.
This also fixes problem that apr_thread_once() may return before the other
read completes initialization on Windows.
[1] https://docs.microsoft.com/en-gb/windows/desktop/Sync/one-time-initialization
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@1859517 13f79535-47bb-0310-9956-ffa450edef68
|
|
|
|
|
|
|
|
| |
* threadproc/win32/threadpriv.c
(apr_threadkey_private_create): Use TLS_OUT_OF_INDEXES instead of hardcoded
0xFFFFFFFF.
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@1859171 13f79535-47bb-0310-9956-ffa450edef68
|
|
|
|
|
|
|
|
| |
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/trunk@1854123 13f79535-47bb-0310-9956-ffa450edef68
|
|
|
|
|
|
|
|
|
|
|
|
| |
Make cprng_stream_ctx_bytes() rekey in any case, this is exactly what we need
both when generating pooled random bytes and when handling fork() the parent
and child key should not leak to each other.
There is no use case for a keystream without setting the key first and burning
it afterward, and there shouldn't be.
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@1834600 13f79535-47bb-0310-9956-ffa450edef68
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Rework apr_crypto_prng_after_fork() which now handles rekeying of all the
CPRNGs created within apr_crypto, by maintaining them in a global APR_RING,
with the notable exception of per-thread ones (never forked).
For each maintained CPRNG, apr_crypto_prng_after_fork() will now first rekey
both the parent and child processes (determined by the 'in_child' argument
provided by the caller), and for the parent only rekey a second time so that
the initial states finally differ for both processes. Once these new keys are
committed to their respective CPRNGs, thanks to and in continuity with the
forward secrecy construct of apr_crypto_prng, there will be no in memory key
material or stream that one process can inherit or infer from the other.
The user can also rekey a CPRNG explicitely by calling the new function
apr_crypto_prng_rekey(), and this is done by apr_fork() implicitely before
forking any child, thus for the parent process. This safe guard ensures both
the clearing of the pooled random bytes (buffered keystream) and the renewal
of key material (cheap and preventive against _atfork() handlers or alike).
Rekeying is done by using each CPRNG's keystream directly, there isn't anymore
the use of a PID (or SHA256 thereof) for children processes nor any extra reads
from the system RNG. All the apr_crypto_prng API is now self contained and can
work entirely with a single stream cipher as primitive (Chacha20 or AES256-CTR,
in that order of availability) and the initial entropy of 32 bytes gathered
from the system. IOW, there is only one call issued to the system RNG for the
global CPRNG's initial key, and if more CPRNGs are created their own initial
key is produced by the global CPRNG.
The KAT arrays in the tests suite needed adjustment too because the initial
seed (if provided, like the zeros-input for the KAT) is no more used directly
as the first key. Instead the first 32 bytes of the keystream generated from
the seed are, and the seed (like any just used key) is then cleared immediatly
from internal memory.
Finally some private APR_CRYPTO_PRNG_* macros (in .c file only) are renamed to
CPRNG_* to shorten colomns and avoid multilines in several cases.
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@1834551 13f79535-47bb-0310-9956-ffa450edef68
|
|
|
|
| |
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@1833382 13f79535-47bb-0310-9956-ffa450edef68
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
New apr_crypto_prng API and apr_crypto[_thread]_random_bytes() functions.
Allows to generate cryptographically secure random bytes indefinitely
given an initial seed of APR_CRYPTO_PRNG_SEED_SIZE bytes (32), which
is either provided by the caller or automatically gathered from the system.
The CPRNG can also be re-seeded at any time, or after a process is fork()ed.
The internal key is renewed every APR_CRYPTO_PRNG_SEED_SIZE random
bytes produced and those data once returned to the caller are cleared from
the internal state, which ensures forward secrecy.
This CPRNG is fast, based on a stream cipher, and will never block besides
the initial seed or any reseed if it depends on the system entropy.
Finally, it can be used either globally (locked in multithread environment),
per-thread (a lock free instance is automatically created for each thread on
first use), or created as standalone instance (manageable independently).
For now it's only implemented with the OpenSSL library as underlying crypto,
that is --with-crypto --with-openssl needs to be configured, and the latter
links libcrypto with APR.
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@1833359 13f79535-47bb-0310-9956-ffa450edef68
|
|
|
|
|
|
| |
save a few cycles.
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@1710307 13f79535-47bb-0310-9956-ffa450edef68
|
|
|
|
| |
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@1611050 13f79535-47bb-0310-9956-ffa450edef68
|
|
|
|
| |
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@1611046 13f79535-47bb-0310-9956-ffa450edef68
|
|
|
|
| |
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@1559343 13f79535-47bb-0310-9956-ffa450edef68
|
|
|
|
|
|
|
|
| |
platform independent macro instead of pthread
define.
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@1481265 13f79535-47bb-0310-9956-ffa450edef68
|
|
|
|
| |
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@1481262 13f79535-47bb-0310-9956-ffa450edef68
|