Mailing List Archive

cvs commit: apache/src http_conf_globals.h http_config.c http_core.c http_main.c httpd.h
dgaudet 97/06/28 16:05:17

Modified: src http_conf_globals.h http_config.c http_core.c
http_main.c httpd.h
Log:
Implement a LockFile directive to move the lockfile to a different location.

Submitted by: Jim and Dean

Revision Changes Path
1.11 +1 -0 apache/src/http_conf_globals.h

Index: http_conf_globals.h
===================================================================
RCS file: /export/home/cvs/apache/src/http_conf_globals.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -C3 -r1.10 -r1.11
*** http_conf_globals.h 1997/06/15 19:22:25 1.10
--- http_conf_globals.h 1997/06/28 23:05:13 1.11
***************
*** 74,79 ****
--- 74,80 ----

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*



1.52 +1 -0 apache/src/http_config.c

Index: http_config.c
===================================================================
RCS file: /export/home/cvs/apache/src/http_config.c,v
retrieving revision 1.51
retrieving revision 1.52
diff -C3 -r1.51 -r1.52
*** http_config.c 1997/06/28 22:12:53 1.51
--- http_config.c 1997/06/28 23:05:13 1.52
***************
*** 1040,1045 ****
--- 1040,1046 ----
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;



1.86 +7 -0 apache/src/http_core.c

Index: http_core.c
===================================================================
RCS file: /export/home/cvs/apache/src/http_core.c,v
retrieving revision 1.85
retrieving revision 1.86
diff -C3 -r1.85 -r1.86
*** http_core.c 1997/06/28 20:10:12 1.85
--- http_core.c 1997/06/28 23:05:13 1.86
***************
*** 970,975 ****
--- 970,980 ----
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;
***************
*** 1230,1235 ****
--- 1235,1242 ----
"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" },



1.164 +15 -25 apache/src/http_main.c

Index: http_main.c
===================================================================
RCS file: /export/home/cvs/apache/src/http_main.c,v
retrieving revision 1.163
retrieving revision 1.164
diff -C3 -r1.163 -r1.164
*** http_main.c 1997/06/28 22:39:21 1.163
--- http_main.c 1997/06/28 23:05:14 1.164
***************
*** 154,159 ****
--- 154,160 ----
int excess_requests_per_child;
char *pid_fname;
char *scoreboard_fname;
+ char *lock_fname;
char *server_argv0;
struct in_addr bind_address;
listen_rec *listeners;
***************
*** 201,206 ****
--- 202,218 ----
#endif
#endif /* WIN32 */

+ #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)-1, ".%u", getpid() );
+ buf[sizeof(buf)-1] = 0;
+ 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;
***************
*** 213,220 ****
*/
void
accept_mutex_init(pool *p)
! {
! char lock_fname[256];

lock_it.l_whence = SEEK_SET; /* from current point */
lock_it.l_start = 0; /* -"- */
--- 225,231 ----
*/
void
accept_mutex_init(pool *p)
! {

lock_it.l_whence = SEEK_SET; /* from current point */
lock_it.l_start = 0; /* -"- */
***************
*** 227,245 ****
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);
! }
!
lock_fd = popenf(p, lock_fname, O_CREAT | O_WRONLY | O_EXCL, 0644);
if (lock_fd == -1)
{
--- 238,244 ----
unlock_it.l_type = F_UNLCK; /* set exclusive/write lock */
unlock_it.l_pid = 0; /* pid not actually interesting */

! expand_lock_fname (p);
lock_fd = popenf(p, lock_fname, O_CREAT | O_WRONLY | O_EXCL, 0644);
if (lock_fd == -1)
{
***************
*** 284,300 ****
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);
- }

lock_fd = popenf(p, lock_fname, O_CREAT | O_WRONLY | O_EXCL, 0644);
if (lock_fd == -1)
{
--- 283,290 ----
void
accept_mutex_init(pool *p)
{

+ expand_lock_fname (p);
lock_fd = popenf(p, lock_fname, O_CREAT | O_WRONLY | O_EXCL, 0644);
if (lock_fd == -1)
{



1.117 +1 -0 apache/src/httpd.h

Index: httpd.h
===================================================================
RCS file: /export/home/cvs/apache/src/httpd.h,v
retrieving revision 1.116
retrieving revision 1.117
diff -C3 -r1.116 -r1.117
*** httpd.h 1997/06/28 22:39:22 1.116
--- httpd.h 1997/06/28 23:05:15 1.117
***************
*** 126,131 ****
--- 126,132 ----
#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"