[dovecot] Re: Using on AIX

Timo Sirainen tss at iki.fi
Wed Apr 23 16:29:55 EEST 2003


On Wed, 2003-04-23 at 15:56, Adam Lackorzynski wrote:
> The problem seems to be that
> 
>   index->mmap_base = mmap_anon(index->mmap_full_length);
> 
> in lib-index/mail-index-open.c(287) returns -1 (MAP_FAILED) which is
> then fed to mail_index_init_header(..., 0xffffffff) without being
> checked.

Right, I've missed all of them for some reason. Added to CVS.

> The mmap in anon_mmap_fixed in lib/mmap-anon.c returns
> "Not enough space" in errno. The parameter values are
> "address=0x00002000 length=0x00002000".

Linux and *BSD returns only EINVAL if address and/or length is invalid,
but UNIX98 said ENOMEM can be returned too then. This is a bit annoying
in that I can't now know if the mmap() failed because there's really no
memory or because the address was just invalid. If it's because there's
no memory, Dovecot will try a bit too long before failing. This should
anyway fix:

RCS file: /home/cvs/dovecot/src/lib/mmap-anon.c,v
retrieving revision 1.10
diff -u -r1.10 mmap-anon.c
--- mmap-anon.c 29 Dec 2002 19:33:04 -0000      1.10
+++ mmap-anon.c 23 Apr 2003 13:23:41 -0000
@@ -176,7 +176,7 @@
                if (ret == 0)
                        break;
 
-               if (ret < 0 && errno != EINVAL)
+               if (ret < 0 && errno != EINVAL && errno != ENOMEM)
                        return MAP_FAILED;
        }
 
@@ -200,7 +200,7 @@
        }
 
        if (anon_mmap_fixed(grow_base, new_size - hdr->size) < 0) {
-               if (errno == EINVAL) {
+               if (errno == EINVAL || errno == ENOMEM) {
                        /* can't grow, wanted address space is already in use */
                        return 0;
                }




More information about the dovecot mailing list