You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Randy Terbush <ra...@zyzzyva.com> on 1997/06/29 00:58:02 UTC
Re: [PATCH] LockFile take 2
+1 on a commit to head. I'l actually try it as soon as it is
commited.
> How's this tweak of Jim's patch?
>
> Dean
>
> Index: http_conf_globals.h
> ===================================================================
> RCS file: /export/home/cvs/apache/src/http_conf_globals.h,v
> retrieving revision 1.10
> diff -c -3 -r1.10 http_conf_globals.h
> *** http_conf_globals.h 1997/06/15 19:22:25 1.10
> --- http_conf_globals.h 1997/06/28 22:50:26
> ***************
> *** 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*
> Index: http_config.c
> ===================================================================
> RCS file: /export/home/cvs/apache/src/http_config.c,v
> retrieving revision 1.51
> diff -c -3 -r1.51 http_config.c
> *** http_config.c 1997/06/28 22:12:53 1.51
> --- http_config.c 1997/06/28 22:50:30
> ***************
> *** 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;
> Index: http_core.c
> ===================================================================
> RCS file: /export/home/cvs/apache/src/http_core.c,v
> retrieving revision 1.85
> diff -c -3 -r1.85 http_core.c
> *** http_core.c 1997/06/28 20:10:12 1.85
> --- http_core.c 1997/06/28 22:50:36
> ***************
> *** 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" },
> Index: http_main.c
> ===================================================================
> RCS file: /export/home/cvs/apache/src/http_main.c,v
> retrieving revision 1.162
> diff -c -3 -r1.162 http_main.c
> *** http_main.c 1997/06/28 22:12:54 1.162
> --- http_main.c 1997/06/28 22:50:43
> ***************
> *** 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)
> {
> Index: httpd.h
> ===================================================================
> RCS file: /export/home/cvs/apache/src/httpd.h,v
> retrieving revision 1.115
> diff -c -3 -r1.115 httpd.h
> *** httpd.h 1997/06/28 21:46:57 1.115
> --- httpd.h 1997/06/28 22:50:46
> ***************
> *** 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"
>
>
>
>
>
Re: [PATCH] LockFile take 2
Posted by Dean Gaudet <dg...@arctic.org>.
Ok committed. Plus the changes to conf.h to enable this under freebsd,
aux and sunos4.
Dean
On Sat, 28 Jun 1997, Randy Terbush wrote:
>
> +1 on a commit to head. I'l actually try it as soon as it is
> commited.
>
>
> > How's this tweak of Jim's patch?
> >
> > Dean