You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by po...@apache.org on 2010/02/16 21:50:11 UTC

svn commit: r910684 - in /httpd/httpd/trunk: CHANGES include/ap_mmn.h include/http_log.h server/log.c server/mpm/event/event.c server/mpm/netware/mpm_netware.c server/mpm/prefork/prefork.c server/mpm/winnt/mpm_winnt.c server/mpm/worker/worker.c

Author: poirier
Date: Tue Feb 16 20:50:10 2010
New Revision: 910684

URL: http://svn.apache.org/viewvc?rev=910684&view=rev
Log:
Log command line on startup, so there's a record of command line
arguments like -f.  Suggested by Shaya Potter.  [Dan Poirier]
PR: 48752

Modified:
    httpd/httpd/trunk/CHANGES
    httpd/httpd/trunk/include/ap_mmn.h
    httpd/httpd/trunk/include/http_log.h
    httpd/httpd/trunk/server/log.c
    httpd/httpd/trunk/server/mpm/event/event.c
    httpd/httpd/trunk/server/mpm/netware/mpm_netware.c
    httpd/httpd/trunk/server/mpm/prefork/prefork.c
    httpd/httpd/trunk/server/mpm/winnt/mpm_winnt.c
    httpd/httpd/trunk/server/mpm/worker/worker.c

Modified: httpd/httpd/trunk/CHANGES
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/CHANGES?rev=910684&r1=910683&r2=910684&view=diff
==============================================================================
--- httpd/httpd/trunk/CHANGES [utf-8] (original)
+++ httpd/httpd/trunk/CHANGES [utf-8] Tue Feb 16 20:50:10 2010
@@ -2,6 +2,10 @@
 
 Changes with Apache 2.3.7
 
+  *) Log command line on startup, so there's a record of command line
+     arguments like -f.
+     PR 48752.  [Dan Poirier]
+
   *) Introduce mod_reflector, a handler capable of reflecting POSTed
      request bodies back within the response through the output filter
      stack. Can be used to turn an output filter into a web service.

Modified: httpd/httpd/trunk/include/ap_mmn.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/include/ap_mmn.h?rev=910684&r1=910683&r2=910684&view=diff
==============================================================================
--- httpd/httpd/trunk/include/ap_mmn.h (original)
+++ httpd/httpd/trunk/include/ap_mmn.h Tue Feb 16 20:50:10 2010
@@ -216,6 +216,7 @@
  * 20091230.4 (2.3.6-dev)  export ap_process_request_after_handler() for mod_serf
  * 20100208.0 (2.3.6-dev)  ap_socache_provider_t API changes to store and iterate
  * 20100208.1 (2.3.6-dev)  Added forward member to proxy_conn_rec
+ * 20100215.0 (2.3.7-dev)  Added ap_log_command_line().
  *
  */
 

Modified: httpd/httpd/trunk/include/http_log.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/include/http_log.h?rev=910684&r1=910683&r2=910684&view=diff
==============================================================================
--- httpd/httpd/trunk/include/http_log.h (original)
+++ httpd/httpd/trunk/include/http_log.h Tue Feb 16 20:50:10 2010
@@ -250,6 +250,14 @@
 AP_DECLARE(void) ap_error_log2stderr(server_rec *s);
 
 /**
+ * Log the command line used to start the server.
+ * @param p The pool to use for logging
+ * @param s The server_rec whose process's command line we want to log.
+ * The command line is logged to that server's error log.
+ */
+AP_DECLARE(void) ap_log_command_line(apr_pool_t *p, server_rec *s);
+
+/**
  * Log the current pid of the parent process
  * @param p The pool to use for logging
  * @param fname The name of the file to log to

Modified: httpd/httpd/trunk/server/log.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/log.c?rev=910684&r1=910683&r2=910684&view=diff
==============================================================================
--- httpd/httpd/trunk/server/log.c (original)
+++ httpd/httpd/trunk/server/log.c Tue Feb 16 20:50:10 2010
@@ -784,6 +784,33 @@
     va_end(args);
 }
 
+AP_DECLARE(void) ap_log_command_line(apr_pool_t *plog, server_rec *s)
+{
+    int i;
+    process_rec *process = s->process;
+    char *result;
+    int len_needed = 0;
+    
+    /* Piece together the command line from the pieces
+     * in process->argv, with spaces in between.
+     */
+    for (i = 0; i < process->argc; i++) {
+        len_needed += strlen(process->argv[i]) + 1;
+    }
+
+    result = (char *) apr_palloc(plog, len_needed);
+    *result = '\0';
+
+    for (i = 0; i < process->argc; i++) {
+        strcat(result, process->argv[i]);
+        if ((i+1)< process->argc) {
+            strcat(result, " ");
+        }
+    }
+    ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, s,
+                 "Command line: '%s'", result);
+}
+
 AP_DECLARE(void) ap_log_pid(apr_pool_t *p, const char *filename)
 {
     apr_file_t *pid_file = NULL;

Modified: httpd/httpd/trunk/server/mpm/event/event.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm/event/event.c?rev=910684&r1=910683&r2=910684&view=diff
==============================================================================
--- httpd/httpd/trunk/server/mpm/event/event.c (original)
+++ httpd/httpd/trunk/server/mpm/event/event.c Tue Feb 16 20:50:10 2010
@@ -2239,6 +2239,7 @@
                  ap_get_server_description());
     ap_log_error(APLOG_MARK, APLOG_INFO, 0, ap_server_conf,
                  "Server built: %s", ap_get_server_built());
