httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From traw...@apache.org
Subject svn commit: r885868 - in /httpd/mod_fcgid/trunk/modules/fcgid: config.m4 fcgid_mutex.h fcgid_mutex_unix.c fcgid_pm.h fcgid_pm_unix.c fcgid_pm_win.c fcgid_proctbl.h fcgid_proctbl_unix.c fcgid_proctbl_win.c mod_fcgid.c modules.mk.apxs
Date Tue, 01 Dec 2009 19:01:18 GMT
Author: trawick
Date: Tue Dec  1 19:01:17 2009
New Revision: 885868

URL: http://svn.apache.org/viewvc?rev=885868&view=rev
Log:
consolidate apr global_mutex setup

use httpd 2.3.4 mutex creation APIs so that Mutex directive is
respected and can be used for mod_fcgid's mutexes

Added:
    httpd/mod_fcgid/trunk/modules/fcgid/fcgid_mutex.h
    httpd/mod_fcgid/trunk/modules/fcgid/fcgid_mutex_unix.c
Modified:
    httpd/mod_fcgid/trunk/modules/fcgid/config.m4
    httpd/mod_fcgid/trunk/modules/fcgid/fcgid_pm.h
    httpd/mod_fcgid/trunk/modules/fcgid/fcgid_pm_unix.c
    httpd/mod_fcgid/trunk/modules/fcgid/fcgid_pm_win.c
    httpd/mod_fcgid/trunk/modules/fcgid/fcgid_proctbl.h
    httpd/mod_fcgid/trunk/modules/fcgid/fcgid_proctbl_unix.c
    httpd/mod_fcgid/trunk/modules/fcgid/fcgid_proctbl_win.c
    httpd/mod_fcgid/trunk/modules/fcgid/mod_fcgid.c
    httpd/mod_fcgid/trunk/modules/fcgid/modules.mk.apxs

Modified: httpd/mod_fcgid/trunk/modules/fcgid/config.m4
URL: http://svn.apache.org/viewvc/httpd/mod_fcgid/trunk/modules/fcgid/config.m4?rev=885868&r1=885867&r2=885868&view=diff
==============================================================================
--- httpd/mod_fcgid/trunk/modules/fcgid/config.m4 (original)
+++ httpd/mod_fcgid/trunk/modules/fcgid/config.m4 Tue Dec  1 19:01:17 2009
@@ -29,6 +29,7 @@
 fcgid_proc_unix.lo dnl
 fcgid_bucket.lo dnl
 fcgid_filter.lo dnl
