You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Jeff Trawick <tr...@attglobal.net> on 2001/06/26 14:00:12 UTC
[PATCH] AcceptMutex configuration
This just changes prefork, but same basic change can be made to
threaded and perchild.
Any suggested improvements to lingo or logic before I commit?
Does anybody want me to do the following to detect missing mechanisms
when the config file is read?
1) export APR_HAVE_FCNTL_SERIALIZE, APR_HAVE_FLOCK_SERIALIZE, et al
from apr.h
2) change set_accept_lock_mech() to only allow a particular keyword
(e.g., "sysvsem") if the corresponding APR feature (e.g.,
APR_HAVE_SYSVSEM_SERIALIZE) is present
(Actually, I vote for this now that I think about it for a second :))
Index: server/mpm/prefork/prefork.c
===================================================================
RCS file: /home/cvspublic/httpd-2.0/server/mpm/prefork/prefork.c,v
retrieving revision 1.186
diff -u -r1.186 prefork.c
--- server/mpm/prefork/prefork.c 2001/06/26 10:59:16 1.186
+++ server/mpm/prefork/prefork.c 2001/06/26 12:00:50
@@ -138,6 +138,7 @@
static const char *ap_pid_fname=NULL;
static apr_lock_t *accept_lock;
static const char *ap_lock_fname;
+static apr_lockmech_e_np accept_lock_mech = APR_LOCK_DEFAULT;
static int ap_daemons_to_start=0;
static int ap_daemons_min_free=0;
static int ap_daemons_max_free=0;
@@ -274,7 +275,8 @@
apr_status_t rv;
expand_lock_fname(p);
- rv = apr_lock_create(&accept_lock, APR_MUTEX, APR_CROSS_PROCESS, ap_lock_fname, p);
+ rv = apr_lock_create_np(&accept_lock, APR_MUTEX, APR_CROSS_PROCESS,
+ accept_lock_mech, ap_lock_fname, p);
if (rv) {
ap_log_error(APLOG_MARK, APLOG_EMERG, rv, NULL, "couldn't create accept mutex");
exit(APEXIT_INIT);
@@ -1469,6 +1471,35 @@
return NULL;
}
+static const char *set_accept_lock_mech(cmd_parms *cmd, void *dummy, const char *arg)
+{
+ const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
+ if (err != NULL) {
+ return err;
+ }
+
+ if (!strcasecmp(arg, "default")) {
+ accept_lock_mech = APR_LOCK_DEFAULT;
+ }
+ else if (!strcasecmp(arg, "flock")) {
+ accept_lock_mech = APR_LOCK_FLOCK;
+ }
+ else if (!strcasecmp(arg, "fcntl")) {
+ accept_lock_mech = APR_LOCK_FCNTL;
+ }
+ else if (!strcasecmp(arg, "sysvsem")) {
+ accept_lock_mech = APR_LOCK_SYSVSEM;
+ }
+ else if (!strcasecmp(arg, "proc_pthread")) {
+ accept_lock_mech = APR_LOCK_PROC_PTHREAD;
+ }
+ else {
+ return apr_pstrcat(cmd->pool, arg, " is an invalid mutex mechanism",
+ NULL);
+ }
+ return NULL;
+}
+
static const command_rec prefork_cmds[] = {
UNIX_DAEMON_COMMANDS
LISTEN_COMMANDS
@@ -1490,6 +1521,8 @@
"Maximum number of requests a particular child serves before dying."),
AP_INIT_TAKE1("CoreDumpDirectory", set_coredumpdir, NULL, RSRC_CONF,
"The location of the directory Apache changes to before dumping core"),
+AP_INIT_TAKE1("AcceptMutex", set_accept_lock_mech, NULL, RSRC_CONF,
+ "The system mutex implementation to use for the accept mutex"),
{ NULL }
};
--
Jeff Trawick | trawick@attglobal.net | PGP public key at web site:
http://www.geocities.com/SiliconValley/Park/9289/
Born in Roswell... married an alien...
Re: [PATCH] AcceptMutex configuration
Posted by Jeff Trawick <tr...@attglobal.net>.
"Bill Stoddard" <bi...@wstoddard.com> writes:
> > + return apr_pstrcat(cmd->pool, arg, " is an invalid mutex mechanism",
> > + NULL);
>
> Why not return the list of possibly choices?
sure... the list will be built dynamically though so it won't be
pretty :)
--
Jeff Trawick | trawick@attglobal.net | PGP public key at web site:
http://www.geocities.com/SiliconValley/Park/9289/
Born in Roswell... married an alien...
Re: [PATCH] AcceptMutex configuration
Posted by Bill Stoddard <bi...@wstoddard.com>.
> + return apr_pstrcat(cmd->pool, arg, " is an invalid mutex mechanism",
> + NULL);
Why not return the list of possibly choices?
Bill
----- Original Message -----
From: "Jeff Trawick" <tr...@attglobal.net>
To: <ne...@apache.org>
Sent: Tuesday, June 26, 2001 8:00 AM
Subject: [PATCH] AcceptMutex configuration
> This just changes prefork, but same basic change can be made to
> threaded and perchild.
>
> Any suggested improvements to lingo or logic before I commit?
>
> Does anybody want me to do the following to detect missing mechanisms
> when the config file is read?
>
> 1) export APR_HAVE_FCNTL_SERIALIZE, APR_HAVE_FLOCK_SERIALIZE, et al
> from apr.h
>
> 2) change set_accept_lock_mech() to only allow a particular keyword
> (e.g., "sysvsem") if the corresponding APR feature (e.g.,
> APR_HAVE_SYSVSEM_SERIALIZE) is present
>
> (Actually, I vote for this now that I think about it for a second :))
>
> Index: server/mpm/prefork/prefork.c
> ===================================================================
> RCS file: /home/cvspublic/httpd-2.0/server/mpm/prefork/prefork.c,v
> retrieving revision 1.186
> diff -u -r1.186 prefork.c
> --- server/mpm/prefork/prefork.c 2001/06/26 10:59:16 1.186
> +++ server/mpm/prefork/prefork.c 2001/06/26 12:00:50
> @@ -138,6 +138,7 @@
> static const char *ap_pid_fname=NULL;
> static apr_lock_t *accept_lock;
> static const char *ap_lock_fname;
> +static apr_lockmech_e_np accept_lock_mech = APR_LOCK_DEFAULT;
> static int ap_daemons_to_start=0;
> static int ap_daemons_min_free=0;
> static int ap_daemons_max_free=0;
> @@ -274,7 +275,8 @@
> apr_status_t rv;
>
> expand_lock_fname(p);
> - rv = apr_lock_create(&accept_lock, APR_MUTEX, APR_CROSS_PROCESS, ap_lock_fname, p);
> + rv = apr_lock_create_np(&accept_lock, APR_MUTEX, APR_CROSS_PROCESS,
> + accept_lock_mech, ap_lock_fname, p);
> if (rv) {
> ap_log_error(APLOG_MARK, APLOG_EMERG, rv, NULL, "couldn't create accept mutex");
> exit(APEXIT_INIT);
> @@ -1469,6 +1471,35 @@
> return NULL;
> }
>
> +static const char *set_accept_lock_mech(cmd_parms *cmd, void *dummy, const char *arg)
> +{
> + const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
> + if (err != NULL) {
> + return err;
> + }
> +
> + if (!strcasecmp(arg, "default")) {
> + accept_lock_mech = APR_LOCK_DEFAULT;
> + }
> + else if (!strcasecmp(arg, "flock")) {
> + accept_lock_mech = APR_LOCK_FLOCK;
> + }
> + else if (!strcasecmp(arg, "fcntl")) {
> + accept_lock_mech = APR_LOCK_FCNTL;
> + }
> + else if (!strcasecmp(arg, "sysvsem")) {
> + accept_lock_mech = APR_LOCK_SYSVSEM;
> + }
> + else if (!strcasecmp(arg, "proc_pthread")) {
> + accept_lock_mech = APR_LOCK_PROC_PTHREAD;
> + }
> + else {
> + return apr_pstrcat(cmd->pool, arg, " is an invalid mutex mechanism",
> + NULL);
> + }
> + return NULL;
> +}
> +
> static const command_rec prefork_cmds[] = {
> UNIX_DAEMON_COMMANDS
> LISTEN_COMMANDS
> @@ -1490,6 +1521,8 @@
> "Maximum number of requests a particular child serves before dying."),
> AP_INIT_TAKE1("CoreDumpDirectory", set_coredumpdir, NULL, RSRC_CONF,
> "The location of the directory Apache changes to before dumping core"),
> +AP_INIT_TAKE1("AcceptMutex", set_accept_lock_mech, NULL, RSRC_CONF,
> + "The system mutex implementation to use for the accept mutex"),
> { NULL }
> };
>
>
> --
> Jeff Trawick | trawick@attglobal.net | PGP public key at web site:
> http://www.geocities.com/SiliconValley/Park/9289/
> Born in Roswell... married an alien...
>