+    ap_log_command_line(plog, s);
 
     restart_pending = shutdown_pending = 0;
     mpm_state = AP_MPMQ_RUNNING;

Modified: httpd/httpd/trunk/server/mpm/netware/mpm_netware.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm/netware/mpm_netware.c?rev=910684&r1=910683&r2=910684&view=diff
==============================================================================
--- httpd/httpd/trunk/server/mpm/netware/mpm_netware.c (original)
+++ httpd/httpd/trunk/server/mpm/netware/mpm_netware.c Tue Feb 16 20:50:10 2010
@@ -922,6 +922,7 @@
             ap_get_server_description());
     ap_log_error(APLOG_MARK, APLOG_INFO, 0, ap_server_conf,
             "Server built: %s", ap_get_server_built());
+    ap_log_command_line(plog, s);
     show_server_data();
 
     mpm_state = AP_MPMQ_RUNNING;

Modified: httpd/httpd/trunk/server/mpm/prefork/prefork.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm/prefork/prefork.c?rev=910684&r1=910683&r2=910684&view=diff
==============================================================================
--- httpd/httpd/trunk/server/mpm/prefork/prefork.c (original)
+++ httpd/httpd/trunk/server/mpm/prefork/prefork.c Tue Feb 16 20:50:10 2010
@@ -971,6 +971,7 @@
                 ap_get_server_description());
     ap_log_error(APLOG_MARK, APLOG_INFO, 0, ap_server_conf,
                 "Server built: %s", ap_get_server_built());
+    ap_log_command_line(plog, s);
     ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, ap_server_conf,
                 "Accept mutex: %s (default: %s)",
                 apr_proc_mutex_name(accept_mutex),

Modified: httpd/httpd/trunk/server/mpm/winnt/mpm_winnt.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm/winnt/mpm_winnt.c?rev=910684&r1=910683&r2=910684&view=diff
==============================================================================
--- httpd/httpd/trunk/server/mpm/winnt/mpm_winnt.c (original)
+++ httpd/httpd/trunk/server/mpm/winnt/mpm_winnt.c Tue Feb 16 20:50:10 2010
@@ -1696,6 +1696,7 @@
                      ap_get_server_description());
         ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, ap_server_conf,
                      "Server built: %s", ap_get_server_built());
+        ap_log_command_line(plog, s);
 
         restart = master_main(ap_server_conf, shutdown_event, restart_event);
 

Modified: httpd/httpd/trunk/server/mpm/worker/worker.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm/worker/worker.c?rev=910684&r1=910683&r2=910684&view=diff
==============================================================================
--- httpd/httpd/trunk/server/mpm/worker/worker.c (original)
+++ httpd/httpd/trunk/server/mpm/worker/worker.c Tue Feb 16 20:50:10 2010
@@ -1758,6 +1758,7 @@
                 ap_get_server_description());
     ap_log_error(APLOG_MARK, APLOG_INFO, 0, ap_server_conf,
                 "Server built: %s", ap_get_server_built());
