From 9e05fad4b2d129a60285164effdeb43bde7022e5 Mon Sep 17 00:00:00 2001 From: "darin%meer.net" Date: Wed, 8 Oct 2003 04:37:38 +0000 Subject: [PATCH] adding some additional documentation per bzbarsky, b=192284 --- netwerk/base/public/nsISyncStreamListener.idl | 9 ++++++--- netwerk/base/public/nsNetUtil.h | 3 +++ netwerk/base/src/nsSyncStreamListener.cpp | 9 +++++++++ 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/netwerk/base/public/nsISyncStreamListener.idl b/netwerk/base/public/nsISyncStreamListener.idl index 0a43cf4603f3..27b62574b9b9 100644 --- a/netwerk/base/public/nsISyncStreamListener.idl +++ b/netwerk/base/public/nsISyncStreamListener.idl @@ -40,9 +40,12 @@ interface nsISyncStreamListener : nsIStreamListener { /** - * Returns an input stream that when read will fetch data delivered - * to the sync stream listener. The nsIInputStream implementation - * will wait for OnDataAvailable events before returning from Read. + * Returns an input stream that when read will fetch data delivered to the + * sync stream listener. The nsIInputStream implementation will wait for + * OnDataAvailable events before returning from Read. + * + * NOTE: Reading from the returned nsIInputStream may spin the current + * thread's event queue, which could result in any event being processed. */ readonly attribute nsIInputStream inputStream; }; diff --git a/netwerk/base/public/nsNetUtil.h b/netwerk/base/public/nsNetUtil.h index 63fc84173f57..a8f6fcce36c7 100644 --- a/netwerk/base/public/nsNetUtil.h +++ b/netwerk/base/public/nsNetUtil.h @@ -468,6 +468,9 @@ NS_NewSyncStreamListener(nsIStreamListener **aResult, /** * Implement the nsIChannel::Open(nsIInputStream**) method using the channel's * AsyncOpen method. + * + * NOTE: Reading from the returned nsIInputStream may spin the current + * thread's event queue, which could result in any event being processed. */ inline nsresult NS_ImplementChannelOpen(nsIChannel *aChannel, diff --git a/netwerk/base/src/nsSyncStreamListener.cpp b/netwerk/base/src/nsSyncStreamListener.cpp index 8fdf061b3721..5ba20aea7034 100644 --- a/netwerk/base/src/nsSyncStreamListener.cpp +++ b/netwerk/base/src/nsSyncStreamListener.cpp @@ -116,9 +116,18 @@ nsSyncStreamListener::OnDataAvailable(nsIRequest *request, PRUint32 bytesWritten; nsresult rv = mPipeOut->WriteFrom(stream, count, &bytesWritten); + + // if we get an error, then return failure. this will cause the + // channel to be canceled, and as a result our OnStopRequest method + // will be called immediately. because of this we do not need to + // set mStatus or mKeepWaiting here. if (NS_FAILED(rv)) return rv; + // we expect that all data will be written to the pipe because + // the pipe was created to have "infinite" room. + NS_ASSERTION(bytesWritten == count, "did not write all data"); + mKeepWaiting = PR_FALSE; // unblock Read return NS_OK; }