From dev-return-13727-apmail-apr-dev-archive=apr.apache.org@apr.apache.org Mon Jan 31 17:12:34 2005 Return-Path: Delivered-To: apmail-apr-dev-archive@www.apache.org Received: (qmail 49336 invoked from network); 31 Jan 2005 17:12:34 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 31 Jan 2005 17:12:34 -0000 Received: (qmail 93016 invoked by uid 500); 31 Jan 2005 17:12:33 -0000 Delivered-To: apmail-apr-dev-archive@apr.apache.org Received: (qmail 92972 invoked by uid 500); 31 Jan 2005 17:12:32 -0000 Mailing-List: contact dev-help@apr.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Delivered-To: mailing list dev@apr.apache.org Received: (qmail 92958 invoked by uid 99); 31 Jan 2005 17:12:32 -0000 X-ASF-Spam-Status: No, hits=1.0 required=10.0 tests=SPF_HELO_SOFTFAIL X-Spam-Check-By: apache.org Received-SPF: pass (hermes.apache.org: local policy) Received: from kilimandjaro.dyndns.org (HELO kilimandjaro.dyndns.org) (212.85.147.17) by apache.org (qpsmtpd/0.28) with ESMTP; Mon, 31 Jan 2005 09:12:29 -0800 Received: by kilimandjaro.dyndns.org (Postfix, from userid 500) id 01B60BE859; Mon, 31 Jan 2005 18:12:25 +0100 (CET) Received: from saperlipopette ([127.0.0.1] helo=kilimandjaro.dyndns.org) by saperlipopette with esmtp (Exim 4.22) id 1Cvf8W-0002l2-A8 for dev@apr.apache.org; Mon, 31 Jan 2005 18:14:52 +0100 Message-ID: <41FE678B.3050108@kilimandjaro.dyndns.org> Date: Mon, 31 Jan 2005 18:14:51 +0100 From: Dominique Quatravaux User-Agent: Mozilla Thunderbird 0.4 (X11/20040306) X-Accept-Language: fr, en MIME-Version: 1.0 To: dev@apr.apache.org Subject: [PATCH] APR should prefer mmap() to shmat() whenever possible X-Enigmail-Version: 0.83.2.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: multipart/mixed; boundary="------------000006060704000707090500" X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N This is a multi-part message in MIME format. --------------000006060704000707090500 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Dear APR developers, Like a couple of random folks on the great Internet (http://www.google.fr/search?hl=fr&q=%22name-based+shared+memory+failure%22), I've been unsuccessfully trying to use a ScoreBoardFile with Apache 2.0.52 under Linux (Debian testing). Symptoms are: * your usual SysV IPC leakage, which prevents me from restarting the server (I *did* shutdown Apache with care and SIGTERM); * the ScoreBoard does not actually contain a scoreboard, only what looks like a rendez-vous into the allocated SysV shared memory segment. (I would love to be able to parse the scoreboard file from Perl as I did with Apache 1.3, without resorting to some weirdo SysV-shm CPAN wrappage). Tracing the problem back, I found that in my libapr configuration, I have #define APR_USE_SHMEM_SHMGET 1 #define APR_USE_SHMEM_MMAP_ANON 1 (the rest of APR_USE_SHMEM_* being 0 - this seems to be the normal outcome for Linux as one of the aforementioned folks had the same thing under RedHat), and this in turn is because apr/trunk/configure.in (fresh from Subversion, around line 801) prefers "SysV IPC shmget()" over "Classical mmap() on temporary file", which is the *worse* option in configure.in's view (according to a comment way below, at line 1631). Now, why on earth would one prefer SysV shared memory over file-based mmap() when both are available? At the very least this should be made a command-line configuration option, for the benefit of distribution maintainers who want to get rid of SysV stuff altogether. Enclosed is a patch to configure.in that sets mmap-first behavior (w/o a command-line switch), and shuffles the documentation around a bit so as to avoid future confusion on this topic. Best regards and thanks for all the hard work, -- << Tout n'y est pas parfait, mais on y honore certainement les jardiniers >> Dominique Quatravaux --------------000006060704000707090500 Content-Type: text/x-patch; name="apr-mmap-predates-sysvshm.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="apr-mmap-predates-sysvshm.patch" Index: configure.in =================================================================== --- configure.in (revision 149267) +++ configure.in (working copy) @@ -729,6 +729,7 @@ fi # Now we determine which one is our anonymous shmem preference. +# The last APR_DECIDE to execute sets the default. haveshmgetanon="0" havemmapzero="0" havemmapanon="0" @@ -793,25 +794,26 @@ AC_SUBST(havemmapanon) # Now we determine which one is our name-based shmem preference. +# The last APR_DECIDE to execute sets the default. havemmaptmp="0" havemmapshm="0" haveshmget="0" havebeosarea="0" haveos2shm="0" APR_BEGIN_DECISION([namebased memory allocation method]) -APR_IFALLYES(header:sys/mman.h func:mmap func:munmap, - [havemmaptmp="1" - APR_DECIDE(USE_SHMEM_MMAP_TMP, - [Classical mmap() on temporary file])]) +APR_IFALLYES(header:sys/ipc.h header:sys/shm.h header:sys/file.h dnl + func:shmget func:shmat func:shmdt func:shmctl, + [haveshmget="1" + APR_DECIDE(USE_SHMEM_SHMGET, [SysV IPC shmget()])]) APR_IFALLYES(header:sys/mman.h func:mmap func:munmap func:shm_open dnl func:shm_unlink, [havemmapshm="1" APR_DECIDE(USE_SHMEM_MMAP_SHM, [mmap() via POSIX.1 shm_open() on temporary file])]) -APR_IFALLYES(header:sys/ipc.h header:sys/shm.h header:sys/file.h dnl - func:shmget func:shmat func:shmdt func:shmctl, - [haveshmget="1" - APR_DECIDE(USE_SHMEM_SHMGET, [SysV IPC shmget()])]) +APR_IFALLYES(header:sys/mman.h func:mmap func:munmap, + [havemmaptmp="1" + APR_DECIDE(USE_SHMEM_MMAP_TMP, + [Classical mmap() on temporary file])]) APR_IFALLYES(header:kernel/OS.h func:create_area, [havebeosshm="1" APR_DECIDE(USE_SHMEM_BEOS, [BeOS areas])]) --------------000006060704000707090500--