bug #18267. Changed the marshalled OnDataAvailable event to cancel the transport if the consumer returns a failure. THis ensures that the transport is notified of the error...

git-svn-id: svn://10.0.0.236/trunk@62031 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
rpotts%netscape.com
2000-03-02 05:49:09 +00:00
parent 23c0ad524f
commit e54a3271ae
2 changed files with 30 additions and 2 deletions

View File

@@ -279,6 +279,15 @@ nsOnStopRequestEvent::HandleEvent()
("netlibEvent: Handle Stop [event=%x]", this));
#endif
nsIStreamObserver* receiver = (nsIStreamObserver*)mListener->GetReceiver();
nsresult rv = mListener->GetStatus();
//
// If the consumer returned a failure code, then pass it out in the
// OnStopRequest(...) notification...
//
if (NS_FAILED(rv)) {
mStatus = rv;
}
return receiver->OnStopRequest(mChannel, mContext, mStatus, mMessage);
}
@@ -369,8 +378,27 @@ nsOnDataAvailableEvent::HandleEvent()
("netlibEvent: Handle Data [event=%x]", this));
#endif
nsIStreamListener* receiver = (nsIStreamListener*)mListener->GetReceiver();
return receiver->OnDataAvailable(mChannel, mContext,
nsresult rv = mListener->GetStatus();
//
// Only send OnDataAvailable(... ) notifications if all previous calls
// have succeeded...
//
if (NS_SUCCEEDED(rv)) {
rv = receiver->OnDataAvailable(mChannel, mContext,
mIStream, mSourceOffset, mLength);
//
// If the consumer fails, then cancel the transport. This is necessary
// in case where the socket transport is blocked waiting for room in the
// pipe, but the consumer fails without consuming all the data.
//
// Unless the transport is cancelled, it will block forever, waiting for
// the pipe to empty...
//
if (NS_FAILED(rv)) {
mChannel->Cancel();
}
}
return rv;
}
NS_IMETHODIMP

View File

@@ -52,7 +52,7 @@ public:
nsISupports* GetReceiver() { return mReceiver.get(); }
nsresult GetStatus() { return mStatus; }
void SetStatus(nsresult value) { mStatus = value; }
void SetStatus(nsresult value) { if (NS_SUCCEEDED(mStatus)) mStatus = value; }
protected:
nsCOMPtr<nsIEventQueue> mEventQueue;