You are viewing a plain text version of this content. The canonical link for it is here.
Posted to apache-bugdb@apache.org by Tetsuya Furukawa <te...@secom-sis.co.jp> on 1997/08/26 13:40:03 UTC
general/1056: USE_FLOCK_SERIALIZED_ACCEPT is no use.
>Number: 1056
>Category: general
>Synopsis: USE_FLOCK_SERIALIZED_ACCEPT is no use.
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: apache (Apache HTTP Project)
>State: open
>Class: sw-bug
>Submitter-Id: apache
>Arrival-Date: Tue Aug 26 04:40:02 1997
>Originator: tetsuya@secom-sis.co.jp
>Organization:
apache
>Release: 1.2.1
>Environment:
FreeBSD 2.1.7.1-RELEASE, FreeBSD 2.2-STABLE
>Description:
If USE_FLOCK_SERIALIZED_ACCEPT is defined,
1. First, the parent will create a lock file and get the file descriptor
associated with the file in accept_mutex_init().
2. Then, the children will intend to do flock() on the descriptor
in accept_mutex_on() and accept_mutex_off().
The flock(lock_fd, LOCK_EX) will always success without blocking in the case.
I think it isn't the expected action.
However, it doesn't currently seem to cause any problem on FreeBSD.
>How-To-Repeat:
At the next of the line ``accept_mutex_on();'', insert
``log_printf(server_conf, "accept_mutex_on: %d", (int)getpid());''.
Then make, install and start the Apache on the FreeBSD system.
You'll see the multiple "accept_mutex_on: xxxx" in the error log
even if no client accesses the server.
>Fix:
I made a patch.
It seems to work fine on my system.
--------
--- http_main.c.original Tue Aug 26 20:15:21 1997
+++ http_main.c Tue Aug 26 20:15:12 1997
@@ -271,7 +271,7 @@
fprintf (stderr, "Cannot open lock file\n");
exit (1);
}
- unlink(lock_fname);
+ pclosef(p, lock_fd);
}
void accept_mutex_on()
@@ -1228,6 +1228,9 @@
void sig_term() {
log_error("httpd: caught SIGTERM, shutting down", server_conf);
cleanup_scoreboard();
+#if defined(USE_FLOCK_SERIALIZED_ACCEPT)
+ unlink(lock_fname);
+#endif
ap_killpg (pgrp, SIGKILL);
close(sd);
exit(1);
@@ -1665,6 +1668,16 @@
dupped_csd = -1;
child_num = child_num_arg;
requests_this_child = 0;
+
+#if defined(USE_FLOCK_SERIALIZED_ACCEPT)
+ lock_fd = popenf(pconf, lock_fname, O_WRONLY, 0);
+ if (lock_fd == -1)
+ {
+ perror ("open");
+ fprintf (stderr, "Cannot open lock file\n");
+ exit (1);
+ }
+#endif
reopen_scoreboard(pconf);
(void)update_child_status(child_num, SERVER_READY, (request_rec*)NULL);
-------
>Audit-Trail:
>Unformatted:
Re: general/1056: USE_FLOCK_SERIALIZED_ACCEPT is no use.
Posted by Marc Slemko <ma...@worldgate.com>.
On Thu, 4 Sep 1997, Dean Gaudet wrote:
> I really can't believe this one ... could a freebsd person start up a
> server, then ktrace/truss/whatever a few of the pids and make sure only
> one of them is in accept() ?
Looks fine to me using 1.3-dev code.
Possible they are seeing oddities if they are NFS mounting things.
This is one of the PRs I hope to get around to some day...
>
> Dean
>
> On Tue, 26 Aug 1997, Tetsuya Furukawa wrote:
>
> >
> > >Number: 1056
> > >Category: general
> > >Synopsis: USE_FLOCK_SERIALIZED_ACCEPT is no use.
> > >Confidential: no
> > >Severity: non-critical
> > >Priority: medium
> > >Responsible: apache (Apache HTTP Project)
> > >State: open
> > >Class: sw-bug
> > >Submitter-Id: apache
> > >Arrival-Date: Tue Aug 26 04:40:02 1997
> > >Originator: tetsuya@secom-sis.co.jp
> > >Organization:
> > apache
> > >Release: 1.2.1
> > >Environment:
> > FreeBSD 2.1.7.1-RELEASE, FreeBSD 2.2-STABLE
> > >Description:
> > If USE_FLOCK_SERIALIZED_ACCEPT is defined,
> > 1. First, the parent will create a lock file and get the file descriptor
> > associated with the file in accept_mutex_init().
> > 2. Then, the children will intend to do flock() on the descriptor
> > in accept_mutex_on() and accept_mutex_off().
> >
> > The flock(lock_fd, LOCK_EX) will always success without blocking in the case.
> > I think it isn't the expected action.
> > However, it doesn't currently seem to cause any problem on FreeBSD.
> > >How-To-Repeat:
> > At the next of the line ``accept_mutex_on();'', insert
> > ``log_printf(server_conf, "accept_mutex_on: %d", (int)getpid());''.
> > Then make, install and start the Apache on the FreeBSD system.
> > You'll see the multiple "accept_mutex_on: xxxx" in the error log
> > even if no client accesses the server.
> > >Fix:
> > I made a patch.
> > It seems to work fine on my system.
> > --------
> > --- http_main.c.original Tue Aug 26 20:15:21 1997
> > +++ http_main.c Tue Aug 26 20:15:12 1997
> > @@ -271,7 +271,7 @@
> > fprintf (stderr, "Cannot open lock file\n");
> > exit (1);
> > }
> > - unlink(lock_fname);
> > + pclosef(p, lock_fd);
> > }
> >
> > void accept_mutex_on()
> > @@ -1228,6 +1228,9 @@
> > void sig_term() {
> > log_error("httpd: caught SIGTERM, shutting down", server_conf);
> > cleanup_scoreboard();
> > +#if defined(USE_FLOCK_SERIALIZED_ACCEPT)
> > + unlink(lock_fname);
> > +#endif
> > ap_killpg (pgrp, SIGKILL);
> > close(sd);
> > exit(1);
> > @@ -1665,6 +1668,16 @@
> > dupped_csd = -1;
> > child_num = child_num_arg;
> > requests_this_child = 0;
> > +
> > +#if defined(USE_FLOCK_SERIALIZED_ACCEPT)
> > + lock_fd = popenf(pconf, lock_fname, O_WRONLY, 0);
> > + if (lock_fd == -1)
> > + {
> > + perror ("open");
> > + fprintf (stderr, "Cannot open lock file\n");
> > + exit (1);
> > + }
> > +#endif
> >
> > reopen_scoreboard(pconf);
> > (void)update_child_status(child_num, SERVER_READY, (request_rec*)NULL);
> > -------
> > >Audit-Trail:
> > >Unformatted:
> >
> >
> >
>
Re: general/1056: USE_FLOCK_SERIALIZED_ACCEPT is no use.
Posted by Dean Gaudet <dg...@arctic.org>.
I really can't believe this one ... could a freebsd person start up a
server, then ktrace/truss/whatever a few of the pids and make sure only
one of them is in accept() ?
Dean
On Tue, 26 Aug 1997, Tetsuya Furukawa wrote:
>
> >Number: 1056
> >Category: general
> >Synopsis: USE_FLOCK_SERIALIZED_ACCEPT is no use.
> >Confidential: no
> >Severity: non-critical
> >Priority: medium
> >Responsible: apache (Apache HTTP Project)
> >State: open
> >Class: sw-bug
> >Submitter-Id: apache
> >Arrival-Date: Tue Aug 26 04:40:02 1997
> >Originator: tetsuya@secom-sis.co.jp
> >Organization:
> apache
> >Release: 1.2.1
> >Environment:
> FreeBSD 2.1.7.1-RELEASE, FreeBSD 2.2-STABLE
> >Description:
> If USE_FLOCK_SERIALIZED_ACCEPT is defined,
> 1. First, the parent will create a lock file and get the file descriptor
> associated with the file in accept_mutex_init().
> 2. Then, the children will intend to do flock() on the descriptor
> in accept_mutex_on() and accept_mutex_off().
>
> The flock(lock_fd, LOCK_EX) will always success without blocking in the case.
> I think it isn't the expected action.
> However, it doesn't currently seem to cause any problem on FreeBSD.
> >How-To-Repeat:
> At the next of the line ``accept_mutex_on();'', insert
> ``log_printf(server_conf, "accept_mutex_on: %d", (int)getpid());''.
> Then make, install and start the Apache on the FreeBSD system.
> You'll see the multiple "accept_mutex_on: xxxx" in the error log
> even if no client accesses the server.
> >Fix:
> I made a patch.
> It seems to work fine on my system.
> --------
> --- http_main.c.original Tue Aug 26 20:15:21 1997
> +++ http_main.c Tue Aug 26 20:15:12 1997
> @@ -271,7 +271,7 @@
> fprintf (stderr, "Cannot open lock file\n");
> exit (1);
> }
> - unlink(lock_fname);
> + pclosef(p, lock_fd);
> }
>
> void accept_mutex_on()
> @@ -1228,6 +1228,9 @@
> void sig_term() {
> log_error("httpd: caught SIGTERM, shutting down", server_conf);
> cleanup_scoreboard();
> +#if defined(USE_FLOCK_SERIALIZED_ACCEPT)
> + unlink(lock_fname);
> +#endif
> ap_killpg (pgrp, SIGKILL);
> close(sd);
> exit(1);
> @@ -1665,6 +1668,16 @@
> dupped_csd = -1;
> child_num = child_num_arg;
> requests_this_child = 0;
> +
> +#if defined(USE_FLOCK_SERIALIZED_ACCEPT)
> + lock_fd = popenf(pconf, lock_fname, O_WRONLY, 0);
> + if (lock_fd == -1)
> + {
> + perror ("open");
> + fprintf (stderr, "Cannot open lock file\n");
> + exit (1);
> + }
> +#endif
>
> reopen_scoreboard(pconf);
> (void)update_child_status(child_num, SERVER_READY, (request_rec*)NULL);
> -------
> >Audit-Trail:
> >Unformatted:
>
>
>