OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "nacl_io/socket/udp_node.h" | 5 #include "nacl_io/socket/udp_node.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 #include <string.h> | 8 #include <string.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
127 virtual void Run(int32_t length_error) { | 127 virtual void Run(int32_t length_error) { |
128 AUTO_LOCK(emitter_->GetLock()); | 128 AUTO_LOCK(emitter_->GetLock()); |
129 UdpNode* stream = static_cast<UdpNode*>(emitter_->stream()); | 129 UdpNode* stream = static_cast<UdpNode*>(emitter_->stream()); |
130 if (NULL == stream) | 130 if (NULL == stream) |
131 return; | 131 return; |
132 | 132 |
133 // On successful receive we queue more input | 133 // On successful receive we queue more input |
134 if (length_error > 0) { | 134 if (length_error > 0) { |
135 Packet* packet = new Packet(filesystem()->ppapi()); | 135 Packet* packet = new Packet(filesystem()->ppapi()); |
136 packet->Copy(data_, length_error, addr_); | 136 packet->Copy(data_, length_error, addr_); |
137 filesystem()->ppapi()->ReleaseResource(addr_); | |
yzshen1
2014/08/19 18:37:29
drive-by:
Maybe we could consider "safer" ref-coun
noelallen1
2014/08/19 20:46:59
While it is possible to call Start without calling
yzshen1
2014/08/19 20:53:16
Thanks for reply!
If the completion callback is "
| |
137 emitter_->WriteRXPacket_Locked(packet); | 138 emitter_->WriteRXPacket_Locked(packet); |
138 stream->ClearStreamFlags(SSF_RECVING); | 139 stream->ClearStreamFlags(SSF_RECVING); |
139 stream->QueueInput(); | 140 stream->QueueInput(); |
140 } else { | 141 } else { |
141 stream->SetError_Locked(length_error); | 142 stream->SetError_Locked(length_error); |
142 } | 143 } |
143 } | 144 } |
144 | 145 |
145 private: | 146 private: |
146 char data_[kMaxPacketSize]; | 147 char data_[kMaxPacketSize]; |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
295 int capped_len = static_cast<int32_t>(std::min<int>(len, kMaxPacketSize)); | 296 int capped_len = static_cast<int32_t>(std::min<int>(len, kMaxPacketSize)); |
296 Packet* packet = new Packet(filesystem_->ppapi()); | 297 Packet* packet = new Packet(filesystem_->ppapi()); |
297 packet->Copy(buf, capped_len, addr); | 298 packet->Copy(buf, capped_len, addr); |
298 | 299 |
299 emitter_->WriteTXPacket_Locked(packet); | 300 emitter_->WriteTXPacket_Locked(packet); |
300 *out_len = capped_len; | 301 *out_len = capped_len; |
301 return 0; | 302 return 0; |
302 } | 303 } |
303 | 304 |
304 } // namespace nacl_io | 305 } // namespace nacl_io |
OLD | NEW |