+fcgid_mutex_unix.lo dnl
 "
 
 APACHE_MODULE(fcgid, [FastCGI support (mod_fcgid)], $fcigd_objs, , no, [

Added: httpd/mod_fcgid/trunk/modules/fcgid/fcgid_mutex.h
URL: http://svn.apache.org/viewvc/httpd/mod_fcgid/trunk/modules/fcgid/fcgid_mutex.h?rev=885868&view=auto
==============================================================================
--- httpd/mod_fcgid/trunk/modules/fcgid/fcgid_mutex.h (added)
+++ httpd/mod_fcgid/trunk/modules/fcgid/fcgid_mutex.h Tue Dec  1 19:01:17 2009
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+apr_status_t fcgid_mutex_register(const char *mutex_type,
+                                  apr_pool_t *pconf);
+
+apr_status_t fcgid_mutex_create(apr_global_mutex_t **mutex,
+                                const char **lockfile,
+                                const char *mutex_type,
+                                apr_pool_t *pconf,
+                                server_rec *s);

Added: httpd/mod_fcgid/trunk/modules/fcgid/fcgid_mutex_unix.c
URL: http://svn.apache.org/viewvc/httpd/mod_fcgid/trunk/modules/fcgid/fcgid_mutex_unix.c?rev=885868&view=auto
==============================================================================
--- httpd/mod_fcgid/trunk/modules/fcgid/fcgid_mutex_unix.c (added)
+++ httpd/mod_fcgid/trunk/modules/fcgid/fcgid_mutex_unix.c Tue Dec  1 19:01:17 2009
@@ -0,0 +1,103 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdio.h>
+
+#include "apr_global_mutex.h"
+#include "httpd.h"
+#include "ap_mmn.h"
+#include "http_log.h"
+#include "fcgid_mutex.h"
+
+#if AP_MODULE_MAGIC_AT_LEAST(20091119,1)
+
+#include "util_mutex.h"
+
+apr_status_t fcgid_mutex_register(const char *mutex_type,
+                                  apr_pool_t *pconf)
+{
+    return ap_mutex_register(pconf, mutex_type, NULL, APR_LOCK_DEFAULT, 0);
+}
+
+apr_status_t fcgid_mutex_create(apr_global_mutex_t **mutex,
+                                const char **lockfile,
+                                const char *mutex_type,
+                                apr_pool_t *pconf,
+                                server_rec *main_server)
+{
+    apr_status_t rv;
+
+    *lockfile = NULL;
+    rv = ap_global_mutex_create(mutex, mutex_type, NULL, main_server,
+                                pconf, 0);
+    if (rv != APR_SUCCESS) {
+        return rv;
+    }
+
+    *lockfile = apr_global_mutex_lockfile(*mutex);
+    return APR_SUCCESS;
+}
+
+#else
+
+#if AP_NEED_SET_MUTEX_PERMS
+#include "unixd.h"
+#endif
+
+#if MODULE_MAGIC_NUMBER_MAJOR < 20081201
+#define ap_unixd_set_global_mutex_perms unixd_set_global_mutex_perms
+#endif
+
+apr_status_t fcgid_mutex_register(const char *mutex_type,
+                                  apr_pool_t *pconf)
+{
+    return APR_SUCCESS;
+}
+
+apr_status_t fcgid_mutex_create(apr_global_mutex_t **mutex,
+                                const char **lockfilep,
+                                const char *mutex_type,
+                                apr_pool_t *pconf,
+                                server_rec *s)
+{
+    apr_status_t rv;
+    apr_lockmech_e mechanism = APR_LOCK_DEFAULT;
+    char *lockfile;
+
+    lockfile = apr_palloc(pconf, L_tmpnam);
+    tmpnam(lockfile);
+    rv = apr_global_mutex_create(mutex, lockfile, mechanism, pconf);
+    if (rv != APR_SUCCESS) {
+        ap_log_error(APLOG_MARK, APLOG_EMERG, rv, s,
+                     "mod_fcgid: Can't create global %s mutex", mutex_type);
+        return rv;
+    }
+
+#ifdef AP_NEED_SET_MUTEX_PERMS
+    rv = ap_unixd_set_global_mutex_perms(*mutex);
+    if (rv != APR_SUCCESS) {
+        ap_log_error(APLOG_MARK, APLOG_EMERG, rv, s,
+                     "mod_fcgid: Can't set global %s mutex perms", mutex_type);
+        return rv;
+    }
+#endif
+
+    *lockfilep = lockfile;
+    return APR_SUCCESS;
+}
+
+#endif

Modified: httpd/mod_fcgid/trunk/modules/fcgid/fcgid_pm.h
URL: http://svn.apache.org/viewvc/httpd/mod_fcgid/trunk/modules/fcgid/fcgid_pm.h?rev=885868&r1=885867&r2=885868&view=diff
==============================================================================
--- httpd/mod_fcgid/trunk/modules/fcgid/fcgid_pm.h (original)
+++ httpd/mod_fcgid/trunk/modules/fcgid/fcgid_pm.h Tue Dec  1 19:01:17 2009
@@ -47,6 +47,8 @@
 
 apr_status_t procmgr_child_init(server_rec * main_server,
                                 apr_pool_t * pchild);
+apr_status_t procmgr_pre_config(apr_pool_t *p, apr_pool_t *plog,
+                                apr_pool_t *ptemp);
 apr_status_t procmgr_post_config(server_rec * main_server,
                                  apr_pool_t * pconf);
 

Modified: httpd/mod_fcgid/trunk/modules/fcgid/fcgid_pm_unix.c
URL: http://svn.apache.org/viewvc/httpd/mod_fcgid/trunk/modules/fcgid/fcgid_pm_unix.c?rev=885868&r1=885867&r2=885868&view=diff
==============================================================================
--- httpd/mod_fcgid/trunk/modules/fcgid/fcgid_pm_unix.c (original)
+++ httpd/mod_fcgid/trunk/modules/fcgid/fcgid_pm_unix.c Tue Dec  1 19:01:17 2009
@@ -28,6 +28,7 @@
 #include "fcgid_conf.h"
 #include "fcgid_proctbl.h"
 #include "fcgid_spawn_ctl.h"
+#include "fcgid_mutex.h"
 #include <unistd.h>
 
 #if MODULE_MAGIC_NUMBER_MAJOR >= 20090209
@@ -37,7 +38,6 @@
 #if MODULE_MAGIC_NUMBER_MAJOR < 20081201
 #define ap_unixd_config unixd_config
 #define ap_unixd_setup_child unixd_setup_child
-#define ap_unixd_set_global_mutex_perms unixd_set_global_mutex_perms
 #endif
 
 static apr_status_t create_process_manager(server_rec * main_server,
@@ -50,7 +50,8 @@
 static apr_file_t *g_ap_write_pipe = NULL;
 static apr_file_t *g_ap_read_pipe = NULL;
 static apr_global_mutex_t *g_pipelock = NULL;
-char g_pipelock_name[L_tmpnam];
+static const char *g_pipelock_name;
+static const char *g_pipelock_mutex_type = "fcgid-pipe";
 
 static int volatile g_caughtSigTerm = 0;
 static pid_t g_pm_pid;
@@ -301,6 +302,12 @@
     return APR_SUCCESS;
 }
 
+apr_status_t procmgr_pre_config(apr_pool_t *p, apr_pool_t *plog,
+                                apr_pool_t *ptemp)
+{
+    return fcgid_mutex_register(g_pipelock_mutex_type, p);
+}
+
 apr_status_t
 procmgr_post_config(server_rec * main_server, apr_pool_t * configpool)
 {
@@ -364,18 +371,10 @@
     }
 
     /* Create mutex for pipe reading and writing */
-    if ((rv =
-         apr_global_mutex_create(&g_pipelock, tmpnam(g_pipelock_name),
-                                 APR_LOCK_DEFAULT,
-                                 main_server->process->pconf)) !=
-        APR_SUCCESS) {
-        ap_log_error(APLOG_MARK, APLOG_EMERG, rv, main_server,
-                     "mod_fcgid: Can't create global pipe mutex");
-        exit(1);
-    }
-    if ((rv = ap_unixd_set_global_mutex_perms(g_pipelock)) != APR_SUCCESS) {
-        ap_log_error(APLOG_MARK, APLOG_EMERG, rv, main_server,
-                     "mod_fcgid: Can't set global pipe mutex perms");
+    rv = fcgid_mutex_create(&g_pipelock, &g_pipelock_name,
+                            g_pipelock_mutex_type,
+                            main_server->process->pconf, main_server);
+    if (rv != APR_SUCCESS) {
         exit(1);
     }
 

Modified: httpd/mod_fcgid/trunk/modules/fcgid/fcgid_pm_win.c
URL: http://svn.apache.org/viewvc/httpd/mod_fcgid/trunk/modules/fcgid/fcgid_pm_win.c?rev=885868&r1=885867&r2=885868&view=diff
==============================================================================
--- httpd/mod_fcgid/trunk/modules/fcgid/fcgid_pm_win.c (original)
+++ httpd/mod_fcgid/trunk/modules/fcgid/fcgid_pm_win.c Tue Dec  1 19:01:17 2009
@@ -59,6 +59,12 @@
     return NULL;
 }
 
+apr_status_t procmgr_pre_config(apr_pool_t *p, apr_pool_t *plog,
+                                apr_pool_t *ptemp)
+{
+    return APR_SUCCESS;
+}
+
 apr_status_t
 procmgr_post_config(server_rec * main_server, apr_pool_t * pconf)
 {

Modified: httpd/mod_fcgid/trunk/modules/fcgid/fcgid_proctbl.h
URL: http://svn.apache.org/viewvc/httpd/mod_fcgid/trunk/modules/fcgid/fcgid_proctbl.h?rev=885868&r1=885867&r2=885868&view=diff
==============================================================================
--- httpd/mod_fcgid/trunk/modules/fcgid/fcgid_proctbl.h (original)
+++ httpd/mod_fcgid/trunk/modules/fcgid/fcgid_proctbl.h Tue Dec  1 19:01:17 2009
@@ -77,6 +77,8 @@
 
 apr_status_t proctable_child_init(server_rec * main_server,
                                   apr_pool_t * pchild);
+apr_status_t proctable_pre_config(apr_pool_t *p, apr_pool_t *plog,
+                                  apr_pool_t *ptemp);
 apr_status_t proctable_post_config(server_rec * main_server,
                                    apr_pool_t * pconf);
 

Modified: httpd/mod_fcgid/trunk/modules/fcgid/fcgid_proctbl_unix.c
URL: http://svn.apache.org/viewvc/httpd/mod_fcgid/trunk/modules/fcgid/fcgid_proctbl_unix.c?rev=885868&r1=885867&r2=885868&view=diff
==============================================================================
--- httpd/mod_fcgid/trunk/modules/fcgid/fcgid_proctbl_unix.c (original)
+++ httpd/mod_fcgid/trunk/modules/fcgid/fcgid_proctbl_unix.c Tue Dec  1 19:01:17 2009
@@ -21,16 +21,13 @@
 #include "apr_global_mutex.h"
 #include "fcgid_global.h"
 #include "fcgid_conf.h"
-#include "unixd.h"
+#include "fcgid_mutex.h"
 #include <unistd.h>
 
-#if MODULE_MAGIC_NUMBER_MAJOR < 20081201
-#define ap_unixd_set_global_mutex_perms unixd_set_global_mutex_perms
-#endif
-
 static apr_shm_t *g_sharemem = NULL;
 static apr_global_mutex_t *g_sharelock = NULL;
-char g_sharelock_name[L_tmpnam];
+static const char *g_sharelock_name;
+static const char *g_sharelock_mutex_type = "fcgid-proctbl";
 static fcgid_procnode *g_proc_array = NULL; /* Contain all process slot */
 static fcgid_procnode *g_free_list_header = NULL;   /* Attach to no process list */
 static fcgid_procnode *g_busy_list_header = NULL;   /* Attach to a working process list */
@@ -123,6 +120,12 @@
 }
 #endif                          /* APR_MAJOR_VERSION<1 */
 
+apr_status_t proctable_pre_config(apr_pool_t *p, apr_pool_t *plog,
+                                  apr_pool_t *ptemp)
+{
+    return fcgid_mutex_register(g_sharelock_mutex_type, p);
+}
+
 apr_status_t
 proctable_post_config(server_rec * main_server, apr_pool_t * configpool)
 {
@@ -148,18 +151,10 @@
     _global_memory = apr_shm_baseaddr_get(g_sharemem);
 
     /* Create global mutex */
-    if ((rv =
-         apr_global_mutex_create(&g_sharelock, tmpnam(g_sharelock_name),
-                                 APR_LOCK_DEFAULT,
-                                 main_server->process->pconf)) !=
-        APR_SUCCESS) {
-        ap_log_error(APLOG_MARK, APLOG_EMERG, rv, main_server,
-                     "mod_fcgid: Can't create global mutex");
-        exit(1);
-    }
-    if ((rv = ap_unixd_set_global_mutex_perms(g_sharelock)) != APR_SUCCESS) {
-        ap_log_error(APLOG_MARK, APLOG_EMERG, rv, main_server,
-                     "mod_fcgid: Can't set global mutex perms");
+    rv = fcgid_mutex_create(&g_sharelock, &g_sharelock_name,
+                            g_sharelock_mutex_type,
+                            main_server->process->pconf, main_server);
+    if (rv != APR_SUCCESS) {
         exit(1);
     }
 

Modified: httpd/mod_fcgid/trunk/modules/fcgid/fcgid_proctbl_win.c
URL: http://svn.apache.org/viewvc/httpd/mod_fcgid/trunk/modules/fcgid/fcgid_proctbl_win.c?rev=885868&r1=885867&r2=885868&view=diff
==============================================================================
--- httpd/mod_fcgid/trunk/modules/fcgid/fcgid_proctbl_win.c (original)
+++ httpd/mod_fcgid/trunk/modules/fcgid/fcgid_proctbl_win.c Tue Dec  1 19:01:17 2009
@@ -30,6 +30,12 @@
 static fcgid_global_share *g_global_share = NULL;   /* global information */
 static size_t g_table_size = FCGID_PROC_TABLE_SIZE;
 
+apr_status_t proctable_pre_config(apr_pool_t *p, apr_pool_t *plog,
+                                  apr_pool_t *ptemp)
+{
+    return APR_SUCCESS;
+}
+
 apr_status_t
 proctable_post_config(server_rec * main_server, apr_pool_t * pconf)
 {

Modified: httpd/mod_fcgid/trunk/modules/fcgid/mod_fcgid.c
URL: http://svn.apache.org/viewvc/httpd/mod_fcgid/trunk/modules/fcgid/mod_fcgid.c?rev=885868&r1=885867&r2=885868&view=diff
==============================================================================
--- httpd/mod_fcgid/trunk/modules/fcgid/mod_fcgid.c (original)
+++ httpd/mod_fcgid/trunk/modules/fcgid/mod_fcgid.c Tue Dec  1 19:01:17 2009
@@ -953,9 +953,22 @@
 
 static int fcgid_pre_config(apr_pool_t *pconf, apr_pool_t *plog,
                             apr_pool_t *ptemp)
-{                            
+{
+    apr_status_t rv;
+
     APR_OPTIONAL_HOOK(ap, status_hook, fcgid_status_hook, NULL, NULL,
                       APR_HOOK_MIDDLE);
+
+    rv = procmgr_pre_config(pconf, plog, ptemp);
+    if (rv != APR_SUCCESS) {
+        return rv;
+    }
+
+    rv = proctable_pre_config(pconf, plog, ptemp);
+    if (rv != APR_SUCCESS) {
+        return rv;
+    }
+
     return OK;
 } 
 

Modified: httpd/mod_fcgid/trunk/modules/fcgid/modules.mk.apxs
URL: http://svn.apache.org/viewvc/httpd/mod_fcgid/trunk/modules/fcgid/modules.mk.apxs?rev=885868&r1=885867&r2=885868&view=diff
==============================================================================
--- httpd/mod_fcgid/trunk/modules/fcgid/modules.mk.apxs (original)
+++ httpd/mod_fcgid/trunk/modules/fcgid/modules.mk.apxs Tue Dec  1 19:01:17 2009
@@ -16,8 +16,8 @@
 #
 # this is used/needed by the APACHE2 build system
 #
-mod_fcgid.la: mod_fcgid.slo fcgid_bridge.slo fcgid_conf.slo fcgid_pm_main.slo fcgid_protocol.slo
fcgid_spawn_ctl.slo  fcgid_proctbl_unix.slo fcgid_pm_unix.slo fcgid_proc_unix.slo fcgid_bucket.slo
fcgid_filter.slo
-	$(SH_LINK) -rpath $(libexecdir) -module -avoid-version mod_fcgid.lo fcgid_bridge.lo fcgid_conf.lo
fcgid_pm_main.lo fcgid_protocol.lo fcgid_spawn_ctl.lo  fcgid_proctbl_unix.lo fcgid_pm_unix.lo
fcgid_proc_unix.lo fcgid_bucket.lo fcgid_filter.lo
+mod_fcgid.la: mod_fcgid.slo fcgid_bridge.slo fcgid_conf.slo fcgid_pm_main.slo fcgid_protocol.slo
fcgid_spawn_ctl.slo  fcgid_proctbl_unix.slo fcgid_pm_unix.slo fcgid_proc_unix.slo fcgid_bucket.slo
fcgid_filter.slo fcgid_mutex_unix.slo
+	$(SH_LINK) -rpath $(libexecdir) -module -avoid-version mod_fcgid.lo fcgid_bridge.lo fcgid_conf.lo
fcgid_pm_main.lo fcgid_protocol.lo fcgid_spawn_ctl.lo  fcgid_proctbl_unix.lo fcgid_pm_unix.lo
fcgid_proc_unix.lo fcgid_bucket.lo fcgid_filter.lo fcgid_mutex_unix.lo
 DISTCLEAN_TARGETS = modules.mk
 static =
 shared =  mod_fcgid.la



Mime
View raw message