summaryrefslogtreecommitdiff
path: root/threadproc/os2
diff options
context:
space:
mode:
authorYann Ylavic <ylavic@apache.org>2022-01-25 20:14:55 +0000
committerYann Ylavic <ylavic@apache.org>2022-01-25 20:14:55 +0000
commit865e0f3805b4f46d77a43bc661fd793dbaaa7ff6 (patch)
tree33c018b578c888228c8b6ed79741c439a25370ed /threadproc/os2
parent05023098b8283a21bf1c5229db6c6c73c6407a0e (diff)
downloadapr-865e0f3805b4f46d77a43bc661fd793dbaaa7ff6.tar.gz
apr_thread: Follow up to r1897207: Provide apr_thread_current_after_fork().
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
Diffstat (limited to 'threadproc/os2')
-rw-r--r--threadproc/os2/proc.c3
-rw-r--r--threadproc/os2/thread.c7
2 files changed, 10 insertions, 0 deletions
diff --git a/threadproc/os2/proc.c b/threadproc/os2/proc.c
index cd7500129..beb100908 100644
--- a/threadproc/os2/proc.c
+++ b/threadproc/os2/proc.c
@@ -227,6 +227,9 @@ APR_DECLARE(apr_status_t) apr_proc_fork(apr_proc_t *proc, apr_pool_t *pool)
return errno;
}
else if (pid == 0) {
+#if AP_HAS_THREAD_LOCAL
+ apr_thread_current_after_fork();
+#endif
proc->pid = pid;
proc->in = NULL;
proc->out = NULL;
diff --git a/threadproc/os2/thread.c b/threadproc/os2/thread.c
index d23be9aed..fc3015088 100644
--- a/threadproc/os2/thread.c
+++ b/threadproc/os2/thread.c
@@ -187,6 +187,13 @@ APR_DECLARE(apr_status_t) apr_thread_current_create(apr_thread_t **current,
return APR_SUCCESS;
}
+APR_DECLARE(void) apr_thread_current_after_fork(void)
+{
+#if APR_HAS_THREAD_LOCAL
+ current_thread = NULL;
+#endif
+}
+
APR_DECLARE(apr_thread_t *) apr_thread_current(void)
{
#if APR_HAS_THREAD_LOCAL