Changeset 1367


Ignore:
Timestamp:
Apr 15, 2004, 12:51:47 AM (21 years ago)
Author:
bird
Message:

#1023: check for ERROR_TOO_MANY_OPEN_FILES and try expand table.

Location:
trunk/src/emx/src/lib/sys
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/emx/src/lib/sys/__dup.c

    • Property cvs2svn:cvs-rev changed from 1.4 to 1.5
    r1366 r1367  
    44#include "libc-alias.h"
    55#define INCL_FSMACROS
     6#define INCL_ERRORS
    67#include <os2emx.h>
    78#include <errno.h>
     
    3132    if (!pFH->pOps)
    3233    {
    33         HFILE   hNew = ~0;
     34        int     cExpandRetries;
     35        HFILE   hNew;
    3436        FS_VAR();
    3537        FS_SAVE_LOAD();
    36         rc = DosDupHandle(fh, &hNew);
     38        for (cExpandRetries = 0;;)
     39        {
     40            hNew = ~0;
     41            rc = DosDupHandle(fh, &hNew);
     42            if (rc != ERROR_TOO_MANY_OPEN_FILES)
     43                break;
     44            if (cExpandRetries++ >= 3)
     45                break;
     46            /* autoincrement. */
     47            __libc_FHMoreHandles();
     48        }   /* ... retry 3 times ... */
    3749        FS_RESTORE();
    3850        fhNew = (int)hNew;
  • trunk/src/emx/src/lib/sys/__open.c

    • Property cvs2svn:cvs-rev changed from 1.9 to 1.10
    r1366 r1367  
    3434    HFILE   hFile;
    3535    int     cch;
     36    int     cExpandRetries;
    3637    int     failed_open_errno;
    3738    FS_VAR();
     
    114115     */
    115116    FS_SAVE_LOAD();
     117    for (cExpandRetries = 0;;)
     118    {
    116119#if OFF_MAX > LONG_MAX
    117     if (__pfnDosOpenL)
    118     {
    119         LONGLONG cbInitialTmp = cbInitial;
    120         int     cch = strlen(pszFile);
    121         char *  pszFile_safe = alloca(cch + 1);
    122         if (pszFile_safe)
    123         {
    124             strcpy(pszFile_safe, pszFile);
    125             rc = __pfnDosOpenL((PCSZ)pszFile_safe, &hFile, &ulAction, cbInitialTmp, flAttr, flOpenFlags, flOpenMode, NULL);
     120        if (__pfnDosOpenL)
     121        {
     122            LONGLONG cbInitialTmp = cbInitial;
     123            int     cch = strlen(pszFile);
     124            char *  pszFile_safe = alloca(cch + 1);
     125            if (pszFile_safe)
     126            {
     127                strcpy(pszFile_safe, pszFile);
     128                rc = __pfnDosOpenL((PCSZ)pszFile_safe, &hFile, &ulAction, cbInitialTmp, flAttr, flOpenFlags, flOpenMode, NULL);
     129            }
     130            else
     131                rc = ERROR_NOT_ENOUGH_MEMORY;
    126132        }
    127133        else
    128             rc = ERROR_NOT_ENOUGH_MEMORY;
    129     }
    130     else
    131     {
    132         ULONG cbInitialTmp = (ULONG)cbInitial;
    133         if (cbInitial > LONG_MAX)
    134         {
    135             FS_RESTORE();
    136             errno = EOVERFLOW;
    137             LIBCLOG_RETURN_INT(-1);
    138         }
    139         rc = DosOpen((PCSZ)pszFile, &hFile, &ulAction, cbInitialTmp, flAttr, flOpenFlags, flOpenMode, NULL);
    140     }
     134        {
     135            ULONG cbInitialTmp = (ULONG)cbInitial;
     136            if (cbInitial > LONG_MAX)
     137            {
     138                FS_RESTORE();
     139                errno = EOVERFLOW;
     140                LIBCLOG_RETURN_INT(-1);
     141            }
     142            rc = DosOpen((PCSZ)pszFile, &hFile, &ulAction, cbInitialTmp, flAttr, flOpenFlags, flOpenMode, NULL);
     143        }
    141144#else
    142     {
    143         ULONG cbInitialTmp = cbInitial;
    144         rc = DosOpen((PCSZ)pszFile, &hFile, &ulAction, cbInitialTmp, flAttr, flOpenFlags, flOpenMode, NULL);
    145     }
     145        {
     146            ULONG cbInitialTmp = cbInitial;
     147            rc = DosOpen((PCSZ)pszFile, &hFile, &ulAction, cbInitialTmp, flAttr, flOpenFlags, flOpenMode, NULL);
     148        }
    146149#endif
     150        /* Check if we're out of handles. */
     151        if (rc != ERROR_TOO_MANY_OPEN_FILES)
     152            break;
     153        if (cExpandRetries++ >= 3)
     154            break;
     155        __libc_FHMoreHandles();
     156    }   /* ... retry 3 times ... */
    147157
    148158    if (!rc)
  • trunk/src/emx/src/lib/sys/__pipe.c

    • Property cvs2svn:cvs-rev changed from 1.5 to 1.6
    r1366 r1367  
    33
    44#include "libc-alias.h"
     5#define INCL_ERRORS
    56#define INCL_DOSQUEUES
    67#define INCL_FSMACROS
     
    1415int __pipe(int *two_handles, int pipe_size, PLIBCFH *ppFHRead, PLIBCFH *ppFHWrite)
    1516{
    16     ULONG rc;
     17    ULONG   rc;
     18    int     cExpandRetries;
    1719    FS_VAR();
    1820
    19     FS_SAVE_LOAD();
    2021    /*
    2122     * Create the pipe
    2223     */
    23     rc = DosCreatePipe((PHFILE)&two_handles[0], (PHFILE)&two_handles[1], pipe_size);
     24    FS_SAVE_LOAD();
     25    for (cExpandRetries = 0;;)
     26    {
     27        rc = DosCreatePipe((PHFILE)&two_handles[0], (PHFILE)&two_handles[1], pipe_size);
     28        if (rc != ERROR_TOO_MANY_OPEN_FILES)
     29            break;
     30        if (cExpandRetries++ >= 3)
     31            break;
     32        /* auto increment */
     33        __libc_FHMoreHandles();
     34    }   /* ... retry 3 times ... */
     35
    2436    if (!rc)
    2537    {
Note: See TracChangeset for help on using the changeset viewer.