summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwtc%netscape.com <devnull@localhost>2000-03-15 00:18:23 +0000
committerwtc%netscape.com <devnull@localhost>2000-03-15 00:18:23 +0000
commit2b4fe8582bccc2f847ed50c8593605f20c846372 (patch)
tree01d53fd38c5d7acecd0aa519e260857a461a832a
parentc4e2c9f60daa71875b5df0b28b8b3ccd4deaaf5b (diff)
downloadnspr-hg-2b4fe8582bccc2f847ed50c8593605f20c846372.tar.gz
Bugzilla bug #29908: make sure that md.write.thread or md.read.thread is
nil when we return from SendReceiveStream so that we don't leave a dangling reference for the OT notifier routine. This patch is submitted by Gordon Sheridon <gordon@netscape.com>. r=wtc@netscape.com a=jar@netscape.com. (NSPRPUB_CLIENT_BRANCH)
-rw-r--r--pr/src/md/mac/macsockotpt.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/pr/src/md/mac/macsockotpt.c b/pr/src/md/mac/macsockotpt.c
index 7b6e4441..f408d845 100644
--- a/pr/src/md/mac/macsockotpt.c
+++ b/pr/src/md/mac/macsockotpt.c
@@ -1350,6 +1350,7 @@ static PRInt32 SendReceiveStream(PRFileDesc *fd, void *buf, PRInt32 amount,
PRInt32 bytesLeft = amount;
PR_ASSERT(flags == 0);
+ PR_ASSERT(opCode == kSTREAM_SEND || opCode == kSTREAM_RECEIVE);
if (endpoint == NULL) {
err = kEBADFErr;
@@ -1361,11 +1362,6 @@ static PRInt32 SendReceiveStream(PRFileDesc *fd, void *buf, PRInt32 amount,
goto ErrorExit;
}
- if (opCode != kSTREAM_SEND && opCode != kSTREAM_RECEIVE) {
- err = kEINVALErr;
- goto ErrorExit;
- }
-
while (bytesLeft > 0) {
PrepareForAsyncCompletion(me, fd->secret->md.osfd);
@@ -1434,6 +1430,10 @@ static PRInt32 SendReceiveStream(PRFileDesc *fd, void *buf, PRInt32 amount,
}
me->io_pending = PR_FALSE;
+ if (opCode == kSTREAM_SEND)
+ fd->secret->md.write.thread = nil;
+ else
+ fd->secret->md.read.thread = nil;
if (result > 0) {
buf = (void *) ( (UInt32) buf + (UInt32)result );
@@ -1471,9 +1471,13 @@ static PRInt32 SendReceiveStream(PRFileDesc *fd, void *buf, PRInt32 amount,
}
}
+ PR_ASSERT(opCode == kSTREAM_SEND ? fd->secret->md.write.thread == nil :
+ fd->secret->md.read.thread == nil);
return amount;
ErrorExit:
+ PR_ASSERT(opCode == kSTREAM_SEND ? fd->secret->md.write.thread == nil :
+ fd->secret->md.read.thread == nil);
macsock_map_error(err);
return -1;
}