]> git.tuebingen.mpg.de Git - paraslash.git/commit
ipc: Determine maximal size of a shared memory area at runtime.
authorAndre Noll <maan@systemlinux.org>
Wed, 10 Aug 2011 17:50:38 +0000 (19:50 +0200)
committerAndre Noll <maan@systemlinux.org>
Fri, 16 Sep 2011 19:41:47 +0000 (21:41 +0200)
commit1fcea504b3a8541d039c3e63491e158433b06875
treeac79075cce8395d7912d6d64fcfbb762ee5532af
parent1123865b9a3e45dc26d7c6dec0ed3540274c1c3d
ipc: Determine maximal size of a shared memory area at runtime.

During command dispatch, the afs process allocates shm areas for the
query result and passes the identifiers via the local socket to the
child process of para_server which is executing the command. If the
write to the (non-blocking) local socket fails, for example because
the call would block, afs closes the connection to the child process
immediately to avoid deadlocks.

Therefore the maximal output size of an (afs) command depends
linearly on the size of the shared memory areas, so it is desirable
to allocate areas as large as possible. Currently, we use the SHMMAX
if it is defined and fall back to the safe default value of 64K
otherwise. However, this default is much smaller than the typical limit
of 32M on Linux. Moreover, the maximal size of a shared memory area
(shmmax) can be set at any time on most if not all operating systems,
so runtime detection of shmmax is to be preferred.

Unfortunately the way to obtain shmmax varies between operating
systems. On Linux, the value is available as the contents of a file
in /proc while on {Free,Net}BSD and Darwin sysctlbyname() must be
called. Moreover, BSD and Darwin use different identifiers for the
sysctlbyname() call.

So any code that determines shmmax at runtime and works on all
of the above systems must necessarily be ugly. This patch tries to
concentrate all ugliness in the new shm_get_shmmax() function, so that
the changes outside of ipc.c consist only of replacements SHMMAX ->
shm_get_shmmax() and of the removal of the default SHMMAX setting.

The new function only determines shmmax once when it is called for
the first time.
afs.c
aft.c
attribute.c
blob.c
ipc.c
ipc.h
mood.c
playlist.c