httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jos Backus <j...@cncdsl.com>
Subject Re: Running Apache in the foreground
Date Tue, 15 Jan 2002 19:52:45 GMT
On Mon, Jan 14, 2002 at 11:15:14PM -0800, Justin Erenkrantz wrote:
> As a rule, please don't do style changes in a patch that changes
> functionality.  It makes it too hard to review what you have really
> changed.

Of course, sorry.
> 
> > @@ -1433,9 +1433,8 @@
> >  
> >      debug = ap_exists_config_define("DEBUG");
> >  
> > -    if (debug) {
> > +    if (debug)
> >          no_detach = one_process = 1;
> > -    }
> >      else {
> >          one_process = ap_exists_config_define("ONE_PROCESS");
> >          no_detach = ap_exists_config_define("NO_DETACH");
> 
> This and others like it is a no-no.  The current style is correct
> (brace even if one-line) - we do this to make it easier when
> people add a line to a conditional clause.  (I learned this the
> hard way, too...)

Yeah, I agree. As you can see in the patch below the current source is a bit
inconsistent though. So a style change should add those missing braces. I can
submit a diff ;)

> Please remove any unnecessary style changes and resubmit your patch.
> Thanks.  -- justin

Thanks for the feedback Justin. Here's the cleaned-up patch, let me know if I
missed anything.

Index: server/mpm/beos/beos.c
===================================================================
RCS file: /home/cvspublic/httpd-2.0/server/mpm/beos/beos.c,v
retrieving revision 1.76
diff -u -r1.76 beos.c
--- server/mpm/beos/beos.c	10 Jan 2002 00:27:58 -0000	1.76
+++ server/mpm/beos/beos.c	15 Jan 2002 19:44:29 -0000
@@ -1009,8 +1009,8 @@
     if (restart_num++ == 1) {
         is_graceful = 0;
         
-        if (!one_process && !no_detach)
-	        apr_proc_detach();
+        if (!one_process)
+               apr_proc_detach(no_detach);
 
         server_pid = getpid();
     }
