From 03ce8cb8eeff4eb2be1e7d404aee252f053e47ba Mon Sep 17 00:00:00 2001 From: Andrea Marchesini Date: Mon, 24 Apr 2017 12:09:39 +0200 Subject: [PATCH] Bug 1353475 - Implement AutoIPCStream with delayed start - part 2 - delayed start, r=smaug --- ipc/glue/IPCStream.ipdlh | 6 + ipc/glue/IPCStreamChild.cpp | 14 ++ ipc/glue/IPCStreamDestination.cpp | 275 +++++++++++++++++++++++++++++ ipc/glue/IPCStreamDestination.h | 32 +++- ipc/glue/IPCStreamParent.cpp | 14 ++ ipc/glue/IPCStreamUtils.cpp | 84 +++++---- ipc/glue/IPCStreamUtils.h | 8 +- ipc/glue/PChildToParentStream.ipdl | 8 + ipc/glue/PParentToChildStream.ipdl | 8 + 9 files changed, 412 insertions(+), 37 deletions(-) diff --git a/ipc/glue/IPCStream.ipdlh b/ipc/glue/IPCStream.ipdlh index a4cd19c28d77..68751ce46978 100644 --- a/ipc/glue/IPCStream.ipdlh +++ b/ipc/glue/IPCStream.ipdlh @@ -27,6 +27,12 @@ union IPCRemoteStreamType struct IPCRemoteStream { + // If this is true, the stream will send data only when the first operation + // is done on the destination side. The benefit of this is that we do not + // send data if not needed. On the other hand, it could have a performance + // issue. + bool delayedStart; + IPCRemoteStreamType stream; }; diff --git a/ipc/glue/IPCStreamChild.cpp b/ipc/glue/IPCStreamChild.cpp index 155a47b54307..76294312978e 100644 --- a/ipc/glue/IPCStreamChild.cpp +++ b/ipc/glue/IPCStreamChild.cpp @@ -47,6 +47,13 @@ public: ActorDestroyed(); } + IPCResult + RecvStartReading() override + { + Start(); + return IPC_OK(); + } + IPCResult RecvRequestClose(const nsresult& aRv) override { @@ -167,6 +174,13 @@ private: // IPCStreamDestination methods + void + StartReading() override + { + MOZ_ASSERT(HasDelayedStart()); + Unused << SendStartReading(); + } + void RequestClose(nsresult aRv) override { diff --git a/ipc/glue/IPCStreamDestination.cpp b/ipc/glue/IPCStreamDestination.cpp index 2d2ee8d80cde..1d3a76b1956a 100644 --- a/ipc/glue/IPCStreamDestination.cpp +++ b/ipc/glue/IPCStreamDestination.cpp @@ -5,14 +5,256 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "IPCStreamDestination.h" +#include "mozilla/Mutex.h" #include "nsIAsyncInputStream.h" #include "nsIAsyncOutputStream.h" +#include "nsIBufferedStreams.h" +#include "nsICloneableInputStream.h" #include "nsIPipe.h" namespace mozilla { namespace ipc { +// ---------------------------------------------------------------------------- +// IPCStreamDestination::DelayedStartInputStream +// +// When AutoIPCStream is used with delayedStart, we need to ask for data at the +// first real use of the nsIInputStream. In order to do so, we wrap the +// nsIInputStream, created by the nsIPipe, with this wrapper. + +class IPCStreamDestination::DelayedStartInputStream final + : public nsIAsyncInputStream + , public nsISearchableInputStream + , public nsICloneableInputStream + , public nsIBufferedInputStream +{ +public: + NS_DECL_THREADSAFE_ISUPPORTS + + DelayedStartInputStream(IPCStreamDestination* aDestination, + already_AddRefed&& aStream) + : mDestination(aDestination) + , mStream(aStream) + , mMutex("IPCStreamDestination::DelayedStartInputStream::mMutex") + { + MOZ_ASSERT(mDestination); + MOZ_ASSERT(mStream); + } + + void + DestinationShutdown() + { + MutexAutoLock lock(mMutex); + mDestination = nullptr; + } + + // nsIInputStream interface + + NS_IMETHOD + Close() override + { + MaybeCloseDestination(); + return mStream->Close(); + } + + NS_IMETHOD + Available(uint64_t* aLength) override + { + MaybeStartReading(); + return mStream->Available(aLength); + } + + NS_IMETHOD + Read(char* aBuffer, uint32_t aCount, uint32_t* aReadCount) override + { + MaybeStartReading(); + return mStream->Read(aBuffer, aCount, aReadCount); + } + + NS_IMETHOD + ReadSegments(nsWriteSegmentFun aWriter, void* aClosure, uint32_t aCount, + uint32_t *aResult) override + { + MaybeStartReading(); + return mStream->ReadSegments(aWriter, aClosure, aCount, aResult); + } + + NS_IMETHOD + IsNonBlocking(bool* aNonBlocking) override + { + MaybeStartReading(); + return mStream->IsNonBlocking(aNonBlocking); + } + + // nsIAsyncInputStream interface + + NS_IMETHOD + CloseWithStatus(nsresult aReason) override + { + MaybeCloseDestination(); + return mStream->CloseWithStatus(aReason); + } + + NS_IMETHOD + AsyncWait(nsIInputStreamCallback* aCallback, uint32_t aFlags, + uint32_t aRequestedCount, nsIEventTarget* aTarget) override + { + MaybeStartReading(); + return mStream->AsyncWait(aCallback, aFlags, aRequestedCount, aTarget); + } + + NS_IMETHOD + Search(const char* aForString, bool aIgnoreCase, bool* aFound, + uint32_t* aOffsetSearchedTo) override + { + MaybeStartReading(); + nsCOMPtr searchable = do_QueryInterface(mStream); + MOZ_ASSERT(searchable); + return searchable->Search(aForString, aIgnoreCase, aFound, aOffsetSearchedTo); + } + + // nsICloneableInputStream interface + + NS_IMETHOD + GetCloneable(bool* aCloneable) override + { + MaybeStartReading(); + nsCOMPtr cloneable = do_QueryInterface(mStream); + MOZ_ASSERT(cloneable); + return cloneable->GetCloneable(aCloneable); + } + + NS_IMETHOD + Clone(nsIInputStream** aResult) override + { + MaybeStartReading(); + nsCOMPtr cloneable = do_QueryInterface(mStream); + MOZ_ASSERT(cloneable); + return cloneable->Clone(aResult); + } + + // nsIBufferedInputStream + + NS_IMETHOD + Init(nsIInputStream* aStream, uint32_t aBufferSize) override + { + MaybeStartReading(); + nsCOMPtr stream = do_QueryInterface(mStream); + MOZ_ASSERT(stream); + return stream->Init(aStream, aBufferSize); + } + + void + MaybeStartReading(); + + void + MaybeCloseDestination(); + +private: + ~DelayedStartInputStream() = default; + + IPCStreamDestination* mDestination; + nsCOMPtr mStream; + + // This protects mDestination: any method can be called by any thread. + Mutex mMutex; + + class HelperRunnable; +}; + +class IPCStreamDestination::DelayedStartInputStream::HelperRunnable final + : public Runnable +{ +public: + enum Op { + eStartReading, + eCloseDestination, + }; + + HelperRunnable(IPCStreamDestination::DelayedStartInputStream* aDelayedStartInputStream, + Op aOp) + : mDelayedStartInputStream(aDelayedStartInputStream) + , mOp(aOp) + { + MOZ_ASSERT(aDelayedStartInputStream); + } + + NS_IMETHOD + Run() override + { + switch (mOp) { + case eStartReading: + mDelayedStartInputStream->MaybeStartReading(); + break; + case eCloseDestination: + mDelayedStartInputStream->MaybeCloseDestination(); + break; + } + + return NS_OK; + } + +private: + RefPtr mDelayedStartInputStream; + Op mOp; +}; + +void +IPCStreamDestination::DelayedStartInputStream::MaybeStartReading() +{ + MutexAutoLock lock(mMutex); + if (!mDestination) { + return; + } + + if (mDestination->IsOnOwningThread()) { + mDestination->StartReading(); + mDestination = nullptr; + return; + } + + RefPtr runnable = + new HelperRunnable(this, HelperRunnable::eStartReading); + mDestination->DispatchRunnable(runnable.forget()); +} + +void +IPCStreamDestination::DelayedStartInputStream::MaybeCloseDestination() +{ + MutexAutoLock lock(mMutex); + if (!mDestination) { + return; + } + + if (mDestination->IsOnOwningThread()) { + mDestination->RequestClose(NS_ERROR_ABORT); + mDestination = nullptr; + return; + } + + RefPtr runnable = + new HelperRunnable(this, HelperRunnable::eCloseDestination); + mDestination->DispatchRunnable(runnable.forget()); +} + +NS_IMPL_ADDREF(IPCStreamDestination::DelayedStartInputStream); +NS_IMPL_RELEASE(IPCStreamDestination::DelayedStartInputStream); + +NS_INTERFACE_MAP_BEGIN(IPCStreamDestination::DelayedStartInputStream) + NS_INTERFACE_MAP_ENTRY(nsIAsyncInputStream) + NS_INTERFACE_MAP_ENTRY(nsISearchableInputStream) + NS_INTERFACE_MAP_ENTRY(nsICloneableInputStream) + NS_INTERFACE_MAP_ENTRY(nsIBufferedInputStream) + NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsIInputStream, nsIAsyncInputStream) + NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIAsyncInputStream) +NS_INTERFACE_MAP_END + +// ---------------------------------------------------------------------------- +// IPCStreamDestination + IPCStreamDestination::IPCStreamDestination() + : mOwningThread(NS_GetCurrentThread()) + , mDelayedStart(false) { } @@ -45,13 +287,41 @@ IPCStreamDestination::Initialize() return NS_OK; } +void +IPCStreamDestination::SetDelayedStart(bool aDelayedStart) +{ + mDelayedStart = aDelayedStart; +} + already_AddRefed IPCStreamDestination::TakeReader() { MOZ_ASSERT(mReader); + MOZ_ASSERT(!mDelayedStartInputStream); + + if (mDelayedStart) { + mDelayedStartInputStream = + new DelayedStartInputStream(this, mReader.forget()); + RefPtr inputStream = mDelayedStartInputStream; + return inputStream.forget(); + } + return mReader.forget(); } +bool +IPCStreamDestination::IsOnOwningThread() const +{ + return mOwningThread == NS_GetCurrentThread(); +} + +void +IPCStreamDestination::DispatchRunnable(already_AddRefed&& aRunnable) +{ + nsCOMPtr runnable = aRunnable; + mOwningThread->Dispatch(runnable.forget(), NS_DISPATCH_NORMAL); +} + void IPCStreamDestination::ActorDestroyed() { @@ -62,6 +332,11 @@ IPCStreamDestination::ActorDestroyed() // effect. This just aborts the writer in the case where the child process // crashes. mWriter->CloseWithStatus(NS_ERROR_ABORT); + + if (mDelayedStartInputStream) { + mDelayedStartInputStream->DestinationShutdown(); + mDelayedStartInputStream = nullptr; + } } void diff --git a/ipc/glue/IPCStreamDestination.h b/ipc/glue/IPCStreamDestination.h index 20c44f359d77..97c165f44f56 100644 --- a/ipc/glue/IPCStreamDestination.h +++ b/ipc/glue/IPCStreamDestination.h @@ -31,9 +31,18 @@ public: static IPCStreamDestination* Cast(PParentToChildStreamChild* aActor); - virtual already_AddRefed + void + SetDelayedStart(bool aDelayedStart); + + already_AddRefed TakeReader(); + bool + IsOnOwningThread() const; + + void + DispatchRunnable(already_AddRefed&& aRunnable); + protected: IPCStreamDestination(); virtual ~IPCStreamDestination(); @@ -51,16 +60,37 @@ protected: void CloseReceived(nsresult aRv); +#ifdef DEBUG + bool + HasDelayedStart() const + { + return mDelayedStart; + } +#endif + // These methods will be implemented by the actor. + virtual void + StartReading() = 0; + virtual void RequestClose(nsresult aRv) = 0; virtual void TerminateDestination() = 0; +private: nsCOMPtr mReader; nsCOMPtr mWriter; + + // This is created by TakeReader() if we need to delay the reading of data. + // We keep a reference to the stream in order to inform it when the actor goes + // away. If that happens, the reading of data will not be possible anymore. + class DelayedStartInputStream; + RefPtr mDelayedStartInputStream; + + nsCOMPtr mOwningThread; + bool mDelayedStart; }; } // namespace ipc diff --git a/ipc/glue/IPCStreamParent.cpp b/ipc/glue/IPCStreamParent.cpp index ec7e8e8e3717..99aa6ea50ac6 100644 --- a/ipc/glue/IPCStreamParent.cpp +++ b/ipc/glue/IPCStreamParent.cpp @@ -45,6 +45,13 @@ public: ActorDestroyed(); } + IPCResult + RecvStartReading() override + { + Start(); + return IPC_OK(); + } + IPCResult RecvRequestClose(const nsresult& aRv) override { @@ -167,6 +174,13 @@ private: // IPCStreamDestination methods + void + StartReading() override + { + MOZ_ASSERT(HasDelayedStart()); + Unused << SendStartReading(); + } + void RequestClose(nsresult aRv) override { diff --git a/ipc/glue/IPCStreamUtils.cpp b/ipc/glue/IPCStreamUtils.cpp index f1f27a275980..7518e3812edd 100644 --- a/ipc/glue/IPCStreamUtils.cpp +++ b/ipc/glue/IPCStreamUtils.cpp @@ -131,7 +131,8 @@ SerializeInputStreamWithFdsParent(nsIIPCSerializableInputStream* aStream, template bool -SerializeInputStream(nsIInputStream* aStream, IPCStream& aValue, M* aManager) +SerializeInputStream(nsIInputStream* aStream, IPCStream& aValue, M* aManager, + bool aDelayedStart) { MOZ_ASSERT(aStream); MOZ_ASSERT(aManager); @@ -165,6 +166,7 @@ SerializeInputStream(nsIInputStream* aStream, IPCStream& aValue, M* aManager) MOZ_ASSERT(asyncStream); IPCRemoteStream remoteStream; + remoteStream.delayedStart() = aDelayedStart; remoteStream.stream() = IPCStreamSource::Create(asyncStream, aManager); aValue = remoteStream; @@ -175,7 +177,8 @@ template bool SerializeInputStreamChild(nsIInputStream* aStream, M* aManager, IPCStream* aValue, - OptionalIPCStream* aOptionalValue) + OptionalIPCStream* aOptionalValue, + bool aDelayedStart) { MOZ_ASSERT(aStream); MOZ_ASSERT(aManager); @@ -202,17 +205,18 @@ SerializeInputStreamChild(nsIInputStream* aStream, M* aManager, } if (aValue) { - return SerializeInputStream(aStream, *aValue, aManager); + return SerializeInputStream(aStream, *aValue, aManager, aDelayedStart); } - return SerializeInputStream(aStream, *aOptionalValue, aManager); + return SerializeInputStream(aStream, *aOptionalValue, aManager, aDelayedStart); } template bool SerializeInputStreamParent(nsIInputStream* aStream, M* aManager, IPCStream* aValue, - OptionalIPCStream* aOptionalValue) + OptionalIPCStream* aOptionalValue, + bool aDelayedStart) { MOZ_ASSERT(aStream); MOZ_ASSERT(aManager); @@ -236,14 +240,14 @@ SerializeInputStreamParent(nsIInputStream* aStream, M* aManager, } if (aValue) { - return SerializeInputStream(aStream, *aValue, aManager); + return SerializeInputStream(aStream, *aValue, aManager, aDelayedStart); } - return SerializeInputStream(aStream, *aOptionalValue, aManager); + return SerializeInputStream(aStream, *aOptionalValue, aManager, aDelayedStart); } void -CleanupIPCStream(IPCStream& aValue, bool aConsumedByIPC) +CleanupIPCStream(IPCStream& aValue, bool aConsumedByIPC, bool aDelayedStart) { if (aValue.type() == IPCStream::T__None) { return; @@ -309,24 +313,29 @@ CleanupIPCStream(IPCStream& aValue, bool aConsumedByIPC) MOZ_ASSERT(source); + // If the source stream has not been taken to be sent to the other side, we + // can destroy it. if (!aConsumedByIPC) { source->StartDestroy(); return; } - // If the source stream was taken to be sent to the other side, then we need - // to start it before forgetting about it. - source->Start(); + if (!aDelayedStart) { + // If we don't need to do a delayedStart, we start it now. Otherwise, the + // Start() will be called at the first use by the + // IPCStreamDestination::DelayedStartInputStream. + source->Start(); + } } void -CleanupIPCStream(OptionalIPCStream& aValue, bool aConsumedByIPC) +CleanupIPCStream(OptionalIPCStream& aValue, bool aConsumedByIPC, bool aDelayedStart) { if (aValue.type() == OptionalIPCStream::Tvoid_t) { return; } - CleanupIPCStream(aValue.get_IPCStream(), aConsumedByIPC); + CleanupIPCStream(aValue.get_IPCStream(), aConsumedByIPC, aDelayedStart); } // Returns false if the serialization should not proceed. This means that the @@ -356,19 +365,21 @@ already_AddRefed DeserializeIPCStream(const IPCStream& aValue) { if (aValue.type() == IPCStream::TIPCRemoteStream) { - const IPCRemoteStreamType& remoteInputStream = - aValue.get_IPCRemoteStream().stream(); - if (remoteInputStream.type() == IPCRemoteStreamType::TPChildToParentStreamParent) { - auto sendStream = - IPCStreamDestination::Cast(remoteInputStream.get_PChildToParentStreamParent()); - return sendStream->TakeReader(); + const IPCRemoteStream& remoteStream = aValue.get_IPCRemoteStream(); + const IPCRemoteStreamType& remoteStreamType = remoteStream.stream(); + IPCStreamDestination* destinationStream; + + if (remoteStreamType.type() == IPCRemoteStreamType::TPChildToParentStreamParent) { + destinationStream = + IPCStreamDestination::Cast(remoteStreamType.get_PChildToParentStreamParent()); + } else { + MOZ_ASSERT(remoteStreamType.type() == IPCRemoteStreamType::TPParentToChildStreamChild); + destinationStream = + IPCStreamDestination::Cast(remoteStreamType.get_PParentToChildStreamChild()); } - MOZ_ASSERT(remoteInputStream.type() == IPCRemoteStreamType::TPParentToChildStreamChild); - - auto sendStream = - IPCStreamDestination::Cast(remoteInputStream.get_PParentToChildStreamChild()); - return sendStream->TakeReader(); + destinationStream->SetDelayedStart(remoteStream.delayedStart()); + return destinationStream->TakeReader(); } // Note, we explicitly do not support deserializing the PChildToParentStream actor on @@ -419,27 +430,30 @@ DeserializeIPCStream(const OptionalIPCStream& aValue) return DeserializeIPCStream(aValue.get_IPCStream()); } -AutoIPCStream::AutoIPCStream() +AutoIPCStream::AutoIPCStream(bool aDelayedStart) : mInlineValue(void_t()) , mValue(nullptr) , mOptionalValue(&mInlineValue) , mTaken(false) + , mDelayedStart(aDelayedStart) { } -AutoIPCStream::AutoIPCStream(IPCStream& aTarget) +AutoIPCStream::AutoIPCStream(IPCStream& aTarget, bool aDelayedStart) : mInlineValue(void_t()) , mValue(&aTarget) , mOptionalValue(nullptr) , mTaken(false) + , mDelayedStart(aDelayedStart) { } -AutoIPCStream::AutoIPCStream(OptionalIPCStream& aTarget) +AutoIPCStream::AutoIPCStream(OptionalIPCStream& aTarget, bool aDelayedStart) : mInlineValue(void_t()) , mValue(nullptr) , mOptionalValue(&aTarget) , mTaken(false) + , mDelayedStart(aDelayedStart) { *mOptionalValue = void_t(); } @@ -448,9 +462,9 @@ AutoIPCStream::~AutoIPCStream() { MOZ_ASSERT(mValue || mOptionalValue); if (mValue && IsSet()) { - CleanupIPCStream(*mValue, mTaken); + CleanupIPCStream(*mValue, mTaken, mDelayedStart); } else { - CleanupIPCStream(*mOptionalValue, mTaken); + CleanupIPCStream(*mOptionalValue, mTaken, mDelayedStart); } } @@ -468,7 +482,8 @@ AutoIPCStream::Serialize(nsIInputStream* aStream, dom::nsIContentChild* aManager return true; } - if (!SerializeInputStreamChild(aStream, aManager, mValue, mOptionalValue)) { + if (!SerializeInputStreamChild(aStream, aManager, mValue, mOptionalValue, + mDelayedStart)) { MOZ_CRASH("IPCStream creation failed!"); } @@ -495,7 +510,8 @@ AutoIPCStream::Serialize(nsIInputStream* aStream, PBackgroundChild* aManager) return true; } - if (!SerializeInputStreamChild(aStream, aManager, mValue, mOptionalValue)) { + if (!SerializeInputStreamChild(aStream, aManager, mValue, mOptionalValue, + mDelayedStart)) { MOZ_CRASH("IPCStream creation failed!"); } @@ -523,7 +539,8 @@ AutoIPCStream::Serialize(nsIInputStream* aStream, return true; } - if (!SerializeInputStreamParent(aStream, aManager, mValue, mOptionalValue)) { + if (!SerializeInputStreamParent(aStream, aManager, mValue, mOptionalValue, + mDelayedStart)) { return false; } @@ -550,7 +567,8 @@ AutoIPCStream::Serialize(nsIInputStream* aStream, PBackgroundParent* aManager) return true; } - if (!SerializeInputStreamParent(aStream, aManager, mValue, mOptionalValue)) { + if (!SerializeInputStreamParent(aStream, aManager, mValue, mOptionalValue, + mDelayedStart)) { return false; } diff --git a/ipc/glue/IPCStreamUtils.h b/ipc/glue/IPCStreamUtils.h index 054f7c02b7c8..cfd3d649299e 100644 --- a/ipc/glue/IPCStreamUtils.h +++ b/ipc/glue/IPCStreamUtils.h @@ -126,6 +126,7 @@ class AutoIPCStream final IPCStream* mValue; OptionalIPCStream* mOptionalValue; bool mTaken; + bool mDelayedStart; bool IsSet() const; @@ -133,16 +134,17 @@ class AutoIPCStream final public: // Implicitly create an OptionalIPCStream value. Either // TakeValue() or TakeOptionalValue() can be used. - AutoIPCStream(); + explicit AutoIPCStream(bool aDelayedStart = false); // Wrap an existing IPCStream. Only TakeValue() may be // used. If a nullptr nsIInputStream is passed to SerializeOrSend() then // a crash will be forced. - explicit AutoIPCStream(IPCStream& aTarget); + explicit AutoIPCStream(IPCStream& aTarget, bool aDelayedStart = false); // Wrap an existing OptionalIPCStream. Either TakeValue() // or TakeOptionalValue can be used. - explicit AutoIPCStream(OptionalIPCStream& aTarget); + explicit AutoIPCStream(OptionalIPCStream& aTarget, + bool aDelayedStart = false); ~AutoIPCStream(); diff --git a/ipc/glue/PChildToParentStream.ipdl b/ipc/glue/PChildToParentStream.ipdl index bc789a73dfe3..ee81822371d6 100644 --- a/ipc/glue/PChildToParentStream.ipdl +++ b/ipc/glue/PChildToParentStream.ipdl @@ -20,6 +20,14 @@ parent: async Close(nsresult aRv); child: + // The remote stream can be used in 2 ways: it can start receiving data + // immediately after the creation of the child actor, or it can wait until + // the child stream is actually used. This second configuration is enabled by + // passing 'true' to delayedStart in AutoIPCStream CTOR. + // If we are delaying the reading, at the first use of the remote stream, we + // must activate the sending of data. This happens by calling this method. + async StartReading(); + // The parent side has hit an error condition and has requested the child // actor issue a Close() message. The close must be initiated by the child // to avoid racing with an in-flight Buffer() message. diff --git a/ipc/glue/PParentToChildStream.ipdl b/ipc/glue/PParentToChildStream.ipdl index c5e81e279477..dae753bcbdc1 100644 --- a/ipc/glue/PParentToChildStream.ipdl +++ b/ipc/glue/PParentToChildStream.ipdl @@ -20,6 +20,14 @@ child: async Close(nsresult aRv); parent: + // The remote stream can be used in 2 ways: it can start receiving data + // immediately after the creation of the child actor, or it can wait until + // the child stream is actually used. This second configuration is enabled by + // passing 'true' to delayedStart in AutoIPCStream CTOR. + // If we are delaying the reading, at the first use of the remote stream, we + // must activate the sending of data. This happens by calling this method. + async StartReading(); + // The parent side has hit an error condition and has requested the child // actor issue a Close() message. The close must be initiated by the child // to avoid racing with an in-flight Buffer() message.