ibm-information-center/dist/eclipse/plugins/i5OS.ic.apis_5.4.0.1/dossrmfh.htm

314 lines
9.4 KiB
HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Copyright" content="Copyright (c) 2006 by IBM Corporation">
<title>DosSetRelMaxFH()--Change Maximum Number of File Descriptors</title>
<!-- Begin Header Records ========================================== -->
<!-- All rights reserved. Licensed Materials Property of IBM -->
<!-- US Government Users Restricted Rights -->
<!-- Use, duplication or disclosure restricted by -->
<!-- GSA ADP Schedule Contract with IBM Corp. -->
<!-- Change History: -->
<!-- YYMMDD USERID Change description -->
<!-- Unix2 SCRIPT J converted by B2H R4.1 (346) (CMS) by V2KEA304 -->
<!-- at RCHVMW2 on 17 Feb 1999 at 11:05:09 -->
<!-- 020131 JTROUS Changes from API Review 3, V5R2 -->
<!-- 020319 JTROUS Changes for Virus scanner, 98860, V5R3 -->
<!-- 0206?? JET: This file has undergone html cleanup June 2002 -->
<!-- 021118 JTROUS: Correct ERROR_GEN_FAILURE (no change flag) -->
<!-- 050413 JTROUS: Minor fixups, V5R4 review (no change flag) -->
<!--End Header Records -->
<link rel="stylesheet" type="text/css" href="../rzahg/ic.css">
</head>
<body>
<!-- Java sync-link -->
<script language="Javascript" src="../rzahg/synch.js" type="text/javascript">
</script>
<a name="Top_Of_Page"></a>
<h2>DosSetRelMaxFH()--Change Maximum Number of File Descriptors</h2>
<div class="box" style="width: 70%;">
<br>
&nbsp;&nbsp;Syntax<br>
<pre>
#define INCL_DOSERRORS
#define INCL_DOSFILEMGR
#include &lt;os2.h&gt;
APIRET APIENTRY DosSetRelMaxFH(PLONG <em>pcbReqCount</em>,
PULONG <em>pcbCurMaxFH</em>);
</pre>
&nbsp;&nbsp;Service Program Name: QP0LLIB1<br>
<!-- iddvc RMBR -->
<br>
&nbsp;&nbsp;Default Public Authority: *USE<br>
<!-- iddvc RMBR -->
<br>
&nbsp;&nbsp;Threadsafe: Yes<br>
<!-- iddvc RMBR -->
<br>
</div>
<p>The <strong>DosSetRelMaxFH()</strong> function requests that the system
change the maximum number of file descriptors for the calling process (job).
The system preserves all file descriptors that are currently open.</p>
<p>A request to increase the maximum number of file descriptors by more than
the system can accommodate will succeed. The resulting maximum will be the
largest number possible, but will be less than what you requested.</p>
<p>A request to decrease the maximum number of file descriptors will succeed.
The resulting maximum will be the smallest number possible, but may be more
than what you expected. For example, assume that the current maximum is 200 and
there are 150 open files. A request to decrease the maximum by 75 results in
the maximum being decreased by only 50, to 150, to preserve the open file
descriptors.</p>
<p>A request to decrease the maximum number of file descriptors to below 20
will succeed, but the maximum will never be decreased below 20.</p>
<p>To retrieve the current maximum number of file descriptors, without any side
effects, the value pointed to by <em>pcbReqCount</em> should be set to
zero.</p>
<br>
<h3>Parameters</h3>
<dl>
<dt><strong><em>pcbReqCount</em></strong></dt>
<dd>(Input) A pointer to the number to be added to the maximum number of file
descriptors for the calling process. If the value pointed to by <em>
pcbReqCount</em> is positive, the system increases the maximum number of file
descriptors. If the value pointed to by <em>pcbReqCount</em> is negative, the
system decreases the maximum number of file descriptors.<br>
</dd>
<dt><strong><em>pcbCurMaxFH</em></strong></dt>
<dd>(Output) A pointer to the location to receive the new total number of
allocated file descriptors.</dd>
</dl>
<br>
<h3>Authorities</h3>
<p>No authorization is required.</p>
<br>
<h3>Return Value</h3>
<dl compact>
<dt><em>NO_ERROR (0)</em></dt>
<dd><strong>DosSetRelMaxFH()</strong> was successful. The function returns <em>
NO_ERROR (0)</em> even if the system disregards or partially fulfills a request
for an increase or a decrease (for example, decreasing by a smaller number than
requested). You should examine the value pointed to by <em>pcbCurMaxFH</em> to
determine the result of this function.</dd>
<dt><em>value (non-zero)</em></dt>
<dd><strong>
DosSetRelMaxFH()</strong> was not successful. The <em>value</em> that is
returned indicates the error.</dd>
</dl>
<br>
<h3>Error Conditions</h3>
<p>If <strong>DosSetRelMaxFH()</strong> is not successful, the value that is
returned is one of the following errors. The &lt;<strong>bseerr.h</strong>&gt;
header file defines these values.</p>
<dl compact>
<dt><em>[ERROR_GEN_FAILURE]</em></dt>
<dd>
<p>A general failure occurred.</p>
<p>This may result from damage in the system. Refer to messages in the job log
for other possible causes.</p>
<br>
</dd>
<dt><em>[ERROR_PROTECTION_VIOLATION]</em></dt>
<dd>
<p>A protection violation occurred.</p>
<p>A pointer passed to this function is not a valid pointer.</p>
</dd>
</dl>
<br>
<h3>Error Messages</h3>
<p>The system may send the following messages from this function.</p>
<table width="100%" cellpadding="5">
<!-- cols="15 85" -->
<tr>
<th align="left" valign="top">Message ID</th>
<th align="left" valign="top">Error Message Text</th>
</tr>
<tr>
<td width="15%" valign="top">CPE3418 E</td>
<td width="85%" valign="top">Possible APAR condition or hardware failure.</td>
</tr>
<tr>
<td valign="top">CPFA0D4 E</td>
<td valign="top">File system error occurred. Error number &amp;1.</td>
</tr>
<tr>
<td valign="top">CPF3CF2 E</td>
<td valign="top">Error(s) occurred during running of &amp;1 API.</td>
</tr>
<tr>
<td valign="top">CPF9872 E</td>
<td valign="top">Program or service program &amp;1 in library &amp;2 ended.
Reason code &amp;3.</td>
</tr>
</table>
<br>
<br>
<h3>Usage Notes</h3>
<ol type="1">
<li>If you are using the <a href="sselect.htm"><strong>select()</strong></a> API,
you should be aware of
the value of the FD_SETSIZE macro defined in the
&lt;<strong>sys/types.h</strong>&gt; header file. This value is defined to be
200. This means that the fd_set structure is defined to contain 200 bits, one
for each file descriptor.
<p>If your application uses <strong>DosSetRelMaxFH()</strong> to increase the
maximum number of file descriptors beyond 200, you should consider defining
your own value for the FD_SETSIZE macro prior to including
&lt;<strong>sys/types.h</strong>&gt;. This is to ensure that the fd_set
structure is defined with the correct number of bits to accommodate the actual
maximum number of file descriptors.</p>
</li>
<li>The maximum number of file descriptors for this process may be obtained by
using the <a href="sysconf.htm">sysconf()</a> API with the _SC_OPEN_MAX parameter.<br>
<br>
</li>
<li>If this function is called
by a thread executing one of the scan-related exit programs (or any of its
created threads), it will fail with error code [ERROR_GEN_FAILURE]. See <a
href="ifsopenexit.htm">Integrated File System Scan on Open Exit Programs</a>
and <a href="ifscloseexit.htm">Integrated File System Scan on Close Exit
Programs</a> for more information. </li>
</ol>
<br>
<h3>Related Information</h3>
<ul>
<li>The &lt;<strong>os2.h</strong>&gt; file (see <a href="unix13.htm">Header
Files for UNIX-Type Functions</a>)<br>
</li>
<li>The &lt;<strong>os2def.h</strong>&gt; file (see <a href="unix13.htm">Header
Files for UNIX-Type Functions</a>)<br>
</li>
<li>The &lt;<strong>bse.h</strong>&gt; file (see <a href="unix13.htm">Header
Files for UNIX-Type Functions</a>)<br>
</li>
<li>The &lt;<strong>bsedos.h</strong>&gt; file (see <a href="unix13.htm">Header
Files for UNIX-Type Functions</a>)<br>
</li>
<li>The &lt;<strong>bseerr.h</strong>&gt; file (see <a href="unix13.htm">Header
Files for UNIX-Type Functions</a>)<br>
</li>
<li>The &lt;<strong>sys/types.h</strong>&gt; file (see <a href="unix13.htm">
Header Files for UNIX-Type Functions</a>)<br>
</li>
<li><a href="sselect.htm"><strong>select()</strong></a>--Wait for Events on Multiple Sockets<br>
</li>
<li><a href="sysconf.htm">sysconf()</a>--Get System Configuration
Variables</li>
</ul>
<br>
<h3>Example</h3>
<p>See <a href="../apiref/aboutapis.htm#codedisclaimer">Code disclaimer information</a>
for information pertaining to code examples.</p>
<p>The following example increases the maximum number of file descriptors by
two.</p>
<pre>
#define INCL_DOSERRORS
#define INCL_DOSFILEMGR
#include &lt;os2.h&gt;
#include &lt;stdio.h&gt;
void main()
{
long ReqCount = 0; /* Number to add to maximum */
/* file descriptor count. */
ulong CurMaxFH; /* New count of file descriptors. */
int rc; /* Return code. */
/* Find out what the initial maximum is.*/
if ( NO_ERROR == (rc = DosSetRelMaxFH(&amp;ReqCount, &amp;CurMaxFH))
{
printf("Initial maximum = %d",CurMaxFH);
ReqCount = 2; /* Set up to increase by 2. */
if (NO_ERROR == (rc = DosSetRelMaxFH(&amp;ReqCount, &amp;CurMaxFH))
{
printf(" New maximum = %d",CurMaxFH);
}
}
if (NO_ERROR != rc)
{
printf("Error = &amp;d",rc);
}
}
</pre>
<p><strong>Output:</strong></p>
<pre>
Initial maximum = 200 New maximum = 202
</pre>
<hr>
API introduced: V4R2
<hr>
<center>
<table cellpadding="2" cellspacing="2">
<tr align="center">
<td valign="middle" align="center"><a href="#Top_Of_Page">Top</a> | <a href=
"unix.htm">UNIX-Type APIs</a> | <a href="aplist.htm">APIs by category</a></td>
</tr>
</table>
</center>
</body>
</html>