You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Stipe Tolj <to...@wapme-systems.de> on 2002/01/12 23:45:02 UTC
[PATCH] 1.3: changing accept mutex for Cygwin
Attached is a patch that fixes a bug for the accept mutex on the
Cygwin platform. The bug was reported by Sami Tikka
<sa...@welho.com> while trying to use multiple Listen directives.
We change the accept mutex from fcntl to pthread, which works even
with several Listen directives set in httpd.conf.
Here are the changes:
* src/include/ap_config.h: adding HAVE_PTHREAD_SERIALIZED_ACCEPT to
Cygwin block and defaulting to it.
* src/main/http_main.c: exluding pthread_mutexattr_setpshared() call
for Cygwin platform. This calls seems yet not fully functional on this
platform. Forwarding problem to Cygwin core developers.
Stipe
tolj@wapme-systems.de
-------------------------------------------------------------------
Wapme Systems AG
Münsterstr. 248
40470 Düsseldorf
Tel: +49-211-74845-0
Fax: +49-211-74845-299
E-Mail: info@wapme-systems.de
Internet: http://www.wapme-systems.de
-------------------------------------------------------------------
wapme.net - wherever you are
Re: [PATCH] 1.3: changing accept mutex for Cygwin
Posted by Robert Collins <ro...@itdomain.com.au>.
===
----- Original Message -----
From: "Stipe Tolj" <to...@wapme-systems.de>
To: "Jeff Trawick" <tr...@attglobal.net>
Cc: "Robert Collins" <ro...@itdomain.com.au>;
<de...@httpd.apache.org>
> Ok, I'm going to send a new patch in for that.
>
> BTW, Robert, what about the pthread-win32 (native) library that has
> been of some use for Cygwin too. Maybe they have such cross-process
> mutexes included?!
I really can't speak for that project. Certainly they can't have support
for fork() - including pthread_atfork() and related calls. I'd be
surprised if they have cross-process mutex's, but you never know.
Rob
Re: [PATCH] 1.3: changing accept mutex for Cygwin
Posted by Jeff Trawick <tr...@attglobal.net>.
"Robert Collins" <ro...@itdomain.com.au> writes:
> ===
> ----- Original Message -----
> From: "Stipe Tolj" <to...@wapme-systems.de>
>
> > > > manglement aside, I'm -1 without an answer to the question on this
> > > > code which I posted previously...
> > > >
> > > > the answer may simply be
> > > >
> > > > "with Cygwin, all pthread mutexes are cross-process, so there is
> no
> > > > need for such a call"
>
> "With Cygwin, no pthread mutexes are cross-process, so the parameter
> value PTHREAD_PROCESS_SHARED is invalid".
Robert, thanks for the clarification.
Stipe, I think what this means is that we need a patch against HEAD to
change the committed pthread serialization into
HAVE_NONE_SERIALIZED_ACCEPT for Cygwin (if for some reason that works
better than what you had before your latest serialization change).
--
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] 1.3: changing accept mutex for Cygwin
Posted by Robert Collins <ro...@itdomain.com.au>.
===
----- Original Message -----
From: "Stipe Tolj" <to...@wapme-systems.de>
> > > manglement aside, I'm -1 without an answer to the question on this
> > > code which I posted previously...
> > >
> > > the answer may simply be
> > >
> > > "with Cygwin, all pthread mutexes are cross-process, so there is
no
> > > need for such a call"
"With Cygwin, no pthread mutexes are cross-process, so the parameter
value PTHREAD_PROCESS_SHARED is invalid".
I have implemented a proof-of-concept cross-process mutex, but it's not
stable code at this point.
> > 2) not all systems which support pthread mutexes have the support to
> > make them work cross-process; such systems either neglect to
define
> > PTHREAD_PROCESS_SHARED or return an error from
> > pthread_mutexattr_setpshared(,PTHREAD_PROCESS_SHARED)
And this applies to us.
> > 3) Cygwin always returns an error from
> > pthread_mutexattr_setpshared(,PTHREAD_PROCESS_SHARED)
> >
> > 4) it is possible for Apache to appear to work correctly without
> > proper accept serialization
> >
> > My conclusion from these facts/assumptions is that with Stipe's
change
> > he is falling into #4 above. In other words, he isn't getting
working
> > accept serialization. If that is true, I would prefer that for
Cygwin
> > we (Stipe) set whatever is required so that we don't try to do
accept
> > serialization at all, rather than using the pthread mutex support in
a
> > non-working manner.
I'll happily accept contributions to Cygwin to get cross-process mutex's
stable, or I can provide some assistance should Stipe wish to implement
native win32 mutex's for apache/cygwin (which is an ok if-not-preferred
configuration).
Rob
Re: [PATCH] 1.3: changing accept mutex for Cygwin
Posted by Stipe Tolj <to...@wapme-systems.de>.
Jeff Trawick wrote:
>
> Jeff Trawick <tr...@attglobal.net> writes:
>
> > Jim Jagielski <ji...@jaguNET.com> writes:
> >
> > > >diff -ur apache-1.3/src/main/http_main.c apache-1.3-cygwin/src/main/http_main.c
> > > >--- apache-1.3/src/main/http_main.c Wed Oct 17 14:45:30 2001
> > > >+++ apache-1.3-cygwin/src/main/http_main.c Tue Jan 1 16:05:19 2002
> > > >@@ -662,11 +662,17 @@
> > > > perror("pthread_mutexattr_init");
> > > > exit(APEXIT_INIT);
> > > > }
> > > >X-Mozilla-Status: 8009n has problems with this pthread call claiming that these
> > > >+ * are "Invalid arguements", Stipe Tolj <to...@wapme-systems.de>
> > > >+ */
> > > >+#if !defined(CYGWIN)
> > > > if ((errno = pthread_mutexattr_setpshared(&mattr,
> > > > PTHREAD_PROCESS_SHARED))) {
> > > > perror("pthread_mutexattr_setpshared");
> > > > exit(APEXIT_INIT);
> > > > }
> > > >+#endif
> > >
> > > This looks mangled though :) :)
> >
> > manglement aside, I'm -1 without an answer to the question on this
> > code which I posted previously...
> >
> > the answer may simply be
> >
> > "with Cygwin, all pthread mutexes are cross-process, so there is no
> > need for such a call"
> >
> > Since on other systems pthread mutexes are intra-process without
> > such a call, I can't help but wonder.
>
> Let me clarify my concern, in case somebody can find a flaw in my
> logic or in case it helps Stipe know what I would like him to verify
> (and document in comments).
>
> base facts/assumptions:
>
> 1) pthread mutexes are normally intra process, but if the following
> conditions are met, pthread mutexes can be used cross-process
>
> a) the mutex itself lives in shared memory which is addressible by
> the processes which need to serialize via the mutex
>
> b) the pthread_mutexattr_setpshared(,PTHREAD_PROCESS_SHARED) call
> is used to tell the pthreads library that the mutex is
> cross-process
>
> 2) not all systems which support pthread mutexes have the support to
> make them work cross-process; such systems either neglect to define
> PTHREAD_PROCESS_SHARED or return an error from
> pthread_mutexattr_setpshared(,PTHREAD_PROCESS_SHARED)
>
> 3) Cygwin always returns an error from
> pthread_mutexattr_setpshared(,PTHREAD_PROCESS_SHARED)
>
> 4) it is possible for Apache to appear to work correctly without
> proper accept serialization
>
> My conclusion from these facts/assumptions is that with Stipe's change
> he is falling into #4 above. In other words, he isn't getting working
> accept serialization. If that is true, I would prefer that for Cygwin
> we (Stipe) set whatever is required so that we don't try to do accept
> serialization at all, rather than using the pthread mutex support in a
> non-working manner.
>
> I accept that Cygwin may have certain nuances/deviations that result
> in Stipe's code to be appropriate (perhaps on Cygwin all pthread
> mutexes are cross-process and returning an error from
> pthread_mutexattr_setpshared() is Cygwin's way of telling you that the
> call is unnecessary), but I would like to see such nuances spelled out
> in comments adjacent to "#if !defined(CYGWIN)". As it stands, the
> code looks broken.
>
> I suspect that deep knowledge of Cygwin pthread mutex support (i.e.,
> communication with one of the developers or examining the source) is
> necessary to address the concern. If it is unclear why
> pthread_mutexattr_setpshared() returns EINVAL then probably we don't
> have the information to know why skipping that call is appropriate.
yep, I forwarded the issue to Robert Collins
<ro...@itdomain.com.au> which is the one dealing with
Cygwin's pthreads.
Stipe
tolj@wapme-systems.de
-------------------------------------------------------------------
Wapme Systems AG
Münsterstr. 248
40470 Düsseldorf
Tel: +49-211-74845-0
Fax: +49-211-74845-299
E-Mail: info@wapme-systems.de
Internet: http://www.wapme-systems.de
-------------------------------------------------------------------
wapme.net - wherever you are
Re: [PATCH] 1.3: changing accept mutex for Cygwin
Posted by Jeff Trawick <tr...@attglobal.net>.
Jeff Trawick <tr...@attglobal.net> writes:
> Jim Jagielski <ji...@jaguNET.com> writes:
>
> > >diff -ur apache-1.3/src/main/http_main.c apache-1.3-cygwin/src/main/http_main.c
> > >--- apache-1.3/src/main/http_main.c Wed Oct 17 14:45:30 2001
> > >+++ apache-1.3-cygwin/src/main/http_main.c Tue Jan 1 16:05:19 2002
> > >@@ -662,11 +662,17 @@
> > > perror("pthread_mutexattr_init");
> > > exit(APEXIT_INIT);
> > > }
> > >X-Mozilla-Status: 8009n has problems with this pthread call claiming that these
> > >+ * are "Invalid arguements", Stipe Tolj <to...@wapme-systems.de>
> > >+ */
> > >+#if !defined(CYGWIN)
> > > if ((errno = pthread_mutexattr_setpshared(&mattr,
> > > PTHREAD_PROCESS_SHARED))) {
> > > perror("pthread_mutexattr_setpshared");
> > > exit(APEXIT_INIT);
> > > }
> > >+#endif
> >
> > This looks mangled though :) :)
>
> manglement aside, I'm -1 without an answer to the question on this
> code which I posted previously...
>
> the answer may simply be
>
> "with Cygwin, all pthread mutexes are cross-process, so there is no
> need for such a call"
>
> Since on other systems pthread mutexes are intra-process without
> such a call, I can't help but wonder.
Let me clarify my concern, in case somebody can find a flaw in my
logic or in case it helps Stipe know what I would like him to verify
(and document in comments).
base facts/assumptions:
1) pthread mutexes are normally intra process, but if the following
conditions are met, pthread mutexes can be used cross-process
a) the mutex itself lives in shared memory which is addressible by
the processes which need to serialize via the mutex
b) the pthread_mutexattr_setpshared(,PTHREAD_PROCESS_SHARED) call
is used to tell the pthreads library that the mutex is
cross-process
2) not all systems which support pthread mutexes have the support to
make them work cross-process; such systems either neglect to define
PTHREAD_PROCESS_SHARED or return an error from
pthread_mutexattr_setpshared(,PTHREAD_PROCESS_SHARED)
3) Cygwin always returns an error from
pthread_mutexattr_setpshared(,PTHREAD_PROCESS_SHARED)
4) it is possible for Apache to appear to work correctly without
proper accept serialization
My conclusion from these facts/assumptions is that with Stipe's change
he is falling into #4 above. In other words, he isn't getting working
accept serialization. If that is true, I would prefer that for Cygwin
we (Stipe) set whatever is required so that we don't try to do accept
serialization at all, rather than using the pthread mutex support in a
non-working manner.
I accept that Cygwin may have certain nuances/deviations that result
in Stipe's code to be appropriate (perhaps on Cygwin all pthread
mutexes are cross-process and returning an error from
pthread_mutexattr_setpshared() is Cygwin's way of telling you that the
call is unnecessary), but I would like to see such nuances spelled out
in comments adjacent to "#if !defined(CYGWIN)". As it stands, the
code looks broken.
I suspect that deep knowledge of Cygwin pthread mutex support (i.e.,
communication with one of the developers or examining the source) is
necessary to address the concern. If it is unclear why
pthread_mutexattr_setpshared() returns EINVAL then probably we don't
have the information to know why skipping that call is appropriate.
--
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] 1.3: changing accept mutex for Cygwin
Posted by Jeff Trawick <tr...@attglobal.net>.
Jim Jagielski <ji...@jaguNET.com> writes:
> >diff -ur apache-1.3/src/main/http_main.c apache-1.3-cygwin/src/main/http_main.c
> >--- apache-1.3/src/main/http_main.c Wed Oct 17 14:45:30 2001
> >+++ apache-1.3-cygwin/src/main/http_main.c Tue Jan 1 16:05:19 2002
> >@@ -662,11 +662,17 @@
> > perror("pthread_mutexattr_init");
> > exit(APEXIT_INIT);
> > }
> >X-Mozilla-Status: 8009n has problems with this pthread call claiming that these
> >+ * are "Invalid arguements", Stipe Tolj <to...@wapme-systems.de>
> >+ */
> >+#if !defined(CYGWIN)
> > if ((errno = pthread_mutexattr_setpshared(&mattr,
> > PTHREAD_PROCESS_SHARED))) {
> > perror("pthread_mutexattr_setpshared");
> > exit(APEXIT_INIT);
> > }
> >+#endif
>
> This looks mangled though :) :)
manglement aside, I'm -1 without an answer to the question on this
code which I posted previously...
the answer may simply be
"with Cygwin, all pthread mutexes are cross-process, so there is no
need for such a call"
Since on other systems pthread mutexes are intra-process without
such a call, I can't help but wonder.
--
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] 1.3: changing accept mutex for Cygwin
Posted by Jim Jagielski <ji...@jaguNET.com>.
At 11:45 PM +0100 1/12/02, Stipe Tolj wrote:
>diff -ur apache-1.3/src/include/ap_config.h apache-1.3-cygwin/src/include/ap_config.h
>--- apache-1.3/src/include/ap_config.h Tue Oct 9 19:29:46 2001
>+++ apache-1.3-cygwin/src/include/ap_config.h Tue Jan 1 16:07:48 2002
>@@ -1002,7 +1012,11 @@
> #define USE_MMAP_FILES
> #define HAVE_SYSLOG 1
> #define HAVE_FCNTL_SERIALIZED_ACCEPT
>+#define HAVE_PTHREAD_SERIALIZED_ACCEPT
> #define SINGLE_LISTEN_UNSERIALIZED_ACCEPT
>+#if !defined(USE_FNCTL_SERIALIZED_ACCEPT)
>+#define USE_PTHREAD_SERIALIZED_ACCEPT
>+#endif
>
+1 for this
>diff -ur apache-1.3/src/main/http_main.c apache-1.3-cygwin/src/main/http_main.c
>--- apache-1.3/src/main/http_main.c Wed Oct 17 14:45:30 2001
>+++ apache-1.3-cygwin/src/main/http_main.c Tue Jan 1 16:05:19 2002
>@@ -662,11 +662,17 @@
> perror("pthread_mutexattr_init");
> exit(APEXIT_INIT);
> }
>X-Mozilla-Status: 8009n has problems with this pthread call claiming that these
>+ * are "Invalid arguements", Stipe Tolj <to...@wapme-systems.de>
>+ */
>+#if !defined(CYGWIN)
> if ((errno = pthread_mutexattr_setpshared(&mattr,
> PTHREAD_PROCESS_SHARED))) {
> perror("pthread_mutexattr_setpshared");
> exit(APEXIT_INIT);
> }
>+#endif
This looks mangled though :) :)
--
===========================================================================
Jim Jagielski [|] jim@jaguNET.com [|] http://www.jaguNET.com/
"A society that will trade a little liberty for a little order
will lose both and deserve neither"
Re: [PATCH] 1.3: changing accept mutex for Cygwin
Posted by Jeff Trawick <tr...@attglobal.net>.
Stipe Tolj <to...@wapme-systems.de> writes:
> Attached is a patch that fixes a bug for the accept mutex on the
> Cygwin platform. The bug was reported by Sami Tikka
> <sa...@welho.com> while trying to use multiple Listen directives.
>
> We change the accept mutex from fcntl to pthread, which works even
> with several Listen directives set in httpd.conf.
>
> Here are the changes:
>
> * src/include/ap_config.h: adding HAVE_PTHREAD_SERIALIZED_ACCEPT to
> Cygwin block and defaulting to it.
>
> * src/main/http_main.c: exluding pthread_mutexattr_setpshared() call
> for Cygwin platform. This calls seems yet not fully functional on this
> platform. Forwarding problem to Cygwin core developers.
Are you sure you have proper mutexing now? By default, pthread mutexes
are only useful within the current process. Cygwin isn't the only
platform that fails PTHREAD_PROCESS_SHARED. Such a failure is
supposed to mean that the mutexes are only useful within the current
process.
It seems to me that you may not have any effective mutexing (since the
mutex each of your processes tries to grab is not the same mutex
grabbed by other processes since each process has its own local mutex
due to PTHREAD_PROCESS_SHARED failing).
--
Jeff Trawick | trawick@attglobal.net | PGP public key at web site:
http://www.geocities.com/SiliconValley/Park/9289/
Born in Roswell... married an alien...