httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject svn commit: r265506 - in /httpd/httpd/trunk: include/httpd.h modules/generators/mod_cgid.c modules/loggers/mod_log_config.c server/mpm/prefork/prefork.c server/util.c
Date Wed, 31 Aug 2005 15:22:13 GMT
Author: jim
Date: Wed Aug 31 08:22:08 2005
New Revision: 265506

URL: http://svn.apache.org/viewcvs?rev=265506&view=rev
Log:
Add ap_append_pid(); This is performed enough to warrant
a function I think, especially with the fact that
the mapping of getpid() to APR_PID_T_FMT isn't
consistant in some areas. 

Modified:
    httpd/httpd/trunk/include/httpd.h
    httpd/httpd/trunk/modules/generators/mod_cgid.c
    httpd/httpd/trunk/modules/loggers/mod_log_config.c
    httpd/httpd/trunk/server/mpm/prefork/prefork.c
    httpd/httpd/trunk/server/util.c

Modified: httpd/httpd/trunk/include/httpd.h
URL: http://svn.apache.org/viewcvs/httpd/httpd/trunk/include/httpd.h?rev=265506&r1=265505&r2=265506&view=diff
==============================================================================
--- httpd/httpd/trunk/include/httpd.h (original)
+++ httpd/httpd/trunk/include/httpd.h Wed Aug 31 08:22:08 2005
@@ -1681,6 +1681,19 @@
  */
 AP_DECLARE(char *) ap_escape_quotes(apr_pool_t *p, const char *instring);
 
+/**
+ * Given a string, append the PID deliminated by delim.
+ * Usually used to create a pid-appended filepath name
+ * (eg: /a/b/foo -> /a/b/foo.6726). A function, and not
+ * a macro, to avoid unistd.h dependency
+ * @param p The pool to allocate memory from
+ * @param string The string to append the PID to
+ * @param delim The string to use to deliminate the string from the PID
+ * @return A copy of the string with the PID appended 
+ */
+AP_DECLARE(char *) ap_append_pid(apr_pool_t *p, const char *string,
+                                 const char *delim);
+
 /* Misc system hackery */
 /**
  * Given the name of an object in the file system determine if it is a directory

Modified: httpd/httpd/trunk/modules/generators/mod_cgid.c
URL: http://svn.apache.org/viewcvs/httpd/httpd/trunk/modules/generators/mod_cgid.c?rev=265506&r1=265505&r2=265506&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/generators/mod_cgid.c (original)
+++ httpd/httpd/trunk/modules/generators/mod_cgid.c Wed Aug 31 08:22:08 2005
@@ -812,8 +812,7 @@
 static int cgid_pre_config(apr_pool_t *pconf, apr_pool_t *plog,
                            apr_pool_t *ptemp)
 {
-    sockname = apr_psprintf(pconf, "%s.%" APR_PID_T_FMT, DEFAULT_SOCKET, 
-                            getpid());
+    sockname = ap_append_pid(pconf, DEFAULT_SOCKET, ".");
     return OK;
 }
 
@@ -929,7 +928,7 @@
     }
     
     /* Make sure the pid is appended to the sockname */
-    sockname = apr_psprintf(cmd->pool, "%s.%" APR_PID_T_FMT, arg, getpid());
+    sockname = ap_append_pid(cmd->pool, arg, ".");
     sockname = ap_server_root_relative(cmd->pool, sockname); 
 
     if (!sockname) {

Modified: httpd/httpd/trunk/modules/loggers/mod_log_config.c
URL: http://svn.apache.org/viewcvs/httpd/httpd/trunk/modules/loggers/mod_log_config.c?rev=265506&r1=265505&r2=265506&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/loggers/mod_log_config.c (original)
+++ httpd/httpd/trunk/modules/loggers/mod_log_config.c Wed Aug 31 08:22:08 2005
@@ -648,7 +648,7 @@
 static const char *log_pid_tid(request_rec *r, char *a)
 {
     if (*a == '\0' || !strcmp(a, "pid")) {
-        return apr_psprintf(r->pool, "%" APR_PID_T_FMT, getpid());
+        return ap_append_pid(r->pool, "", "");
     }
     else if (!strcmp(a, "tid") || !strcmp(a, "hextid")) {
 #if APR_HAS_THREADS

Modified: httpd/httpd/trunk/server/mpm/prefork/prefork.c
URL: http://svn.apache.org/viewcvs/httpd/httpd/trunk/server/mpm/prefork/prefork.c?rev=265506&r1=265505&r2=265506&view=diff
==============================================================================
--- httpd/httpd/trunk/server/mpm/prefork/prefork.c (original)
+++ httpd/httpd/trunk/server/mpm/prefork/prefork.c Wed Aug 31 08:22:08 2005
@@ -156,16 +156,13 @@
 
     if(dir) {
         apr_status_t res;
-        char buf[512];
+        char *buf = NULL ;
         int len = strlen(sconf->gprof_dir) - 1;
         if(*(dir + len) == '%') {
             dir[len] = '\0';
-            apr_snprintf(buf, sizeof(buf), "%sgprof.%d", dir, (int)getpid());
+            buf = ap_append_pid(pconf, dir, "gprof.");
         }
-        else {
-            buf[0] = '\0';
-        }
-        use_dir = ap_server_root_relative(pconf, buf[0] ? buf : dir);
+        use_dir = ap_server_root_relative(pconf, buf ? buf : dir);
         res = apr_dir_make(use_dir,
                            APR_UREAD | APR_UWRITE | APR_UEXECUTE |
                            APR_GREAD | APR_GEXECUTE |

Modified: httpd/httpd/trunk/server/util.c
URL: http://svn.apache.org/viewcvs/httpd/httpd/trunk/server/util.c?rev=265506&r1=265505&r2=265506&view=diff
==============================================================================
--- httpd/httpd/trunk/server/util.c (original)
+++ httpd/httpd/trunk/server/util.c Wed Aug 31 08:22:08 2005
@@ -2128,3 +2128,17 @@
     *outchr = '\0';
     return outstring;
 }
+
+/*
+ * Given a string, append the PID deliminated by delim.
+ * Usually used to create a pid-appended filepath name
+ * (eg: /a/b/foo -> /a/b/foo.6726). A function, and not
+ * a macro, to avoid unistd.h dependency
+ */
+AP_DECLARE(char *) ap_append_pid(apr_pool_t *p, const char *string,
+                                    const char *delim)
+{
+    return apr_psprintf(p, "%s%s%" APR_PID_T_FMT, string,
+                        delim, getpid());
+
+}



Mime
View raw message