Index: server/mpm/perchild/perchild.c
===================================================================
RCS file: /home/cvspublic/httpd-2.0/server/mpm/perchild/perchild.c,v
retrieving revision 1.98
diff -u -r1.98 perchild.c
--- server/mpm/perchild/perchild.c	10 Jan 2002 00:27:59 -0000	1.98
+++ server/mpm/perchild/perchild.c	15 Jan 2002 19:44:31 -0000
@@ -1445,8 +1445,8 @@
     if (restart_num++ == 1) {
         is_graceful = 0;
 
-        if (!one_process && !no_detach) {
-            apr_proc_detach();
+        if (!one_process) {
+            apr_proc_detach(no_detach);
         }
 
         my_pid = getpid();
Index: server/mpm/prefork/prefork.c
===================================================================
RCS file: /home/cvspublic/httpd-2.0/server/mpm/prefork/prefork.c,v
retrieving revision 1.229
diff -u -r1.229 prefork.c
--- server/mpm/prefork/prefork.c	11 Jan 2002 14:13:23 -0000	1.229
+++ server/mpm/prefork/prefork.c	15 Jan 2002 19:44:32 -0000
@@ -1217,9 +1217,9 @@
     if (restart_num++ == 1) {
 	is_graceful = 0;
 
-	if (!one_process && !no_detach) {
-	    apr_proc_detach();
-	}
+	if (!one_process) {
+	    apr_proc_detach(no_detach);
+        }
 
 	parent_pid = ap_my_pid = getpid();
     }
Index: server/mpm/worker/worker.c
===================================================================
RCS file: /home/cvspublic/httpd-2.0/server/mpm/worker/worker.c,v
retrieving revision 1.60
diff -u -r1.60 worker.c
--- server/mpm/worker/worker.c	11 Jan 2002 08:01:11 -0000	1.60
+++ server/mpm/worker/worker.c	15 Jan 2002 19:44:34 -0000
@@ -1596,8 +1596,8 @@
     if (restart_num++ == 1) {
         is_graceful = 0;
 
-        if (!one_process && !no_detach) {
-            apr_proc_detach();
+        if (!one_process) {
+            apr_proc_detach(no_detach);
         }
         parent_pid = ap_my_pid = getpid();
     }
Index: srclib/apr/include/apr_thread_proc.h
===================================================================
RCS file: /home/cvspublic/apr/include/apr_thread_proc.h,v
retrieving revision 1.78
diff -u -r1.78 apr_thread_proc.h
--- srclib/apr/include/apr_thread_proc.h	27 Dec 2001 17:02:59 -0000	1.78
+++ srclib/apr/include/apr_thread_proc.h	15 Jan 2002 19:44:34 -0000
@@ -552,7 +552,7 @@
 /**
  * Detach the process from the controlling terminal.
  */
-APR_DECLARE(apr_status_t) apr_proc_detach(void);
+APR_DECLARE(apr_status_t) apr_proc_detach(int dont_fork);
 
 #if APR_HAS_OTHER_CHILD
 
Index: srclib/apr/threadproc/netware/proc.c
===================================================================
RCS file: /home/cvspublic/apr/threadproc/netware/proc.c,v
retrieving revision 1.4
diff -u -r1.4 proc.c
--- srclib/apr/threadproc/netware/proc.c	8 Jan 2002 21:00:37 -0000	1.4
+++ srclib/apr/threadproc/netware/proc.c	15 Jan 2002 19:44:35 -0000
@@ -345,13 +345,13 @@
             }
             newargs[i + 2] = NULL;
             if (attr->detached) {
-                apr_proc_detach();
+                apr_proc_detach(0);
             }
             execve(SHELL_PATH, (char * const *) newargs, (char * const *)env);
         }
         else {
             if (attr->detached) {
-                apr_proc_detach();
+                apr_proc_detach(0);
             }
             execve(progname, (char * const *)args, (char * const *)env);
         }
Index: srclib/apr/threadproc/netware/procsup.c
===================================================================
RCS file: /home/cvspublic/apr/threadproc/netware/procsup.c,v
retrieving revision 1.1
diff -u -r1.1 procsup.c
--- srclib/apr/threadproc/netware/procsup.c	2 Aug 2001 20:29:14 -0000	1.1
+++ srclib/apr/threadproc/netware/procsup.c	15 Jan 2002 19:44:35 -0000
@@ -54,7 +54,7 @@
 
 #include "threadproc.h"
 
-apr_status_t apr_proc_detach(void)
+apr_status_t apr_proc_detach(int dont_fork)
 {
 #if 0
     int x;
@@ -64,15 +64,18 @@
 #if !defined(MPE) && !defined(OS2) && !defined(TPF) && !defined(BEOS)
 /* Don't detach for MPE because child processes can't survive the death of
    the parent. */
-    if ((x = fork()) > 0)
-        exit(0);
-    else if (x == -1) {
-        perror("fork");
-        fprintf(stderr, "unable to fork new process\n");
-        exit(1);  /* we can't do anything here, so just exit. */
+    if (!dont_fork) {
+	if ((x = fork()) > 0)
+	    exit(0);
+	else if (x == -1) {
+	    perror("fork");
+	    fprintf(stderr, "unable to fork new process\n");
+	    exit(1);  /* we can't do anything here, so just exit. */
+	}
+    /*    RAISE_SIGSTOP(DETACH);*/
     }
-/*    RAISE_SIGSTOP(DETACH);*/
 #endif
+
 #if APR_HAVE_SETSID
     if ((pgrp = setsid()) == -1) {
         return errno;
Index: srclib/apr/threadproc/os2/proc.c
===================================================================
RCS file: /home/cvspublic/apr/threadproc/os2/proc.c,v
retrieving revision 1.47
diff -u -r1.47 proc.c
--- srclib/apr/threadproc/os2/proc.c	26 Oct 2001 02:31:04 -0000	1.47
+++ srclib/apr/threadproc/os2/proc.c	15 Jan 2002 19:44:36 -0000
@@ -620,7 +620,7 @@
 
 
 
-APR_DECLARE(apr_status_t) apr_proc_detach()
+APR_DECLARE(apr_status_t) apr_proc_detach(int dont_fork)
 {
     return APR_ENOTIMPL;
 }
Index: srclib/apr/threadproc/unix/proc.c
===================================================================
RCS file: /home/cvspublic/apr/threadproc/unix/proc.c,v
retrieving revision 1.53
diff -u -r1.53 proc.c
--- srclib/apr/threadproc/unix/proc.c	11 Nov 2001 05:51:00 -0000	1.53
+++ srclib/apr/threadproc/unix/proc.c	15 Jan 2002 19:44:36 -0000
@@ -362,13 +362,13 @@
             }
             newargs[i + 2] = NULL;
             if (attr->detached) {
-                apr_proc_detach();
+                apr_proc_detach(0);
             }
             execve(SHELL_PATH, (char * const *) newargs, (char * const *)env);
         }
         else {
             if (attr->detached) {
-                apr_proc_detach();
+                apr_proc_detach(0);
             }
             execve(progname, (char * const *)args, (char * const *)env);
         }
Index: srclib/apr/threadproc/unix/procsup.c
===================================================================
RCS file: /home/cvspublic/apr/threadproc/unix/procsup.c,v
retrieving revision 1.33
diff -u -r1.33 procsup.c
--- srclib/apr/threadproc/unix/procsup.c	28 Dec 2001 19:03:48 -0000	1.33
+++ srclib/apr/threadproc/unix/procsup.c	15 Jan 2002 19:44:36 -0000
@@ -54,7 +54,7 @@
 
 #include "threadproc.h"
 
-APR_DECLARE(apr_status_t) apr_proc_detach(void)
+APR_DECLARE(apr_status_t) apr_proc_detach(int dont_fork)
 {
     int x;
     pid_t pgrp;
@@ -63,15 +63,18 @@
 #if !defined(MPE) && !defined(OS2) && !defined(TPF) && !defined(BEOS)
 /* Don't detach for MPE because child processes can't survive the death of
    the parent. */
-    if ((x = fork()) > 0)
-        exit(0);
-    else if (x == -1) {
-        perror("fork");
-        fprintf(stderr, "unable to fork new process\n");
-        exit(1);  /* we can't do anything here, so just exit. */
+    if (!dont_fork) {
+	if ((x = fork()) > 0)
+	    exit(0);
+	else if (x == -1) {
+	    perror("fork");
+	    fprintf(stderr, "unable to fork new process\n");
+	    exit(1);  /* we can't do anything here, so just exit. */
+	}
+	/* RAISE_SIGSTOP(DETACH); */
     }
-/*    RAISE_SIGSTOP(DETACH);*/
 #endif
+
 #ifdef HAVE_SETSID
     if ((pgrp = setsid()) == -1) {
         return errno;
> 
> 

-- 
Jos Backus                 _/  _/_/_/        Santa Clara, CA
                          _/  _/   _/
                         _/  _/_/_/             
                    _/  _/  _/    _/
josb@cncdsl.com     _/_/   _/_/_/            use Std::Disclaimer;

Mime
View raw message