summaryrefslogtreecommitdiffstats
path: root/jingle
diff options
context:
space:
mode:
authorhclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-27 13:25:40 +0000
committerhclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-27 13:25:40 +0000
commit87185ec69cf9f943674e179ebe92ff2a063e37ce (patch)
treed83f0dda670663283f8a71c71d34cc02b70aff90 /jingle
parentaeebebb6c151a7bd90254470aaabded7511fb752 (diff)
downloadchromium_src-87185ec69cf9f943674e179ebe92ff2a063e37ce.zip
chromium_src-87185ec69cf9f943674e179ebe92ff2a063e37ce.tar.gz
chromium_src-87185ec69cf9f943674e179ebe92ff2a063e37ce.tar.bz2
Drop packets when io pending is received for UDP sockets.
On Windows UDP sockets will return a WOULDBLOCK but a writeable notification will never happen in libjingle code. When we receive such error in the glue code we should report a success and drop the packets. BUG=None TEST=Connect to a windows box to itself, network will be alright. Review URL: http://codereview.chromium.org/7380003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@94281 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'jingle')
-rw-r--r--jingle/glue/channel_socket_adapter.cc12
-rw-r--r--jingle/glue/channel_socket_adapter_unittest.cc14
2 files changed, 13 insertions, 13 deletions
diff --git a/jingle/glue/channel_socket_adapter.cc b/jingle/glue/channel_socket_adapter.cc
index e8e0c78..f0671b0 100644
--- a/jingle/glue/channel_socket_adapter.cc
+++ b/jingle/glue/channel_socket_adapter.cc
@@ -68,14 +68,18 @@ int TransportChannelSocketAdapter::Write(
int result;
if (channel_->writable()) {
result = channel_->SendPacket(buffer->data(), buffer_size);
- if (result < 0)
+ if (result < 0) {
result = net::MapSystemError(channel_->GetError());
+
+ // If the underlying socket returns IO pending where it shouldn't we
+ // pretend the packet is dropped and return as succeeded because no
+ // writeable callback will happen.
+ if (result == net::ERR_IO_PENDING)
+ result = net::OK;
+ }
} else {
// Channel is not writable yet.
result = net::ERR_IO_PENDING;
- }
-
- if (result == net::ERR_IO_PENDING) {
write_callback_ = callback;
write_buffer_ = buffer;
write_buffer_size_ = buffer_size;
diff --git a/jingle/glue/channel_socket_adapter_unittest.cc b/jingle/glue/channel_socket_adapter_unittest.cc
index fa4315d..8eb4d23 100644
--- a/jingle/glue/channel_socket_adapter_unittest.cc
+++ b/jingle/glue/channel_socket_adapter_unittest.cc
@@ -100,24 +100,20 @@ TEST_F(TransportChannelSocketAdapterTest, Write) {
EXPECT_EQ(kTestDataSize, result);
}
-// Verify that the message is still send if Write() is called while
-// socket is not open yet, and that the callback is called.
+// Verify that the message is still sent if Write() is called while
+// socket is not open yet. The result is the packet is lost.
TEST_F(TransportChannelSocketAdapterTest, WritePending) {
scoped_refptr<IOBuffer> buffer(new IOBuffer(kTestDataSize));
EXPECT_CALL(channel_, SendPacket(buffer->data(), kTestDataSize))
- .Times(2)
- .WillOnce(Return(SOCKET_ERROR))
- .WillOnce(Return(kTestDataSize));
+ .Times(1)
+ .WillOnce(Return(SOCKET_ERROR));
EXPECT_CALL(channel_, GetError())
.WillOnce(Return(EWOULDBLOCK));
int result = target_->Write(buffer, kTestDataSize, &callback_);
- ASSERT_EQ(net::ERR_IO_PENDING, result);
-
- channel_.SignalWritableState(&channel_);
- EXPECT_EQ(kTestDataSize, callback_result_);
+ ASSERT_EQ(net::OK, result);
}
} // namespace jingle_glue