diff options
-rw-r--r-- | native_client_sdk/src/libraries/nacl_io/socket/udp_node.cc | 16 |
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; } |