man-pages/man3/mpool.3.html
2021-03-31 01:06:50 +01:00

327 lines
6.8 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML><HEAD><TITLE>Man page of MPOOL</TITLE>
</HEAD><BODY>
<H1>MPOOL</H1>
Section: Linux Programmer's Manual (3)<BR>Updated: 2017-09-15<BR><A HREF="#index">Index</A>
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
<A NAME="lbAB">&nbsp;</A>
<H2>NAME</H2>
mpool - shared memory buffer pool
<A NAME="lbAC">&nbsp;</A>
<H2>SYNOPSIS</H2>
<PRE>
<B>#include &lt;<A HREF="file:///usr/include/db.h">db.h</A>&gt;</B>
<B>#include &lt;<A HREF="file:///usr/include/mpool.h">mpool.h</A>&gt;</B>
<B>MPOOL *mpool_open(DBT *</B><I>key</I><B>, int </B><I>fd</I><B>, pgno_t </B><I>pagesize</I><B>, pgno_t </B><I>maxcache</I><B>);</B>
<B>void mpool_filter(MPOOL *</B><I>mp</I><B>, void (*pgin)(void *, pgno_t, void *),</B>
<B> void (*</B><I>pgout</I><B>)(void *, pgno_t, void *),</B>
<B> void *</B><I>pgcookie</I><B>);</B>
<B>void *mpool_new(MPOOL *</B><I>mp</I><B>, pgno_t *</B><I>pgnoaddr</I><B>);</B>
<B>void *mpool_get(MPOOL *</B><I>mp</I><B>, pgno_t </B><I>pgno</I><B>, unsigned int </B><I>flags</I><B>);</B>
<B>int mpool_put(MPOOL *</B><I>mp</I><B>, void *</B><I>pgaddr</I><B>, unsigned int </B><I>flags</I><B>);</B>
<B>int mpool_sync(MPOOL *</B><I>mp</I><B>);</B>
<B>int mpool_close(MPOOL *</B><I>mp</I><B>);</B>
</PRE>
<A NAME="lbAD">&nbsp;</A>
<H2>DESCRIPTION</H2>
<I>Note well</I>:
This page documents interfaces provided in glibc up until version 2.1.
Since version 2.2, glibc no longer provides these interfaces.
Probably, you are looking for the APIs provided by the
<I>libdb</I>
library instead.
<P>
<I>Mpool</I>
is the library interface intended to provide page oriented buffer management
of files.
The buffers may be shared between processes.
<P>
The function
<B>mpool_open</B>()
initializes a memory pool.
The
<I>key</I>
argument is the byte string used to negotiate between multiple
processes wishing to share buffers.
If the file buffers are mapped in shared memory, all processes using
the same key will share the buffers.
If
<I>key</I>
is NULL, the buffers are mapped into private memory.
The
<I>fd</I>
argument is a file descriptor for the underlying file, which must be seekable.
If
<I>key</I>
is non-NULL and matches a file already being mapped, the
<I>fd</I>
argument is ignored.
<P>
The
<I>pagesize</I>
argument is the size, in bytes, of the pages into which the file is broken up.
The
<I>maxcache</I>
argument is the maximum number of pages from the underlying file to cache
at any one time.
This value is not relative to the number of processes which share a file's
buffers, but will be the largest value specified by any of the processes
sharing the file.
<P>
The
<B>mpool_filter</B>()
function is intended to make transparent input and output processing of the
pages possible.
If the
<I>pgin</I>
function is specified, it is called each time a buffer is read into the memory
pool from the backing file.
If the
<I>pgout</I>
function is specified, it is called each time a buffer is written into the
backing file.
Both functions are called with the
<I>pgcookie</I>
pointer, the page number and a pointer to the page to being read or written.
<P>
The function
<B>mpool_new</B>()
takes an
<I>MPOOL</I>
pointer and an address as arguments.
If a new page can be allocated, a pointer to the page is returned and
the page number is stored into the
<I>pgnoaddr</I>
address.
Otherwise, NULL is returned and
<I>errno</I>
is set.
<P>
The function
<B>mpool_get</B>()
takes an
<I>MPOOL</I>
pointer and a page number as arguments.
If the page exists, a pointer to the page is returned.
Otherwise, NULL is returned and
<I>errno</I>
is set.
The
<I>flags</I>
argument is not currently used.
<P>
The function
<B>mpool_put</B>()
unpins the page referenced by
<I>pgaddr</I>.
<I>pgaddr</I>
must be an address previously returned by
<B>mpool_get</B>()
or
<B>mpool_new</B>().
The flag value is specified by ORing
any of the following values:
<DL COMPACT>
<DT id="1"><B>MPOOL_DIRTY</B>
<DD>
The page has been modified and needs to be written to the backing file.
</DL>
<P>
<B>mpool_put</B>()
returns 0 on success and -1 if an error occurs.
<P>
The function
<B>mpool_sync</B>()
writes all modified pages associated with the
<I>MPOOL</I>
pointer to the
backing file.
<B>mpool_sync</B>()
returns 0 on success and -1 if an error occurs.
<P>
The
<B>mpool_close</B>()
function free's up any allocated memory associated with the memory pool
cookie.
Modified pages are
<B>not</B>
written to the backing file.
<B>mpool_close</B>()
returns 0 on success and -1 if an error occurs.
<A NAME="lbAE">&nbsp;</A>
<H2>ERRORS</H2>
The
<B>mpool_open</B>()
function may fail and set
<I>errno</I>
for any of the errors specified for the library routine
<B><A HREF="/cgi-bin/man/man2html?3+malloc">malloc</A></B>(3).
<P>
The
<B>mpool_get</B>()
function may fail and set
<I>errno</I>
for the following:
<DL COMPACT>
<DT id="2"><B>EINVAL</B>
<DD>
The requested record doesn't exist.
</DL>
<P>
The
<B>mpool_new</B>()
and
<B>mpool_get</B>()
functions may fail and set
<I>errno</I>
for any of the errors specified for the library routines
<B><A HREF="/cgi-bin/man/man2html?2+read">read</A></B>(2),
<B><A HREF="/cgi-bin/man/man2html?2+write">write</A></B>(2),
and
<B><A HREF="/cgi-bin/man/man2html?3+malloc">malloc</A></B>(3).
<P>
The
<B>mpool_sync</B>()
function may fail and set
<I>errno</I>
for any of the errors specified for the library routine
<B><A HREF="/cgi-bin/man/man2html?2+write">write</A></B>(2).
<P>
The
<B>mpool_close</B>()
function may fail and set
<I>errno</I>
for any of the errors specified for the library routine
<B><A HREF="/cgi-bin/man/man2html?3+free">free</A></B>(3).
<A NAME="lbAF">&nbsp;</A>
<H2>CONFORMING TO</H2>
Not in POSIX.1.
Present on the BSDs.
<A NAME="lbAG">&nbsp;</A>
<H2>SEE ALSO</H2>
<B><A HREF="/cgi-bin/man/man2html?3+btree">btree</A></B>(3),
<B><A HREF="/cgi-bin/man/man2html?3+dbopen">dbopen</A></B>(3),
<B><A HREF="/cgi-bin/man/man2html?3+hash">hash</A></B>(3),
<B><A HREF="/cgi-bin/man/man2html?3+recno">recno</A></B>(3)
<A NAME="lbAH">&nbsp;</A>
<H2>COLOPHON</H2>
This page is part of release 5.05 of the Linux
<I>man-pages</I>
project.
A description of the project,
information about reporting bugs,
and the latest version of this page,
can be found at
<A HREF="https://www.kernel.org/doc/man-pages/.">https://www.kernel.org/doc/man-pages/.</A>
<P>
<HR>
<A NAME="index">&nbsp;</A><H2>Index</H2>
<DL>
<DT id="3"><A HREF="#lbAB">NAME</A><DD>
<DT id="4"><A HREF="#lbAC">SYNOPSIS</A><DD>
<DT id="5"><A HREF="#lbAD">DESCRIPTION</A><DD>
<DT id="6"><A HREF="#lbAE">ERRORS</A><DD>
<DT id="7"><A HREF="#lbAF">CONFORMING TO</A><DD>
<DT id="8"><A HREF="#lbAG">SEE ALSO</A><DD>
<DT id="9"><A HREF="#lbAH">COLOPHON</A><DD>
</DL>
<HR>
This document was created by
<A HREF="/cgi-bin/man/man2html">man2html</A>,
using the manual pages.<BR>
Time: 00:05:48 GMT, March 31, 2021
</BODY>
</HTML>