+    ap_log_command_line(plog, s);
     ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, ap_server_conf,
                 "Accept mutex: %s (default: %s)",
                 apr_proc_mutex_name(accept_mutex),



Re: svn commit: r910684 - in /httpd/httpd/trunk: CHANGES include/ap_mmn.h include/http_log.h server/log.c server/mpm/event/event.c server/mpm/netware/mpm_netware.c server/mpm/prefork/prefork.c server/mpm/winnt/mpm_winnt.c server/mpm/worker/worker.c

Posted by Jeff Trawick <tr...@gmail.com>.
On Tue, Feb 16, 2010 at 5:26 PM, Dan Poirier <po...@pobox.com> wrote:
> On Tue, Feb 16, 2010, at 04:03:33 PM, Jeff Trawick <tr...@gmail.com> wrote:
>
>> FWLIW, sooner or later somebody will want quoting around args with
>> embedded blanks
>> (surprisingly there doesn't seem to be an existing function to do this
>> work)
>
> Maybe something along these lines would be useful?
>
> /**
>  * Concatenate multiple strings specified in a writev-style vector.
>  * The separator between strings is the sep argument, and each string
>  * has the quote argument preceding and following it.
>  *
>  * @param p The pool from which to allocate
>  * @param vec The strings to concatenate
>  * @param nvec The number of strings to concatenate
>  * @param nbytes (output) strlen of new string (pass in NULL to omit)
>  * @param sep String to place between each input string (pass in NULL to omit)
>  * @param quote String to place around each input string (pass in NULL to omit)
>  * @return The new string
>  */
> APR_DECLARE(char *) apr_pstrjoinv(apr_pool_t *a, const struct iovec *vec,
>                                  apr_size_t nvec, apr_size_t *nbytes,
>                                  const char *sep, const char *quote);

That wouldn't work here without moving the argv to vec.  ("shrug" otherwise)

I'd just like to hear someone from the crowd weigh in on whether an
API should be added to log the command line or to retrieve the command
line in a string.

Re: svn commit: r910684 - in /httpd/httpd/trunk: CHANGES include/ap_mmn.h include/http_log.h server/log.c server/mpm/event/event.c server/mpm/netware/mpm_netware.c server/mpm/prefork/prefork.c server/mpm/winnt/mpm_winnt.c server/mpm/worker/worker.c

Posted by Dan Poirier <po...@pobox.com>.
On Tue, Feb 16, 2010, at 04:03:33 PM, Jeff Trawick <tr...@gmail.com> wrote:

> FWLIW, sooner or later somebody will want quoting around args with
> embedded blanks
> (surprisingly there doesn't seem to be an existing function to do this
> work)

Maybe something along these lines would be useful?

/**
 * Concatenate multiple strings specified in a writev-style vector.
 * The separator between strings is the sep argument, and each string
 * has the quote argument preceding and following it.
 *
 * @param p The pool from which to allocate
 * @param vec The strings to concatenate
 * @param nvec The number of strings to concatenate
 * @param nbytes (output) strlen of new string (pass in NULL to omit)
 * @param sep String to place between each input string (pass in NULL to omit)
 * @param quote String to place around each input string (pass in NULL to omit)
 * @return The new string
 */
APR_DECLARE(char *) apr_pstrjoinv(apr_pool_t *a, const struct iovec *vec,
                                  apr_size_t nvec, apr_size_t *nbytes,
                                  const char *sep, const char *quote);


Re: svn commit: r910684 - in /httpd/httpd/trunk: CHANGES include/ap_mmn.h include/http_log.h server/log.c server/mpm/event/event.c server/mpm/netware/mpm_netware.c server/mpm/prefork/prefork.c server/mpm/winnt/mpm_winnt.c server/mpm/worker/worker.c

