You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by yl...@apache.org on 2022/01/25 20:14:55 UTC
svn commit: r1897470 - in /apr/apr/trunk: include/ threadproc/beos/ threadproc/netware/ threadproc/os2/ threadproc/unix/ threadproc/win32/
Author: ylavic
Date: Tue Jan 25 20:14:55 2022
New Revision: 1897470
URL: http://svn.apache.org/viewvc?rev=1897470&view=rev
Log:
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.
Modified:
apr/apr/trunk/include/apr_thread_proc.h
apr/apr/trunk/threadproc/beos/proc.c
apr/apr/trunk/threadproc/beos/thread.c
apr/apr/trunk/threadproc/netware/proc.c
apr/apr/trunk/threadproc/netware/thread.c
apr/apr/trunk/threadproc/os2/proc.c
apr/apr/trunk/threadproc/os2/thread.c
apr/apr/trunk/threadproc/unix/proc.c
apr/apr/trunk/threadproc/unix/thread.c
apr/apr/trunk/threadproc/win32/thread.c
Modified: apr/apr/trunk/include/apr_thread_proc.h
URL: http://svn.apache.org/viewvc/apr/apr/trunk/include/apr_thread_proc.h?rev=1897470&r1=1897469&r2=1897470&view=diff
==============================================================================
--- apr/apr/trunk/include/apr_thread_proc.h (original)
+++ apr/apr/trunk/include/apr_thread_proc.h Tue Jan 25 20:14:55 2022
@@ -289,7 +289,7 @@ APR_DECLARE(apr_status_t) apr_thread_cre
void *data, apr_pool_t *cont);
/**
- * Setup the current os_thread as an apr_thread
+ * Setup the current native thread as an apr_thread
* @param current The current apr_thread set up (or reused)
* @param attr The threadattr associated with the current thread
* @param pool The parent pool of the current thread
@@ -299,6 +299,12 @@ APR_DECLARE(apr_status_t) apr_thread_cre
APR_DECLARE(apr_status_t) apr_thread_current_create(apr_thread_t **current,
apr_threadattr_t *attr,
apr_pool_t *pool);
+
+/**
+ * Clear the current thread after fork()
+ */
+APR_DECLARE(void) apr_thread_current_after_fork(void);
+
/**
* Get the current thread
* @param The current apr_thread, NULL if it is not an apr_thread or if
Modified: apr/apr/trunk/threadproc/beos/proc.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/threadproc/beos/proc.c?rev=1897470&r1=1897469&r2=1897470&view=diff
==============================================================================
--- apr/apr/trunk/threadproc/beos/proc.c (original)
+++ apr/apr/trunk/threadproc/beos/proc.c Tue Jan 25 20:14:55 2022
@@ -170,6 +170,9 @@ APR_DECLARE(apr_status_t) apr_proc_fork(
}
}
+#if AP_HAS_THREAD_LOCAL
+ apr_thread_current_after_fork();
+#endif
proc->pid = pid;
proc->in = NULL;
proc->out = NULL;
Modified: apr/apr/trunk/threadproc/beos/thread.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/threadproc/beos/thread.c?rev=1897470&r1=1897469&r2=1897470&view=diff
==============================================================================
--- apr/apr/trunk/threadproc/beos/thread.c (original)
+++ apr/apr/trunk/threadproc/beos/thread.c Tue Jan 25 20:14:55 2022
@@ -184,6 +184,13 @@ APR_DECLARE(apr_status_t) apr_thread_cur
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
Modified: apr/apr/trunk/threadproc/netware/proc.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/threadproc/netware/proc.c?rev=1897470&r1=1897469&r2=1897470&view=diff
==============================================================================
--- apr/apr/trunk/threadproc/netware/proc.c (original)
+++ apr/apr/trunk/threadproc/netware/proc.c Tue Jan 25 20:14:55 2022
@@ -226,6 +226,9 @@ APR_DECLARE(apr_status_t) apr_proc_fork(
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;
Modified: apr/apr/trunk/threadproc/netware/thread.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/threadproc/netware/thread.c?rev=1897470&r1=1897469&r2=1897470&view=diff
==============================================================================
--- apr/apr/trunk/threadproc/netware/thread.c (original)
+++ apr/apr/trunk/threadproc/netware/thread.c Tue Jan 25 20:14:55 2022
@@ -219,6 +219,13 @@ APR_DECLARE(apr_status_t) apr_thread_cur
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
Modified: apr/apr/trunk/threadproc/os2/proc.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/threadproc/os2/proc.c?rev=1897470&r1=1897469&r2=1897470&view=diff
==============================================================================
--- apr/apr/trunk/threadproc/os2/proc.c (original)
+++ apr/apr/trunk/threadproc/os2/proc.c Tue Jan 25 20:14:55 2022
@@ -227,6 +227,9 @@ APR_DECLARE(apr_status_t) apr_proc_fork(
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;
Modified: apr/apr/trunk/threadproc/os2/thread.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/threadproc/os2/thread.c?rev=1897470&r1=1897469&r2=1897470&view=diff
==============================================================================
--- apr/apr/trunk/threadproc/os2/thread.c (original)
+++ apr/apr/trunk/threadproc/os2/thread.c Tue Jan 25 20:14:55 2022
@@ -187,6 +187,13 @@ APR_DECLARE(apr_status_t) apr_thread_cur
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
Modified: apr/apr/trunk/threadproc/unix/proc.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/threadproc/unix/proc.c?rev=1897470&r1=1897469&r2=1897470&view=diff
==============================================================================
--- apr/apr/trunk/threadproc/unix/proc.c (original)
+++ apr/apr/trunk/threadproc/unix/proc.c Tue Jan 25 20:14:55 2022
@@ -234,6 +234,9 @@ APR_DECLARE(apr_status_t) apr_proc_fork(
return errno;
}
else if (pid == 0) {
+#if AP_HAS_THREAD_LOCAL
+ apr_thread_current_after_fork();
+#endif
proc->pid = getpid();
/* Do the work needed for children PRNG(s). */
Modified: apr/apr/trunk/threadproc/unix/thread.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/threadproc/unix/thread.c?rev=1897470&r1=1897469&r2=1897470&view=diff
==============================================================================
--- apr/apr/trunk/threadproc/unix/thread.c (original)
+++ apr/apr/trunk/threadproc/unix/thread.c Tue Jan 25 20:14:55 2022
@@ -260,6 +260,13 @@ APR_DECLARE(apr_status_t) apr_thread_cur
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
Modified: apr/apr/trunk/threadproc/win32/thread.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/threadproc/win32/thread.c?rev=1897470&r1=1897469&r2=1897470&view=diff
==============================================================================
--- apr/apr/trunk/threadproc/win32/thread.c (original)
+++ apr/apr/trunk/threadproc/win32/thread.c Tue Jan 25 20:14:55 2022
@@ -199,6 +199,13 @@ APR_DECLARE(apr_status_t) apr_thread_cur
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