From: dgaudet Date: Sun, 29 Jun 1997 18:08:38 +0000 (+0000) Subject: LockFile directive and USE_FLOCK changes. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=da9d411624bc377e5e9b6f42b1e35d5638ddd16a;p=thirdparty%2Fapache%2Fhttpd.git LockFile directive and USE_FLOCK changes. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/1.3@78446 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/APACHE_1_2_X/src/CHANGES b/APACHE_1_2_X/src/CHANGES index a70e56cf6bc..5d3989ea169 100644 --- a/APACHE_1_2_X/src/CHANGES +++ b/APACHE_1_2_X/src/CHANGES @@ -25,6 +25,10 @@ Changes with Apache 1.2.1 to the rule that symlink permissions are tested with the symlink options of the parent directory. [Dean Gaudet] PR#353 + *) CONFIG: The LockFile directive can be used to place the serializing + lockfile in any location. It previously defaulted to /usr/tmp/htlock. + [Somehow it took three of us: Jim Jaglieski, Dean Gaudet, Marc Slemko] + *) QUERY_STRING was unescaped in mod_include, it shouldn't be. [Dean Gaudet] PR#644 @@ -48,6 +52,9 @@ Changes with Apache 1.2.1 directives. But using -DHIGH_SLACK_LINE=256 described above will work around this problem. [Dean Gaudet] + *) USE_FLOCK_SERIALIZED_ACCEPT is now default for FreeBSD, A/UX, and + SunOS 4. + *) Improved unix error response logging. [Marc Slemko] *) Update mod_rewrite from 3.0.5 to 3.0.6. New ruleflag diff --git a/APACHE_1_2_X/src/include/ap_config.h b/APACHE_1_2_X/src/include/ap_config.h index 423abd9fcd4..1ddc9fdc77b 100644 --- a/APACHE_1_2_X/src/include/ap_config.h +++ b/APACHE_1_2_X/src/include/ap_config.h @@ -89,6 +89,7 @@ char *mktemp(char *template); typedef int rlim_t; #define memmove(a,b,c) bcopy(b,a,c) #define NO_LINGCLOSE +#define USE_FLOCK_SERIALIZED_ACCEPT #elif defined(SOLARIS2) #undef HAVE_GMTOFF @@ -317,16 +318,16 @@ extern char *crypt(); #define NEED_STRDUP #define JMP_BUF sigjmp_buf /* fcntl() locking is expensive with NFS */ -#undef USE_FLOCK_SERIALIZED_ACCEPT +#define USE_FLOCK_SERIALIZED_ACCEPT #define HAVE_SHMGET -#define MOVEBREAK 0x4000000 /* * NOTE: If when you run Apache under A/UX and you get a warning - * that httpd couldn't move break, then the above value for + * that httpd couldn't move break, then the below value for * MOVEBREAK (64megs) is too large for your setup. Try reducing * to 0x2000000 which is still PLENTY of space. I doubt if * even on heavy systems sbrk() would be called at all... */ +#define MOVEBREAK 0x4000000 #define NO_LINGCLOSE #define NO_SLACK @@ -411,6 +412,7 @@ extern char *crypt(); (defined(__FreeBSD_version) && (__FreeBSD_version < 220000)) typedef quad_t rlim_t; #endif +#define USE_FLOCK_SERIALIZED_ACCEPT #elif defined(QNX) #ifndef crypt diff --git a/APACHE_1_2_X/src/include/conf.h b/APACHE_1_2_X/src/include/conf.h index 423abd9fcd4..1ddc9fdc77b 100644 --- a/APACHE_1_2_X/src/include/conf.h +++ b/APACHE_1_2_X/src/include/conf.h @@ -89,6 +89,7 @@ char *mktemp(char *template); typedef int rlim_t; #define memmove(a,b,c) bcopy(b,a,c) #define NO_LINGCLOSE +#define USE_FLOCK_SERIALIZED_ACCEPT #elif defined(SOLARIS2) #undef HAVE_GMTOFF @@ -317,16 +318,16 @@ extern char *crypt(); #define NEED_STRDUP #define JMP_BUF sigjmp_buf /* fcntl() locking is expensive with NFS */ -#undef USE_FLOCK_SERIALIZED_ACCEPT +#define USE_FLOCK_SERIALIZED_ACCEPT #define HAVE_SHMGET -#define MOVEBREAK 0x4000000 /* * NOTE: If when you run Apache under A/UX and you get a warning - * that httpd couldn't move break, then the above value for + * that httpd couldn't move break, then the below value for * MOVEBREAK (64megs) is too large for your setup. Try reducing * to 0x2000000 which is still PLENTY of space. I doubt if * even on heavy systems sbrk() would be called at all... */ +#define MOVEBREAK 0x4000000 #define NO_LINGCLOSE #define NO_SLACK @@ -411,6 +412,7 @@ extern char *crypt(); (defined(__FreeBSD_version) && (__FreeBSD_version < 220000)) typedef quad_t rlim_t; #endif +#define USE_FLOCK_SERIALIZED_ACCEPT #elif defined(QNX) #ifndef crypt diff --git a/APACHE_1_2_X/src/include/http_conf_globals.h b/APACHE_1_2_X/src/include/http_conf_globals.h index 0596ab4460b..3a60e7db77b 100644 --- a/APACHE_1_2_X/src/include/http_conf_globals.h +++ b/APACHE_1_2_X/src/include/http_conf_globals.h @@ -72,6 +72,7 @@ extern int suexec_enabled; extern char *pid_fname; extern char *scoreboard_fname; +extern char *lock_fname; extern char *server_argv0; /* Trying to allocate these in the config pool gets us into some *nasty* diff --git a/APACHE_1_2_X/src/include/httpd.h b/APACHE_1_2_X/src/include/httpd.h index 00e7347f2a4..a8c82c5cd8e 100644 --- a/APACHE_1_2_X/src/include/httpd.h +++ b/APACHE_1_2_X/src/include/httpd.h @@ -126,6 +126,7 @@ #endif #define DEFAULT_PIDLOG "logs/httpd.pid" #define DEFAULT_SCOREBOARD "logs/apache_runtime_status" +#define DEFAULT_LOCKFILE "logs/accept.lock" /* Define this to be what your HTML directory content files are called */ #define DEFAULT_INDEX "index.html" diff --git a/APACHE_1_2_X/src/main/http_config.c b/APACHE_1_2_X/src/main/http_config.c index 9b37b2bdb86..16f2fec02a7 100644 --- a/APACHE_1_2_X/src/main/http_config.c +++ b/APACHE_1_2_X/src/main/http_config.c @@ -1040,6 +1040,7 @@ void init_config_globals (pool *p) daemons_limit = HARD_SERVER_LIMIT; pid_fname = DEFAULT_PIDLOG; scoreboard_fname = DEFAULT_SCOREBOARD; + lock_fname = DEFAULT_LOCKFILE; max_requests_per_child = DEFAULT_MAX_REQUESTS_PER_CHILD; bind_address.s_addr = htonl(INADDR_ANY); listeners = NULL; diff --git a/APACHE_1_2_X/src/main/http_core.c b/APACHE_1_2_X/src/main/http_core.c index f3cf492627a..39a6e6bc8f6 100644 --- a/APACHE_1_2_X/src/main/http_core.c +++ b/APACHE_1_2_X/src/main/http_core.c @@ -967,6 +967,11 @@ const char *set_scoreboard (cmd_parms *cmd, void *dummy, char *arg) { return NULL; } +const char *set_lockfile (cmd_parms *cmd, void *dummy, char *arg) { + lock_fname = pstrdup (cmd->pool, arg); + return NULL; +} + const char *set_idcheck (cmd_parms *cmd, core_dir_config *d, int arg) { d->do_rfc1413 = arg; return NULL; @@ -1216,6 +1221,8 @@ command_rec core_cmds[] = { "A file for logging the server process ID"}, { "ScoreBoardFile", set_scoreboard, NULL, RSRC_CONF, TAKE1, "A file for Apache to maintain runtime process management information"}, +{ "LockFile", set_lockfile, NULL, RSRC_CONF, TAKE1, + "The lockfile used when Apache needs to lock the accept() call"}, { "AccessConfig", set_server_string_slot, (void *)XtOffsetOf (server_rec, access_confname), RSRC_CONF, TAKE1, "The filename of the access config file" }, diff --git a/APACHE_1_2_X/src/main/http_main.c b/APACHE_1_2_X/src/main/http_main.c index 443ebc23647..aa5c41b9b4c 100644 --- a/APACHE_1_2_X/src/main/http_main.c +++ b/APACHE_1_2_X/src/main/http_main.c @@ -138,6 +138,7 @@ gid_t group_id_list[NGROUPS_MAX]; int max_requests_per_child; char *pid_fname; char *scoreboard_fname; +char *lock_fname; char *server_argv0; struct in_addr bind_address; listen_rec *listeners; @@ -181,6 +182,16 @@ int one_process = 0; #define ap_killpg(x, y) (killpg ((x), (y))) #endif +#if defined(USE_FCNTL_SERIALIZED_ACCEPT) || defined(USE_FLOCK_SERIALIZED_ACCEPT) +static void expand_lock_fname(pool *p) +{ + char buf[20]; + + ap_snprintf( buf, sizeof(buf), ".%u", getpid() ); + lock_fname = pstrcat (p, server_root_relative (p, lock_fname), buf, NULL); +} +#endif + #if defined(USE_FCNTL_SERIALIZED_ACCEPT) static struct flock lock_it; static struct flock unlock_it; @@ -193,8 +204,7 @@ static int lock_fd=-1; */ void accept_mutex_init(pool *p) - { - char lock_fname[256]; +{ lock_it.l_whence = SEEK_SET; /* from current point */ lock_it.l_start = 0; /* -"- */ @@ -207,19 +217,7 @@ accept_mutex_init(pool *p) unlock_it.l_type = F_UNLCK; /* set exclusive/write lock */ unlock_it.l_pid = 0; /* pid not actually interesting */ -#ifdef __MACHTEN__ - strncpy(lock_fname, "/var/tmp/htlock.XXXXXX", sizeof(lock_fname)-1); -#else - strncpy(lock_fname, "/usr/tmp/htlock.XXXXXX", sizeof(lock_fname)-1); -#endif - lock_fname[sizeof(lock_fname)-1] = '\0'; - - if (mktemp(lock_fname) == NULL || lock_fname[0] == '\0') - { - fprintf (stderr, "Cannot assign name to lock file!\n"); - exit (1); - } - + expand_lock_fname (p); lock_fd = popenf(p, lock_fname, O_CREAT | O_WRONLY | O_EXCL, 0644); if (lock_fd == -1) { @@ -264,17 +262,8 @@ static int lock_fd=-1; void accept_mutex_init(pool *p) { - char lock_fname[256]; - - strncpy(lock_fname, "/usr/tmp/htlock.XXXXXX", sizeof(lock_fname)-1); - lock_fname[sizeof(lock_fname)-1] = '\0'; - - if (mktemp(lock_fname) == NULL || lock_fname[0] == '\0') - { - fprintf (stderr, "Cannot assign name to lock file!\n"); - exit (1); - } + expand_lock_fname (p); lock_fd = popenf(p, lock_fname, O_CREAT | O_WRONLY | O_EXCL, 0644); if (lock_fd == -1) {