summaryrefslogtreecommitdiffstats
path: root/native_client_sdk
diff options
context:
space:
mode:
authordaiweili <daiweili@suitabletech.com>2015-02-27 10:04:51 -0800
committerCommit bot <commit-bot@chromium.org>2015-02-27 18:05:17 +0000
commit83ef7da0ea36022df75770c4d0d8180d32c67b68 (patch)
tree75667423e31692252ee5eb7c488925f93aee7ba1 /native_client_sdk
parentd436ff65372dc34acc7b0974ee8ac4c0f58dd86d (diff)
downloadchromium_src-83ef7da0ea36022df75770c4d0d8180d32c67b68.zip
chromium_src-83ef7da0ea36022df75770c4d0d8180d32c67b68.tar.gz
chromium_src-83ef7da0ea36022df75770c4d0d8180d32c67b68.tar.bz2
nacl_io: Requeue UDP packets if send buffer is full
The Pepper resource (see kPluginSendBufferSlots in udp_socket_resource_base.cc) will return PP_ERROR_INPROGRESS if the send buffer is full. In that case, we should requeue packets for sending rather than discarding them. R=sbc@chromium.org Review URL: https://codereview.chromium.org/946913002 Cr-Commit-Position: refs/heads/master@{#318479}
Diffstat (limited to 'native_client_sdk')
-rw-r--r--native_client_sdk/src/libraries/nacl_io/socket/udp_node.cc16
1 files changed, 13 insertions, 3 deletions
diff --git a/native_client_sdk/src/libraries/nacl_io/socket/udp_node.cc b/native_client_sdk/src/libraries/nacl_io/socket/udp_node.cc
index c84d212..7b8bc1e 100644
--- a/native_client_sdk/src/libraries/nacl_io/socket/udp_node.cc
+++ b/native_client_sdk/src/libraries/nacl_io/socket/udp_node.cc
@@ -57,9 +57,13 @@ class UdpSendWork : public UdpWork {
if (node_->TestStreamFlags(SSF_SENDING))
return false;
- packet_ = emitter_->ReadTXPacket_Locked();
- if (NULL == packet_)
- return false;
+ // If this is a retry packet, packet_ will be already set
+ // and we don't need to dequeue from emitter_.
+ if (NULL == packet_) {
+ packet_ = emitter_->ReadTXPacket_Locked();
+ if (NULL == packet_)
+ return false;
+ }
int err = UDPInterface()->SendTo(node_->socket_resource(),
packet_->buffer(),
@@ -80,6 +84,12 @@ class UdpSendWork : public UdpWork {
AUTO_LOCK(emitter_->GetLock());
if (length_error < 0) {
+ if (length_error == PP_ERROR_INPROGRESS) {
+ // We need to retry this packet later.
+ node_->ClearStreamFlags(SSF_SENDING);
+ node_->stream()->EnqueueWork(this);
+ return;
+ }
node_->SetError_Locked(length_error);
return;
}