OLD | NEW |
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 #include "webrtc/base/physicalsocketserver.h" | 10 #include "webrtc/base/physicalsocketserver.h" |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 // initialized by constructor of a static object. If neccessary libjingle | 131 // initialized by constructor of a static object. If neccessary libjingle |
132 // users can link it with a different version of this function by replacing | 132 // users can link it with a different version of this function by replacing |
133 // win32socketinit.cc. See win32socketinit.cc for more details. | 133 // win32socketinit.cc. See win32socketinit.cc for more details. |
134 EnsureWinsockInit(); | 134 EnsureWinsockInit(); |
135 #endif | 135 #endif |
136 if (s_ != INVALID_SOCKET) { | 136 if (s_ != INVALID_SOCKET) { |
137 enabled_events_ = DE_READ | DE_WRITE; | 137 enabled_events_ = DE_READ | DE_WRITE; |
138 | 138 |
139 int type = SOCK_STREAM; | 139 int type = SOCK_STREAM; |
140 socklen_t len = sizeof(type); | 140 socklen_t len = sizeof(type); |
141 VERIFY(0 == getsockopt(s_, SOL_SOCKET, SO_TYPE, (SockOptArg)&type, &len)); | 141 const int res = |
| 142 getsockopt(s_, SOL_SOCKET, SO_TYPE, (SockOptArg)&type, &len); |
| 143 RTC_DCHECK_EQ(0, res); |
142 udp_ = (SOCK_DGRAM == type); | 144 udp_ = (SOCK_DGRAM == type); |
143 } | 145 } |
144 } | 146 } |
145 | 147 |
146 PhysicalSocket::~PhysicalSocket() { | 148 PhysicalSocket::~PhysicalSocket() { |
147 Close(); | 149 Close(); |
148 } | 150 } |
149 | 151 |
150 bool PhysicalSocket::Create(int family, int type) { | 152 bool PhysicalSocket::Create(int family, int type) { |
151 Close(); | 153 Close(); |
(...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
827 ~EventDispatcher() override { | 829 ~EventDispatcher() override { |
828 ss_->Remove(this); | 830 ss_->Remove(this); |
829 close(afd_[0]); | 831 close(afd_[0]); |
830 close(afd_[1]); | 832 close(afd_[1]); |
831 } | 833 } |
832 | 834 |
833 virtual void Signal() { | 835 virtual void Signal() { |
834 CritScope cs(&crit_); | 836 CritScope cs(&crit_); |
835 if (!fSignaled_) { | 837 if (!fSignaled_) { |
836 const uint8_t b[1] = {0}; | 838 const uint8_t b[1] = {0}; |
837 if (VERIFY(1 == write(afd_[1], b, sizeof(b)))) { | 839 const ssize_t res = write(afd_[1], b, sizeof(b)); |
838 fSignaled_ = true; | 840 RTC_DCHECK_EQ(1, res); |
839 } | 841 fSignaled_ = true; |
840 } | 842 } |
841 } | 843 } |
842 | 844 |
843 uint32_t GetRequestedEvents() override { return DE_READ; } | 845 uint32_t GetRequestedEvents() override { return DE_READ; } |
844 | 846 |
845 void OnPreEvent(uint32_t ff) override { | 847 void OnPreEvent(uint32_t ff) override { |
846 // It is not possible to perfectly emulate an auto-resetting event with | 848 // It is not possible to perfectly emulate an auto-resetting event with |
847 // pipes. This simulates it by resetting before the event is handled. | 849 // pipes. This simulates it by resetting before the event is handled. |
848 | 850 |
849 CritScope cs(&crit_); | 851 CritScope cs(&crit_); |
850 if (fSignaled_) { | 852 if (fSignaled_) { |
851 uint8_t b[4]; // Allow for reading more than 1 byte, but expect 1. | 853 uint8_t b[4]; // Allow for reading more than 1 byte, but expect 1. |
852 VERIFY(1 == read(afd_[0], b, sizeof(b))); | 854 const ssize_t res = read(afd_[0], b, sizeof(b)); |
| 855 RTC_DCHECK_EQ(1, res); |
853 fSignaled_ = false; | 856 fSignaled_ = false; |
854 } | 857 } |
855 } | 858 } |
856 | 859 |
857 void OnEvent(uint32_t ff, int err) override { RTC_NOTREACHED(); } | 860 void OnEvent(uint32_t ff, int err) override { RTC_NOTREACHED(); } |
858 | 861 |
859 int GetDescriptor() override { return afd_[0]; } | 862 int GetDescriptor() override { return afd_[0]; } |
860 | 863 |
861 bool IsDescriptorClosed() override { return false; } | 864 bool IsDescriptorClosed() override { return false; } |
862 | 865 |
(...skipping 733 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1596 break; | 1599 break; |
1597 } | 1600 } |
1598 } | 1601 } |
1599 | 1602 |
1600 // Done | 1603 // Done |
1601 return true; | 1604 return true; |
1602 } | 1605 } |
1603 #endif // WEBRTC_WIN | 1606 #endif // WEBRTC_WIN |
1604 | 1607 |
1605 } // namespace rtc | 1608 } // namespace rtc |
OLD | NEW |