From d513d6ea5eec4773e299d2bae17e9159cebf0446 Mon Sep 17 00:00:00 2001 From: "ukai@chromium.org" Date: Tue, 1 Jun 2010 10:22:32 +0000 Subject: Fix regression of websocket/tests/simple-stress.html Since stress-test.html tries to send 256K message, but we'll set 32K for max_pending_send_allowed in SocketStream. Thus, WebCore::SocketStreamHandle won't send full websocket frame for such large message since WebSocketJob doesn't notify OnSentData at all. Don't parse websocket frame for sending to avoid this issue for now. Also disable buffering and parsing websocket frame for receiving to fix performance regression. BUG=32018 TEST=LayoutTests/websocket/tests/stress-test.html passes Review URL: http://codereview.chromium.org/2453002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@48629 0039d316-1c4b-4281-b951-d872f2087c98 --- net/websockets/websocket_job.cc | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'net/websockets/websocket_job.cc') diff --git a/net/websockets/websocket_job.cc b/net/websockets/websocket_job.cc index c096d5c..063b3ab 100644 --- a/net/websockets/websocket_job.cc +++ b/net/websockets/websocket_job.cc @@ -174,9 +174,16 @@ bool WebSocketJob::SendData(const char* data, int len) { send_frame_handler_->AppendData(data, len); // If current buffer is sending now, this data will be sent in // SendPending() after current data was sent. + // Do not buffer sending data for now. Since + // WebCore::SocketStreamHandle controls traffic to keep number of + // pending bytes less than max_pending_send_allowed, so when sending + // larger message than max_pending_send_allowed should not be buffered. + // If we don't call OnSentData, WebCore::SocketStreamHandle would stop + // sending more data when pending data reaches max_pending_send_allowed. + // TODO(ukai): Fix this to support compression for larger message. int err = 0; if (!send_frame_handler_->GetCurrentBuffer() && - (err = send_frame_handler_->UpdateCurrentBuffer()) > 0) { + (err = send_frame_handler_->UpdateCurrentBuffer(false)) > 0) { current_buffer_ = new DrainableIOBuffer( send_frame_handler_->GetCurrentBuffer(), send_frame_handler_->GetCurrentBufferSize()); @@ -278,7 +285,9 @@ void WebSocketJob::OnReceivedData( } std::string received_data; receive_frame_handler_->AppendData(data, len); - while (receive_frame_handler_->UpdateCurrentBuffer() > 0) { + // Don't buffer receiving data for now. + // TODO(ukai): fix performance of WebSocketFrameHandler. + while (receive_frame_handler_->UpdateCurrentBuffer(false) > 0) { received_data += std::string(receive_frame_handler_->GetCurrentBuffer()->data(), receive_frame_handler_->GetCurrentBufferSize()); @@ -496,7 +505,9 @@ void WebSocketJob::SaveNextCookie() { kResponseKeySize, handshake_response_.size() - handshake_response_header_length_ - kResponseKeySize); - while (receive_frame_handler_->UpdateCurrentBuffer() > 0) { + // Don't buffer receiving data for now. + // TODO(ukai): fix performance of WebSocketFrameHandler. + while (receive_frame_handler_->UpdateCurrentBuffer(false) > 0) { received_data += std::string(receive_frame_handler_->GetCurrentBuffer()->data(), receive_frame_handler_->GetCurrentBufferSize()); @@ -596,7 +607,8 @@ void WebSocketJob::SendPending() { if (current_buffer_) return; // Current buffer is done. Try next buffer if any. - if (send_frame_handler_->UpdateCurrentBuffer() <= 0) { + // Don't buffer sending data. See comment on case OPEN in SendData(). + if (send_frame_handler_->UpdateCurrentBuffer(false) <= 0) { // No more data to send. if (state_ == CLOSING) socket_->Close(); -- cgit v1.1