Project

General

Profile

Bug #1065

gthread_aio/posix_aio: mmap() fails on OS X.

Added by jwmcglynn almost 13 years ago. Updated over 12 years ago.

Status:
Fixed
Priority:
Normal
Assignee:
-
Category:
core
Target version:
Start date:
Due date:
% Done:

0%

Estimated time:
Missing in 1.5.x:

Description

The gthread_aio and posix_aio backends are broken on OS X. OS X doesn't support using /dev/zero file descriptor for anonymous shared memory isn't supported. It results in this error getting repeated when debugging is enabled:

network_posix_aio.c.348: (error) the mmap() failed, no way for a fallback:
connections.c.1336: (trace) (network-subsys sent us a fatal-error)

To avoid this problem I replaced this line in src/network_gthread_aio.c (~ line 101):
c->file.mmap.start = mmap(0, c->file.mmap.length,
PROT_READ | PROT_WRITE, MAP_SHARED, mmap_fd, 0);

With:
c->file.mmap.start = mmap(0, c->file.mmap.length,
PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0);

Doing the same thing with src/network_posix_aio.c (~ line 348) prevents the error when using that backend.

Obviously this isn't the best way to fix the problem, the /dev/zero fd is still created and this probably breaks the code for other operating systems. Note that MAP_ANON may be called MAP_ANONYMOUS on other OSes.


Files

lighttpd-mmap.patch (4.5 KB) lighttpd-mmap.patch lighttpd-mmap.patch jwmcglynn, 2007-03-03 04:00
#1

Updated by jwmcglynn almost 13 years ago

After looking through manpages (http://ou800doc.caldera.com/en/man/html.2/mmap.2.html), it appears that the only difference between using mmap with a /dev/zero fd and MAP_ANONYMOUS is speed, with MAP_ANONYMOUS being faster.

I'm adding this patch so that you can test it, it works on OS X and doesn't crash on Linux, but I haven't tested it on any other operating systems.

#2

Updated by jwmcglynn almost 13 years ago

See also: #966

#3

Updated by jwmcglynn over 12 years ago

  • Status changed from New to Fixed
  • Resolution set to fixed

Fixed in r1757.

Also available in: Atom