Backed out changeset eff866cb4c66 (bug 1668851) for browser_net-ws-filter-freetext.js failures CLOSED TREE

This commit is contained in:
Bogdan Tara 2020-10-06 13:46:20 +03:00
parent 0ddec45053
commit 8391350978
8 changed files with 39 additions and 53 deletions

View File

@ -19,7 +19,6 @@ parent:
async OnTCPClosed();
async OnDataReceived(uint8_t[] aData);
async OnUpgradeFailed(nsresult aReason);
async OnDataSent();
child:
async EnqueueOutgoingData(uint8_t[] aData);

View File

@ -3852,7 +3852,7 @@ void WebSocketChannel::DoEnqueueOutgoingMessage() {
if (!mCurrentOut) PrimeNewOutgoingMessage();
if (mCurrentOut && mConnection) {
while (mCurrentOut && mConnection) {
LOG(
("WebSocketChannel::DoEnqueueOutgoingMessage: "
"Try to send %u of hdr/copybreak and %u of data\n",
@ -3862,6 +3862,10 @@ void WebSocketChannel::DoEnqueueOutgoingMessage() {
mHdrOut, mHdrOutSize, (uint8_t*)mCurrentOut->BeginReading(),
mCurrentOut->Length());
if (rv == NS_BASE_STREAM_WOULD_BLOCK) {
return;
}
LOG(("WebSocketChannel::DoEnqueueOutgoingMessage: rv %" PRIx32 "\n",
static_cast<uint32_t>(rv)));
@ -3869,6 +3873,14 @@ void WebSocketChannel::DoEnqueueOutgoingMessage() {
AbortSession(rv);
return;
}
if (!mStopped) {
mTargetThread->Dispatch(
new CallAcknowledge(this, mCurrentOut->OrigLength()),
NS_DISPATCH_NORMAL);
}
DeleteCurrentOutGoingMessage();
PrimeNewOutgoingMessage();
}
if (mReleaseOnTransmit) ReleaseSession();
@ -3917,17 +3929,8 @@ WebSocketChannel::OnDataReceived(uint8_t* aData, uint32_t aCount) {
}
NS_IMETHODIMP
WebSocketChannel::OnDataSent() {
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
if (!mStopped) {
mTargetThread->Dispatch(
new CallAcknowledge(this, mCurrentOut->OrigLength()),
NS_DISPATCH_NORMAL);
}
DeleteCurrentOutGoingMessage();
PrimeNewOutgoingMessage();
WebSocketChannel::OnReadyToSendData() {
DoEnqueueOutgoingMessage();
return NS_OK;
}

View File

@ -175,12 +175,8 @@ WebSocketConnectionChild::OnDataReceived(uint8_t* aData, uint32_t aCount) {
}
NS_IMETHODIMP
WebSocketConnectionChild::OnDataSent() {
LOG(("WebSocketConnectionChild::OnDataSent %p\n", this));
if (CanSend()) {
Unused << SendOnDataSent();
}
WebSocketConnectionChild::OnReadyToSendData() {
// TODO: implement flow control between parent and socket process.
return NS_OK;
}

View File

@ -130,22 +130,6 @@ mozilla::ipc::IPCResult WebSocketConnectionParent::RecvOnDataReceived(
return IPC_OK();
}
mozilla::ipc::IPCResult WebSocketConnectionParent::RecvOnDataSent() {
LOG(("WebSocketConnectionParent::RecvOnDataSent %p\n", this));
MOZ_ASSERT(mEventTarget);
RefPtr<WebSocketConnectionParent> self = this;
auto task = [self{std::move(self)}]() {
if (self->mListener) {
Unused << self->mListener->OnDataSent();
}
};
DispatchHelper(mEventTarget, "WebSocketConnectionParent::RecvOnDataSent",
std::move(task));
return IPC_OK();
}
void WebSocketConnectionParent::ActorDestroy(ActorDestroyReason aWhy) {
LOG(("WebSocketConnectionParent::ActorDestroy %p aWhy=%d\n", this, aWhy));
if (!mClosed) {

View File

@ -45,7 +45,6 @@ class WebSocketConnectionParent final : public PWebSocketConnectionParent,
mozilla::ipc::IPCResult RecvOnTCPClosed();
mozilla::ipc::IPCResult RecvOnDataReceived(nsTArray<uint8_t>&& aData);
mozilla::ipc::IPCResult RecvOnUpgradeFailed(const nsresult& aReason);
mozilla::ipc::IPCResult RecvOnDataSent();
void ActorDestroy(ActorDestroyReason aWhy) override;

View File

@ -73,8 +73,7 @@ interface nsIWebSocketConnectionListener : nsISupports
in unsigned long dataLength);
/**
* Called to inform the listener that the outgoing data is written
* to socket.
* Called to inform the listener that the outgoing data is ready to write.
*/
void onDataSent();
void onReadyToSendData();
};

View File

@ -20,7 +20,8 @@ nsWebSocketConnection::nsWebSocketConnection(
mSocketIn(aInputStream),
mSocketOut(aOutputStream),
mWriteOffset(0),
mStartReadingCalled(false) {
mStartReadingCalled(false),
mOutputStreamBlocked(false) {
LOG(("nsWebSocketConnection ctor %p\n", this));
}
@ -79,12 +80,12 @@ nsWebSocketConnection::Close() {
nsresult nsWebSocketConnection::EnqueueOutputData(nsTArray<uint8_t>&& aData) {
MOZ_ASSERT(mEventTarget->IsOnCurrentThread());
if (!mSocketOut) {
return NS_ERROR_NOT_AVAILABLE;
mOutputQueue.emplace_back(std::move(aData));
if (mSocketOut) {
mSocketOut->AsyncWait(this, 0, 0, mEventTarget);
}
mOutputQueue.emplace_back(std::move(aData));
OnOutputStreamReady(mSocketOut);
return NS_OK;
}
@ -96,16 +97,19 @@ nsWebSocketConnection::EnqueueOutputData(const uint8_t* aHdrBuf,
LOG(("nsWebSocketConnection::EnqueueOutputData %p\n", this));
MOZ_ASSERT(mEventTarget->IsOnCurrentThread());
if (!mSocketOut) {
return NS_ERROR_NOT_AVAILABLE;
}
nsTArray<uint8_t> data;
data.AppendElements(aHdrBuf, aHdrBufLength);
data.AppendElements(aPayloadBuf, aPayloadBufLength);
mOutputQueue.emplace_back(std::move(data));
OnOutputStreamReady(mSocketOut);
if (mSocketOut) {
mSocketOut->AsyncWait(this, 0, 0, mEventTarget);
}
if (mOutputStreamBlocked) {
return NS_BASE_STREAM_WOULD_BLOCK;
}
return NS_OK;
}
@ -216,6 +220,8 @@ nsWebSocketConnection::OnOutputStreamReady(nsIAsyncOutputStream* aStream) {
return NS_OK;
}
mOutputStreamBlocked = false;
while (!mOutputQueue.empty()) {
const OutputData& data = mOutputQueue.front();
@ -231,6 +237,7 @@ nsWebSocketConnection::OnOutputStreamReady(nsIAsyncOutputStream* aStream) {
if (rv == NS_BASE_STREAM_WOULD_BLOCK) {
mSocketOut->AsyncWait(this, 0, 0, mEventTarget);
mOutputStreamBlocked = true;
return NS_OK;
}
@ -246,12 +253,10 @@ nsWebSocketConnection::OnOutputStreamReady(nsIAsyncOutputStream* aStream) {
if (toWrite == wrote) {
mWriteOffset = 0;
mOutputQueue.pop_front();
Unused << mListener->OnDataSent();
} else {
mSocketOut->AsyncWait(this, 0, 0, mEventTarget);
return NS_OK;
}
}
Unused << mListener->OnReadyToSendData();
return NS_OK;
}

View File

@ -60,6 +60,7 @@ class nsWebSocketConnection : public nsIWebSocketConnection,
size_t mWriteOffset;
std::list<OutputData> mOutputQueue;
bool mStartReadingCalled;
bool mOutputStreamBlocked;
};
} // namespace net