Posted by Jeff Trawick <tr...@gmail.com>.
On Tue, Feb 16, 2010 at 3:50 PM,  <po...@apache.org> wrote:
> Author: poirier
> Date: Tue Feb 16 20:50:10 2010
> New Revision: 910684
>
> URL: http://svn.apache.org/viewvc?rev=910684&view=rev
> Log:
> Log command line on startup, so there's a record of command line
> arguments like -f.  Suggested by Shaya Potter.  [Dan Poirier]
> PR: 48752
>
> Modified:
>    httpd/httpd/trunk/CHANGES
>    httpd/httpd/trunk/include/ap_mmn.h
>    httpd/httpd/trunk/include/http_log.h
>    httpd/httpd/trunk/server/log.c
>    httpd/httpd/trunk/server/mpm/event/event.c
>    httpd/httpd/trunk/server/mpm/netware/mpm_netware.c
>    httpd/httpd/trunk/server/mpm/prefork/prefork.c
>    httpd/httpd/trunk/server/mpm/winnt/mpm_winnt.c
>    httpd/httpd/trunk/server/mpm/worker/worker.c
>
> Modified: httpd/httpd/trunk/CHANGES
> URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/CHANGES?rev=910684&r1=910683&r2=910684&view=diff
> ==============================================================================
> --- httpd/httpd/trunk/CHANGES [utf-8] (original)
> +++ httpd/httpd/trunk/CHANGES [utf-8] Tue Feb 16 20:50:10 2010
> @@ -2,6 +2,10 @@
>
>  Changes with Apache 2.3.7
>
> +  *) Log command line on startup, so there's a record of command line
> +     arguments like -f.
> +     PR 48752.  [Dan Poirier]
> +
>   *) Introduce mod_reflector, a handler capable of reflecting POSTed
>      request bodies back within the response through the output filter
>      stack. Can be used to turn an output filter into a web service.
>
> Modified: httpd/httpd/trunk/include/ap_mmn.h
> URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/include/ap_mmn.h?rev=910684&r1=910683&r2=910684&view=diff
> ==============================================================================
> --- httpd/httpd/trunk/include/ap_mmn.h (original)
> +++ httpd/httpd/trunk/include/ap_mmn.h Tue Feb 16 20:50:10 2010
> @@ -216,6 +216,7 @@
>  * 20091230.4 (2.3.6-dev)  export ap_process_request_after_handler() for mod_serf
>  * 20100208.0 (2.3.6-dev)  ap_socache_provider_t API changes to store and iterate
>  * 20100208.1 (2.3.6-dev)  Added forward member to proxy_conn_rec
> + * 20100215.0 (2.3.7-dev)  Added ap_log_command_line().

A new API is a minor bump (no module recompile necessary), so the new
number would be "20100208.2".  Also, you forgot to change the number
except in the comment (which is what I usually do).

>  *
>  */
>
>
> Modified: httpd/httpd/trunk/include/http_log.h
> URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/include/http_log.h?rev=910684&r1=910683&r2=910684&view=diff
> ==============================================================================
> --- httpd/httpd/trunk/include/http_log.h (original)
> +++ httpd/httpd/trunk/include/http_log.h Tue Feb 16 20:50:10 2010
> @@ -250,6 +250,14 @@
>  AP_DECLARE(void) ap_error_log2stderr(server_rec *s);
>
>  /**
> + * Log the command line used to start the server.
> + * @param p The pool to use for logging
> + * @param s The server_rec whose process's command line we want to log.
> + * The command line is logged to that server's error log.
> + */
> +AP_DECLARE(void) ap_log_command_line(apr_pool_t *p, server_rec *s);

I think an API to return a string form of the command-line would be
more generally useful (e.g., mod_info could use that to display the
command-line).


> +
> +/**
>  * Log the current pid of the parent process
>  * @param p The pool to use for logging
>  * @param fname The name of the file to log to
>
> Modified: httpd/httpd/trunk/server/log.c
> URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/log.c?rev=910684&r1=910683&r2=910684&view=diff
> ==============================================================================
> --- httpd/httpd/trunk/server/log.c (original)
> +++ httpd/httpd/trunk/server/log.c Tue Feb 16 20:50:10 2010
> @@ -784,6 +784,33 @@
>     va_end(args);
>  }
>
> +AP_DECLARE(void) ap_log_command_line(apr_pool_t *plog, server_rec *s)
> +{
> +    int i;
> +    process_rec *process = s->process;
> +    char *result;
> +    int len_needed = 0;
> +
> +    /* Piece together the command line from the pieces
> +     * in process->argv, with spaces in between.
> +     */
> +    for (i = 0; i < process->argc; i++) {
> +        len_needed += strlen(process->argv[i]) + 1;
> +    }

FWLIW, sooner or later somebody will want quoting around args with
embedded blanks
(surprisingly there doesn't seem to be an existing function to do this work)