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:16:03 UTC

svn commit: r1897471 - in /apr/apr/branches/1.8.x: ./ include/ threadproc/beos/ threadproc/netware/ threadproc/os2/ threadproc/unix/ threadproc/win32/

Author: ylavic
Date: Tue Jan 25 20:16:03 2022
New Revision: 1897471

URL: http://svn.apache.org/viewvc?rev=1897471&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.


Merge r1897470 from trunk.
Submitted by: ylavic
Reviewed by: ylavic

Modified:
    apr/apr/branches/1.8.x/   (props changed)
    apr/apr/branches/1.8.x/include/apr_thread_proc.h
    apr/apr/branches/1.8.x/threadproc/beos/proc.c
    apr/apr/branches/1.8.x/threadproc/beos/thread.c
    apr/apr/branches/1.8.x/threadproc/netware/proc.c
    apr/apr/branches/1.8.x/threadproc/netware/thread.c
    apr/apr/branches/1.8.x/threadproc/os2/proc.c
    apr/apr/branches/1.8.x/threadproc/os2/thread.c
    apr/apr/branches/1.8.x/threadproc/unix/proc.c
    apr/apr/branches/1.8.x/threadproc/unix/thread.c
    apr/apr/branches/1.8.x/threadproc/win32/thread.c

Propchange: apr/apr/branches/1.8.x/
------------------------------------------------------------------------------
  Merged /apr/apr/trunk:r1897470

Modified: apr/apr/branches/1.8.x/include/apr_thread_proc.h
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.8.x/include/apr_thread_proc.h?rev=1897471&r1=1897470&r2=1897471&view=diff
==============================================================================
--- apr/apr/branches/1.8.x/include/apr_thread_proc.h (original)
+++ apr/apr/branches/1.8.x/include/apr_thread_proc.h Tue Jan 25 20:16:03 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/branches/1.8.x/threadproc/beos/proc.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.8.x/threadproc/beos/proc.c?rev=1897471&r1=1897470&r2=1897471&view=diff
==============================================================================
--- apr/apr/branches/1.8.x/threadproc/beos/proc.c (original)
+++ apr/apr/branches/1.8.x/threadproc/beos/proc.c Tue Jan 25 20:16:03 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/branches/1.8.x/threadproc/beos/thread.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.8.x/threadproc/beos/thread.c?rev=1897471&r1=1897470&r2=1897471&view=diff
==============================================================================
--- apr/apr/branches/1.8.x/threadproc/beos/thread.c (original)
+++ apr/apr/branches/1.8.x/threadproc/beos/thread.c Tue Jan 25 20:16:03 2022
@@ -183,6 +183,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/branches/1.8.x/threadproc/netware/proc.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.8.x/threadproc/netware/proc.c?rev=1897471&r1=1897470&r2=1897471&view=diff
==============================================================================
--- apr/apr/branches/1.8.x/threadproc/netware/proc.c (original)
+++ apr/apr/branches/1.8.x/threadproc/netware/proc.c Tue Jan 25 20:16:03 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/branches/1.8.x/threadproc/netware/thread.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.8.x/threadproc/netware/thread.c?rev=1897471&r1=1897470&r2=1897471&view=diff
==============================================================================
--- apr/apr/branches/1.8.x/threadproc/netware/thread.c (original)
+++ apr/apr/branches/1.8.x/threadproc/netware/thread.c Tue Jan 25 20:16:03 2022
@@ -218,6 +218,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/branches/1.8.x/threadproc/os2/proc.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.8.x/threadproc/os2/proc.c?rev=1897471&r1=1897470&r2=1897471&view=diff
==============================================================================
--- apr/apr/branches/1.8.x/threadproc/os2/proc.c (original)
+++ apr/apr/branches/1.8.x/threadproc/os2/proc.c Tue Jan 25 20:16:03 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/branches/1.8.x/threadproc/os2/thread.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.8.x/threadproc/os2/thread.c?rev=1897471&r1=1897470&r2=1897471&view=diff
==============================================================================
--- apr/apr/branches/1.8.x/threadproc/os2/thread.c (original)
+++ apr/apr/branches/1.8.x/threadproc/os2/thread.c Tue Jan 25 20:16:03 2022
@@ -186,6 +186,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/branches/1.8.x/threadproc/unix/proc.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.8.x/threadproc/unix/proc.c?rev=1897471&r1=1897470&r2=1897471&view=diff
==============================================================================
--- apr/apr/branches/1.8.x/threadproc/unix/proc.c (original)
+++ apr/apr/branches/1.8.x/threadproc/unix/proc.c Tue Jan 25 20:16:03 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 = getpid();
 
         apr_random_after_fork(proc);

Modified: apr/apr/branches/1.8.x/threadproc/unix/thread.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.8.x/threadproc/unix/thread.c?rev=1897471&r1=1897470&r2=1897471&view=diff
==============================================================================
--- apr/apr/branches/1.8.x/threadproc/unix/thread.c (original)
+++ apr/apr/branches/1.8.x/threadproc/unix/thread.c Tue Jan 25 20:16:03 2022
@@ -259,6 +259,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/branches/1.8.x/threadproc/win32/thread.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.8.x/threadproc/win32/thread.c?rev=1897471&r1=1897470&r2=1897471&view=diff
==============================================================================
--- apr/apr/branches/1.8.x/threadproc/win32/thread.c (original)
+++ apr/apr/branches/1.8.x/threadproc/win32/thread.c Tue Jan 25 20:16:03 2022
@@ -209,6 +209,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