diff options
author | sdagley%netscape.com <devnull@localhost> | 1999-07-22 21:26:33 +0000 |
---|---|---|
committer | sdagley%netscape.com <devnull@localhost> | 1999-07-22 21:26:33 +0000 |
commit | 4585aa328c1eaea0a3a1f6f504e5585446d57b36 (patch) | |
tree | f940c816c9ec9b2f2069160d32fd228fd43f2add | |
parent | 3a1cd3b0f5f574c00cc55f478adec542a664fa0d (diff) | |
download | nspr-hg-4585aa328c1eaea0a3a1f6f504e5585446d57b36.tar.gz |
Change to address bug #10334 and improve startup time on Mac. Use sync i/o for reads of less than 2K.
-rw-r--r-- | pr/src/md/mac/macio.c | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/pr/src/md/mac/macio.c b/pr/src/md/mac/macio.c index c5ae92c9..7a352cb3 100644 --- a/pr/src/md/mac/macio.c +++ b/pr/src/md/mac/macio.c @@ -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) |