diff options
author | wtc%netscape.com <devnull@localhost> | 2001-12-07 01:39:58 +0000 |
---|---|---|
committer | wtc%netscape.com <devnull@localhost> | 2001-12-07 01:39:58 +0000 |
commit | e31f6213a8280057f87da46cce0ad1be1c173a8c (patch) | |
tree | 145896fcdac92c514d62bbcec20dc5f88077c217 | |
parent | b1b754cf01facd57cde699c6791de738c8c8405c (diff) | |
download | nspr-hg-e31f6213a8280057f87da46cce0ad1be1c173a8c.tar.gz |
Bugzilla bug 113906: Made _PR_MD_OPEN more efficient. The patch is
contributed by Michael Kaply <mkaply@us.ibm.com>. r=wtc,pedemont.
-rw-r--r-- | pr/src/md/os2/os2io.c | 41 |
1 files changed, 25 insertions, 16 deletions
diff --git a/pr/src/md/os2/os2io.c b/pr/src/md/os2/os2io.c index 926d6e10..44cee646 100644 --- a/pr/src/md/os2/os2io.c +++ b/pr/src/md/os2/os2io.c @@ -144,7 +144,7 @@ _PR_MD_OPEN(const char *name, PRIntn osflags, int mode) HFILE file; PRInt32 access = OPEN_SHARE_DENYNONE; PRInt32 flags = 0L; - PRInt32 rc; + APIRET rc = 0; PRUword actionTaken; ULONG CurMaxFH = 0; @@ -180,24 +180,33 @@ _PR_MD_OPEN(const char *name, PRIntn osflags, int mode) } if (isxdigit(mode) == 0) /* file attribs are hex, UNIX modes octal */ - fattr = ((ULONG)mode == FILE_HIDDEN) ? FILE_HIDDEN : FILE_NORMAL; + fattr = ((ULONG)mode == FILE_HIDDEN) ? FILE_HIDDEN : FILE_NORMAL; else fattr = FILE_NORMAL; - /* OS/2 sets the Max file handles per process to 20 by default */ - DosSetRelMaxFH(&ReqCount, &CurMaxFH); - - rc = DosOpen((char*)name, - &file, /* file handle if successful */ - &actionTaken, /* reason for failure */ - 0, /* initial size of new file */ - fattr, /* file system attributes */ - flags, /* Open flags */ - access, /* Open mode and rights */ - 0); /* OS/2 Extended Attributes */ + do { + rc = DosOpen((char*)name, + &file, /* file handle if successful */ + &actionTaken, /* reason for failure */ + 0, /* initial size of new file */ + fattr, /* file system attributes */ + flags, /* Open flags */ + access, /* Open mode and rights */ + 0); /* OS/2 Extended Attributes */ + if (rc == ERROR_TOO_MANY_OPEN_FILES) { + ULONG CurMaxFH = 0; + LONG ReqCount = 20; + APIRET rc2; + rc2 = DosSetRelMaxFH(&ReqCount, &CurMaxFH); + if (rc2 != NO_ERROR) { + break; + } + } + } while (rc == ERROR_TOO_MANY_OPEN_FILES); + if (rc != NO_ERROR) { - _PR_MD_MAP_OPEN_ERROR(rc); - return -1; - } + _PR_MD_MAP_OPEN_ERROR(rc); + return -1; + } return (PRInt32)file; } |