diff options
author | cls%seawood.org <devnull@localhost> | 1999-08-20 16:21:37 +0000 |
---|---|---|
committer | cls%seawood.org <devnull@localhost> | 1999-08-20 16:21:37 +0000 |
commit | f7a9850912e8e1ab0ba80bc9d0a386e7ce21ed3b (patch) | |
tree | 4f9e75f7456c7b56abab28cf3b59d1f493449252 | |
parent | 2819e5c9388708946fb3a7b1ccaf8e6ecad70c4d (diff) | |
download | nspr-hg-unlabeled-3.15.8.tar.gz |
Merged with HEAD from 8/18 or so.unlabeled-3.15.8
-rw-r--r-- | pr/src/md/mac/macio.c | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/pr/src/md/mac/macio.c b/pr/src/md/mac/macio.c index 5f931521..7a352cb3 100644 --- a/pr/src/md/mac/macio.c +++ b/pr/src/md/mac/macio.c @@ -227,7 +227,7 @@ PRInt32 ReadWriteProc(PRFileDesc *fd, void *buf, PRUint32 bytes, IOOperation op) a 32 byte Ptr in the heap, so only do this once */ if (!sCompletionUPP) - sCompletionUPP = NewIOCompletionProc((ProcPtr)&AsyncIOCompletion); + sCompletionUPP = NewIOCompletionProc((IOCompletionProcPtr)&AsyncIOCompletion); /* grab the thread so we know which one to post to at completion */ pbAsync.thread = me; @@ -245,13 +245,36 @@ PRInt32 ReadWriteProc(PRFileDesc *fd, void *buf, PRUint32 bytes, IOOperation op) ** with this thread. ** Don't compute error code from async call. Bug in OS returns a garbage value. */ - me->io_pending = PR_TRUE; me->io_fd = refNum; me->md.osErrCode = noErr; if (op == READ_ASYNC) - (void) PBReadAsync(&pbAsync); + { + /* + ** Skanky optimization so that reads < 2K are actually done synchronously + ** to optimize performance on small reads (e.g. registry reads on startup) + */ + if (bytes > 2048L) + { + me->io_pending = PR_TRUE; /* Only mark thread io pending in async call */ + (void) PBReadAsync(&pbAsync); + } + else + { + (void) PBReadSync(&pbAsync); + /* + ** This is probbaly redundant but want to make sure we indicate the read + ** is complete so we don't wander off into the Sargasso Sea of Mac + ** threading + */ + pbAsync.pb.ioParam.ioResult = 0; + } + } else + { + /* writes are currently always async so mark thread io pending */ + me->io_pending = PR_TRUE; (void) PBWriteAsync(&pbAsync); + } /* See if the i/o call is still pending before we actually yield */ if (pbAsync.pb.ioParam.ioResult == 1) |