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

Side by Side Diff: webrtc/p2p/base/port.h

Issue 1371623003: Delete a connection only if it has timed out on writing and not receiving for 10 seconds. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Rename a test Created 5 years, 2 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
« no previous file with comments | « webrtc/p2p/base/p2ptransportchannel_unittest.cc ('k') | webrtc/p2p/base/port.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 extern const char UDP_PROTOCOL_NAME[]; 43 extern const char UDP_PROTOCOL_NAME[];
44 extern const char TCP_PROTOCOL_NAME[]; 44 extern const char TCP_PROTOCOL_NAME[];
45 extern const char SSLTCP_PROTOCOL_NAME[]; 45 extern const char SSLTCP_PROTOCOL_NAME[];
46 46
47 // RFC 6544, TCP candidate encoding rules. 47 // RFC 6544, TCP candidate encoding rules.
48 extern const int DISCARD_PORT; 48 extern const int DISCARD_PORT;
49 extern const char TCPTYPE_ACTIVE_STR[]; 49 extern const char TCPTYPE_ACTIVE_STR[];
50 extern const char TCPTYPE_PASSIVE_STR[]; 50 extern const char TCPTYPE_PASSIVE_STR[];
51 extern const char TCPTYPE_SIMOPEN_STR[]; 51 extern const char TCPTYPE_SIMOPEN_STR[];
52 52
53 // If a connection does not receive anything for this long, it is considered 53 // The minimum time we will wait before destroying a connection after creating
54 // dead. 54 // it.
55 const uint32 DEAD_CONNECTION_RECEIVE_TIMEOUT = 30 * 1000; // 30 seconds. 55 const uint32 MIN_CONNECTION_LIFETIME = 10 * 1000; // 10 seconds.
56 56
57 // The timeout duration when a connection does not receive anything. 57 // The timeout duration when a connection does not receive anything.
58 const uint32 WEAK_CONNECTION_RECEIVE_TIMEOUT = 2500; // 2.5 seconds 58 const uint32 WEAK_CONNECTION_RECEIVE_TIMEOUT = 2500; // 2.5 seconds
59 59
60 // The length of time we wait before timing out writability on a connection. 60 // The length of time we wait before timing out writability on a connection.
61 const uint32 CONNECTION_WRITE_TIMEOUT = 15 * 1000; // 15 seconds 61 const uint32 CONNECTION_WRITE_TIMEOUT = 15 * 1000; // 15 seconds
62 62
63 // The length of time we wait before we become unwritable. 63 // The length of time we wait before we become unwritable.
64 const uint32 CONNECTION_WRITE_CONNECT_TIMEOUT = 5 * 1000; // 5 seconds 64 const uint32 CONNECTION_WRITE_CONNECT_TIMEOUT = 5 * 1000; // 5 seconds
65 65
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 STATE_WRITE_TIMEOUT = 3, // we have had a large number of ping failures 428 STATE_WRITE_TIMEOUT = 3, // we have had a large number of ping failures
429 }; 429 };
430 430
431 WriteState write_state() const { return write_state_; } 431 WriteState write_state() const { return write_state_; }
432 bool writable() const { return write_state_ == STATE_WRITABLE; } 432 bool writable() const { return write_state_ == STATE_WRITABLE; }
433 bool receiving() const { return receiving_; } 433 bool receiving() const { return receiving_; }
434 434
435 // Determines whether the connection has finished connecting. This can only 435 // Determines whether the connection has finished connecting. This can only
436 // be false for TCP connections. 436 // be false for TCP connections.
437 bool connected() const { return connected_; } 437 bool connected() const { return connected_; }
438 438 bool weak() const { return !(writable() && receiving() && connected()); }
439 bool Weak() const { return !(writable() && receiving() && connected()); } 439 bool active() const {
440 // TODO(honghaiz): Move from using |write_state_| to using |pruned_|.
441 return write_state_ != STATE_WRITE_TIMEOUT;
442 }
443 // A connection is dead if it can be safely deleted.
444 bool dead(uint32 now) const;
440 445
441 // Estimate of the round-trip time over this connection. 446 // Estimate of the round-trip time over this connection.
442 uint32 rtt() const { return rtt_; } 447 uint32 rtt() const { return rtt_; }
443 448
444 size_t sent_total_bytes(); 449 size_t sent_total_bytes();
445 size_t sent_bytes_second(); 450 size_t sent_bytes_second();
446 // Used to track how many packets are discarded in the application socket due 451 // Used to track how many packets are discarded in the application socket due
447 // to errors. 452 // to errors.
448 size_t sent_discarded_packets(); 453 size_t sent_discarded_packets();
449 size_t sent_total_packets(); 454 size_t sent_total_packets();
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
565 StunMessage* response); 570 StunMessage* response);
566 void OnConnectionRequestTimeout(ConnectionRequest* req); 571 void OnConnectionRequestTimeout(ConnectionRequest* req);
567 void OnConnectionRequestSent(ConnectionRequest* req); 572 void OnConnectionRequestSent(ConnectionRequest* req);
568 573
569 // Changes the state and signals if necessary. 574 // Changes the state and signals if necessary.
570 void set_write_state(WriteState value); 575 void set_write_state(WriteState value);
571 void set_receiving(bool value); 576 void set_receiving(bool value);
572 void set_state(State state); 577 void set_state(State state);
573 void set_connected(bool value); 578 void set_connected(bool value);
574 579
575 // Checks if this connection is useless, and hence, should be destroyed.
576 void CheckTimeout();
577
578 void OnMessage(rtc::Message *pmsg); 580 void OnMessage(rtc::Message *pmsg);
579 581
580 Port* port_; 582 Port* port_;
581 size_t local_candidate_index_; 583 size_t local_candidate_index_;
582 Candidate remote_candidate_; 584 Candidate remote_candidate_;
583 WriteState write_state_; 585 WriteState write_state_;
584 bool receiving_; 586 bool receiving_;
585 bool connected_; 587 bool connected_;
586 bool pruned_; 588 bool pruned_;
587 // By default |use_candidate_attr_| flag will be true, 589 // By default |use_candidate_attr_| flag will be true,
(...skipping 20 matching lines...) Expand all
608 uint32 sent_packets_total_; 610 uint32 sent_packets_total_;
609 611
610 private: 612 private:
611 void MaybeAddPrflxCandidate(ConnectionRequest* request, 613 void MaybeAddPrflxCandidate(ConnectionRequest* request,
612 StunMessage* response); 614 StunMessage* response);
613 615
614 bool reported_; 616 bool reported_;
615 State state_; 617 State state_;
616 // Time duration to switch from receiving to not receiving. 618 // Time duration to switch from receiving to not receiving.
617 uint32 receiving_timeout_; 619 uint32 receiving_timeout_;
620 uint32 time_created_ms_;
618 621
619 friend class Port; 622 friend class Port;
620 friend class ConnectionRequest; 623 friend class ConnectionRequest;
621 }; 624 };
622 625
623 // ProxyConnection defers all the interesting work to the port 626 // ProxyConnection defers all the interesting work to the port
624 class ProxyConnection : public Connection { 627 class ProxyConnection : public Connection {
625 public: 628 public:
626 ProxyConnection(Port* port, size_t index, const Candidate& candidate); 629 ProxyConnection(Port* port, size_t index, const Candidate& candidate);
627 630
628 virtual int Send(const void* data, size_t size, 631 virtual int Send(const void* data, size_t size,
629 const rtc::PacketOptions& options); 632 const rtc::PacketOptions& options);
630 virtual int GetError() { return error_; } 633 virtual int GetError() { return error_; }
631 634
632 private: 635 private:
633 int error_; 636 int error_;
634 }; 637 };
635 638
636 } // namespace cricket 639 } // namespace cricket
637 640
638 #endif // WEBRTC_P2P_BASE_PORT_H_ 641 #endif // WEBRTC_P2P_BASE_PORT_H_
OLDNEW
« no previous file with comments | « webrtc/p2p/base/p2ptransportchannel_unittest.cc ('k') | webrtc/p2p/base/port.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698