Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(369)

Side by Side Diff: native_client_sdk/src/libraries/nacl_io/socket/tcp_node.cc

Issue 349703003: [NaCl SDK] Add some more logging to nacl_io. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix linux host build Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/ossocket.h" 5 #include "nacl_io/ossocket.h"
6 #ifdef PROVIDES_SOCKET_API 6 #ifdef PROVIDES_SOCKET_API
7 7
8 #include <assert.h> 8 #include <assert.h>
9 #include <errno.h> 9 #include <errno.h>
10 #include <string.h> 10 #include <string.h>
11 #include <algorithm> 11 #include <algorithm>
12 12
13 #include "nacl_io/kernel_handle.h" 13 #include "nacl_io/kernel_handle.h"
14 #include "nacl_io/log.h"
14 #include "nacl_io/pepper_interface.h" 15 #include "nacl_io/pepper_interface.h"
15 #include "nacl_io/socket/tcp_node.h" 16 #include "nacl_io/socket/tcp_node.h"
16 #include "nacl_io/stream/stream_fs.h" 17 #include "nacl_io/stream/stream_fs.h"
17 18
18 namespace { 19 namespace {
19 const size_t kMaxPacketSize = 65536; 20 const size_t kMaxPacketSize = 65536;
20 const size_t kDefaultFifoSize = kMaxPacketSize * 8; 21 const size_t kDefaultFifoSize = kMaxPacketSize * 8;
21 } 22 }
22 23
23 namespace nacl_io { 24 namespace nacl_io {
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 void TcpNode::Destroy() { 281 void TcpNode::Destroy() {
281 emitter_->DetachStream(); 282 emitter_->DetachStream();
282 SocketNode::Destroy(); 283 SocketNode::Destroy();
283 } 284 }
284 285
285 Error TcpNode::Init(int open_flags) { 286 Error TcpNode::Init(int open_flags) {
286 Error err = SocketNode::Init(open_flags); 287 Error err = SocketNode::Init(open_flags);
287 if (err != 0) 288 if (err != 0)
288 return err; 289 return err;
289 290
290 if (TCPInterface() == NULL) 291 if (TCPInterface() == NULL) {
292 LOG_ERROR("Got NULL interface: TCP");
291 return EACCES; 293 return EACCES;
294 }
292 295
293 if (socket_resource_ != 0) { 296 if (socket_resource_ != 0) {
294 // TCP sockets that are contructed with an existing socket_resource_ 297 // TCP sockets that are contructed with an existing socket_resource_
295 // are those that generated from calls to Accept() and therefore are 298 // are those that generated from calls to Accept() and therefore are
296 // already connected. 299 // already connected.
297 remote_addr_ = TCPInterface()->GetRemoteAddress(socket_resource_); 300 remote_addr_ = TCPInterface()->GetRemoteAddress(socket_resource_);
298 ConnectDone_Locked(); 301 ConnectDone_Locked();
299 } else { 302 } else {
300 socket_resource_ = 303 socket_resource_ =
301 TCPInterface()->Create(filesystem_->ppapi()->GetInstance()); 304 TCPInterface()->Create(filesystem_->ppapi()->GetInstance());
302 if (0 == socket_resource_) 305 if (0 == socket_resource_) {
306 LOG_ERROR("Unable to create TCP resource.");
303 return EACCES; 307 return EACCES;
308 }
304 SetStreamFlags(SSF_CAN_CONNECT); 309 SetStreamFlags(SSF_CAN_CONNECT);
305 } 310 }
306 311
307 return 0; 312 return 0;
308 } 313 }
309 314
310 EventEmitter* TcpNode::GetEventEmitter() { 315 EventEmitter* TcpNode::GetEventEmitter() {
311 return emitter_.get(); 316 return emitter_.get();
312 } 317 }
313 318
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 } 481 }
477 482
478 ConnectDone_Locked(); 483 ConnectDone_Locked();
479 return 0; 484 return 0;
480 } 485 }
481 486
482 Error TcpNode::Shutdown(int how) { 487 Error TcpNode::Shutdown(int how) {
483 AUTO_LOCK(node_lock_); 488 AUTO_LOCK(node_lock_);
484 if (!IsConnected()) 489 if (!IsConnected())
485 return ENOTCONN; 490 return ENOTCONN;
491
486 { 492 {
487 AUTO_LOCK(emitter_->GetLock()); 493 AUTO_LOCK(emitter_->GetLock());
488 emitter_->SetError_Locked(); 494 emitter_->SetError_Locked();
489 } 495 }
490 return 0; 496 return 0;
491 } 497 }
492 498
493 void TcpNode::ConnectDone_Locked() { 499 void TcpNode::ConnectDone_Locked() {
494 local_addr_ = TCPInterface()->GetLocalAddress(socket_resource_); 500 local_addr_ = TCPInterface()->GetLocalAddress(socket_resource_);
495 501
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
550 assert(emitter_.get()); 556 assert(emitter_.get());
551 if (emitter_->GetError_Locked()) 557 if (emitter_->GetError_Locked())
552 return EPIPE; 558 return EPIPE;
553 *out_len = emitter_->WriteOut_Locked((char*)buf, len); 559 *out_len = emitter_->WriteOut_Locked((char*)buf, len);
554 return 0; 560 return 0;
555 } 561 }
556 562
557 } // namespace nacl_io 563 } // namespace nacl_io
558 564
559 #endif // PROVIDES_SOCKET_API 565 #endif // PROVIDES_SOCKET_API
OLDNEW
« no previous file with comments | « native_client_sdk/src/libraries/nacl_io/log.h ('k') | native_client_sdk/src/libraries/nacl_io/socket/udp_node.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698