OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2012 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 13 matching lines...) Expand all Loading... | |
24 static size_t kMaxQueuedSendDataBytes = 16 * 1024 * 1024; | 24 static size_t kMaxQueuedSendDataBytes = 16 * 1024 * 1024; |
25 | 25 |
26 enum { | 26 enum { |
27 MSG_CHANNELREADY, | 27 MSG_CHANNELREADY, |
28 }; | 28 }; |
29 | 29 |
30 bool SctpSidAllocator::AllocateSid(rtc::SSLRole role, int* sid) { | 30 bool SctpSidAllocator::AllocateSid(rtc::SSLRole role, int* sid) { |
31 int potential_sid = (role == rtc::SSL_CLIENT) ? 0 : 1; | 31 int potential_sid = (role == rtc::SSL_CLIENT) ? 0 : 1; |
32 while (!IsSidAvailable(potential_sid)) { | 32 while (!IsSidAvailable(potential_sid)) { |
33 potential_sid += 2; | 33 potential_sid += 2; |
34 if (potential_sid > static_cast<int>(cricket::kMaxSctpSid)) { | 34 if (potential_sid >= static_cast<int>(cricket::kMaxSctpStreams)) { |
pthatcher1
2016/08/22 23:09:30
I liked the way it read before: "if sid > maxSid {
Taylor Brandstetter
2016/08/23 00:53:14
Done.
| |
35 return false; | 35 return false; |
36 } | 36 } |
37 } | 37 } |
38 | 38 |
39 *sid = potential_sid; | 39 *sid = potential_sid; |
40 used_sids_.insert(potential_sid); | 40 used_sids_.insert(potential_sid); |
41 return true; | 41 return true; |
42 } | 42 } |
43 | 43 |
44 bool SctpSidAllocator::ReserveSid(int sid) { | 44 bool SctpSidAllocator::ReserveSid(int sid) { |
45 if (!IsSidAvailable(sid)) { | 45 if (!IsSidAvailable(sid)) { |
46 return false; | 46 return false; |
47 } | 47 } |
48 used_sids_.insert(sid); | 48 used_sids_.insert(sid); |
49 return true; | 49 return true; |
50 } | 50 } |
51 | 51 |
52 void SctpSidAllocator::ReleaseSid(int sid) { | 52 void SctpSidAllocator::ReleaseSid(int sid) { |
53 auto it = used_sids_.find(sid); | 53 auto it = used_sids_.find(sid); |
54 if (it != used_sids_.end()) { | 54 if (it != used_sids_.end()) { |
55 used_sids_.erase(it); | 55 used_sids_.erase(it); |
56 } | 56 } |
57 } | 57 } |
58 | 58 |
59 bool SctpSidAllocator::IsSidAvailable(int sid) const { | 59 bool SctpSidAllocator::IsSidAvailable(int sid) const { |
60 if (sid < 0 || sid > static_cast<int>(cricket::kMaxSctpSid)) { | 60 if (sid < 0 || sid >= static_cast<int>(cricket::kMaxSctpStreams)) { |
61 return false; | 61 return false; |
62 } | 62 } |
63 return used_sids_.find(sid) == used_sids_.end(); | 63 return used_sids_.find(sid) == used_sids_.end(); |
64 } | 64 } |
65 | 65 |
66 DataChannel::PacketQueue::PacketQueue() : byte_count_(0) {} | 66 DataChannel::PacketQueue::PacketQueue() : byte_count_(0) {} |
67 | 67 |
68 DataChannel::PacketQueue::~PacketQueue() { | 68 DataChannel::PacketQueue::~PacketQueue() { |
69 Clear(); | 69 Clear(); |
70 } | 70 } |
(...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
631 QueueControlMessage(buffer); | 631 QueueControlMessage(buffer); |
632 } else { | 632 } else { |
633 LOG(LS_ERROR) << "Closing the DataChannel due to a failure to send" | 633 LOG(LS_ERROR) << "Closing the DataChannel due to a failure to send" |
634 << " the CONTROL message, send_result = " << send_result; | 634 << " the CONTROL message, send_result = " << send_result; |
635 Close(); | 635 Close(); |
636 } | 636 } |
637 return retval; | 637 return retval; |
638 } | 638 } |
639 | 639 |
640 } // namespace webrtc | 640 } // namespace webrtc |
OLD | NEW |