| 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 24 matching lines...) Expand all Loading... |
| 35 #include <ws2tcpip.h> | 35 #include <ws2tcpip.h> |
| 36 #undef SetPort | 36 #undef SetPort |
| 37 #endif | 37 #endif |
| 38 | 38 |
| 39 #include <algorithm> | 39 #include <algorithm> |
| 40 #include <map> | 40 #include <map> |
| 41 | 41 |
| 42 #include "webrtc/base/arraysize.h" | 42 #include "webrtc/base/arraysize.h" |
| 43 #include "webrtc/base/basictypes.h" | 43 #include "webrtc/base/basictypes.h" |
| 44 #include "webrtc/base/byteorder.h" | 44 #include "webrtc/base/byteorder.h" |
| 45 #include "webrtc/base/checks.h" |
| 45 #include "webrtc/base/common.h" | 46 #include "webrtc/base/common.h" |
| 46 #include "webrtc/base/logging.h" | 47 #include "webrtc/base/logging.h" |
| 47 #include "webrtc/base/networkmonitor.h" | 48 #include "webrtc/base/networkmonitor.h" |
| 48 #include "webrtc/base/nullsocketserver.h" | 49 #include "webrtc/base/nullsocketserver.h" |
| 49 #include "webrtc/base/timeutils.h" | 50 #include "webrtc/base/timeutils.h" |
| 50 #include "webrtc/base/winping.h" | 51 #include "webrtc/base/winping.h" |
| 51 #include "webrtc/base/win32socketinit.h" | 52 #include "webrtc/base/win32socketinit.h" |
| 52 | 53 |
| 53 #if defined(WEBRTC_POSIX) | 54 #if defined(WEBRTC_POSIX) |
| 54 #include <netinet/tcp.h> // for TCP_NODELAY | 55 #include <netinet/tcp.h> // for TCP_NODELAY |
| (...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 472 1, false); | 473 1, false); |
| 473 if (result == WinPing::PING_FAIL) { | 474 if (result == WinPing::PING_FAIL) { |
| 474 SetError(EINVAL); // can't think of a better error ID | 475 SetError(EINVAL); // can't think of a better error ID |
| 475 return -1; | 476 return -1; |
| 476 } else if (result != WinPing::PING_TOO_LARGE) { | 477 } else if (result != WinPing::PING_TOO_LARGE) { |
| 477 *mtu = PACKET_MAXIMUMS[level]; | 478 *mtu = PACKET_MAXIMUMS[level]; |
| 478 return 0; | 479 return 0; |
| 479 } | 480 } |
| 480 } | 481 } |
| 481 | 482 |
| 482 ASSERT(false); | 483 RTC_NOTREACHED(); |
| 483 return -1; | 484 return -1; |
| 484 #elif defined(WEBRTC_MAC) | 485 #elif defined(WEBRTC_MAC) |
| 485 // No simple way to do this on Mac OS X. | 486 // No simple way to do this on Mac OS X. |
| 486 // SIOCGIFMTU would work if we knew which interface would be used, but | 487 // SIOCGIFMTU would work if we knew which interface would be used, but |
| 487 // figuring that out is pretty complicated. For now we'll return an error | 488 // figuring that out is pretty complicated. For now we'll return an error |
| 488 // and let the caller pick a default MTU. | 489 // and let the caller pick a default MTU. |
| 489 SetError(EINVAL); | 490 SetError(EINVAL); |
| 490 return -1; | 491 return -1; |
| 491 #elif defined(WEBRTC_LINUX) | 492 #elif defined(WEBRTC_LINUX) |
| 492 // Gets the path MTU. | 493 // Gets the path MTU. |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 588 case OPT_NODELAY: | 589 case OPT_NODELAY: |
| 589 *slevel = IPPROTO_TCP; | 590 *slevel = IPPROTO_TCP; |
| 590 *sopt = TCP_NODELAY; | 591 *sopt = TCP_NODELAY; |
| 591 break; | 592 break; |
| 592 case OPT_DSCP: | 593 case OPT_DSCP: |
| 593 LOG(LS_WARNING) << "Socket::OPT_DSCP not supported."; | 594 LOG(LS_WARNING) << "Socket::OPT_DSCP not supported."; |
| 594 return -1; | 595 return -1; |
| 595 case OPT_RTP_SENDTIME_EXTN_ID: | 596 case OPT_RTP_SENDTIME_EXTN_ID: |
| 596 return -1; // No logging is necessary as this not a OS socket option. | 597 return -1; // No logging is necessary as this not a OS socket option. |
| 597 default: | 598 default: |
| 598 ASSERT(false); | 599 RTC_NOTREACHED(); |
| 599 return -1; | 600 return -1; |
| 600 } | 601 } |
| 601 return 0; | 602 return 0; |
| 602 } | 603 } |
| 603 | 604 |
| 604 SocketDispatcher::SocketDispatcher(PhysicalSocketServer *ss) | 605 SocketDispatcher::SocketDispatcher(PhysicalSocketServer *ss) |
| 605 #if defined(WEBRTC_WIN) | 606 #if defined(WEBRTC_WIN) |
| 606 : PhysicalSocket(ss), id_(0), signal_close_(false) | 607 : PhysicalSocket(ss), id_(0), signal_close_(false) |
| 607 #else | 608 #else |
| 608 : PhysicalSocket(ss) | 609 : PhysicalSocket(ss) |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 847 // pipes. This simulates it by resetting before the event is handled. | 848 // pipes. This simulates it by resetting before the event is handled. |
| 848 | 849 |
| 849 CritScope cs(&crit_); | 850 CritScope cs(&crit_); |
| 850 if (fSignaled_) { | 851 if (fSignaled_) { |
| 851 uint8_t b[4]; // Allow for reading more than 1 byte, but expect 1. | 852 uint8_t b[4]; // Allow for reading more than 1 byte, but expect 1. |
| 852 VERIFY(1 == read(afd_[0], b, sizeof(b))); | 853 VERIFY(1 == read(afd_[0], b, sizeof(b))); |
| 853 fSignaled_ = false; | 854 fSignaled_ = false; |
| 854 } | 855 } |
| 855 } | 856 } |
| 856 | 857 |
| 857 void OnEvent(uint32_t ff, int err) override { ASSERT(false); } | 858 void OnEvent(uint32_t ff, int err) override { RTC_NOTREACHED(); } |
| 858 | 859 |
| 859 int GetDescriptor() override { return afd_[0]; } | 860 int GetDescriptor() override { return afd_[0]; } |
| 860 | 861 |
| 861 bool IsDescriptorClosed() override { return false; } | 862 bool IsDescriptorClosed() override { return false; } |
| 862 | 863 |
| 863 private: | 864 private: |
| 864 PhysicalSocketServer *ss_; | 865 PhysicalSocketServer *ss_; |
| 865 int afd_[2]; | 866 int afd_[2]; |
| 866 bool fSignaled_; | 867 bool fSignaled_; |
| 867 CriticalSection crit_; | 868 CriticalSection crit_; |
| (...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1492 DWORD dw = WSAWaitForMultipleEvents(static_cast<DWORD>(events.size()), | 1493 DWORD dw = WSAWaitForMultipleEvents(static_cast<DWORD>(events.size()), |
| 1493 &events[0], | 1494 &events[0], |
| 1494 false, | 1495 false, |
| 1495 static_cast<DWORD>(cmsNext), | 1496 static_cast<DWORD>(cmsNext), |
| 1496 false); | 1497 false); |
| 1497 | 1498 |
| 1498 if (dw == WSA_WAIT_FAILED) { | 1499 if (dw == WSA_WAIT_FAILED) { |
| 1499 // Failed? | 1500 // Failed? |
| 1500 // TODO(pthatcher): need a better strategy than this! | 1501 // TODO(pthatcher): need a better strategy than this! |
| 1501 WSAGetLastError(); | 1502 WSAGetLastError(); |
| 1502 ASSERT(false); | 1503 RTC_NOTREACHED(); |
| 1503 return false; | 1504 return false; |
| 1504 } else if (dw == WSA_WAIT_TIMEOUT) { | 1505 } else if (dw == WSA_WAIT_TIMEOUT) { |
| 1505 // Timeout? | 1506 // Timeout? |
| 1506 return true; | 1507 return true; |
| 1507 } else { | 1508 } else { |
| 1508 // Figure out which one it is and call it | 1509 // Figure out which one it is and call it |
| 1509 CritScope cr(&crit_); | 1510 CritScope cr(&crit_); |
| 1510 int index = dw - WSA_WAIT_EVENT_0; | 1511 int index = dw - WSA_WAIT_EVENT_0; |
| 1511 if (index > 0) { | 1512 if (index > 0) { |
| 1512 --index; // The first event is the socket event | 1513 --index; // The first event is the socket event |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1596 break; | 1597 break; |
| 1597 } | 1598 } |
| 1598 } | 1599 } |
| 1599 | 1600 |
| 1600 // Done | 1601 // Done |
| 1601 return true; | 1602 return true; |
| 1602 } | 1603 } |
| 1603 #endif // WEBRTC_WIN | 1604 #endif // WEBRTC_WIN |
| 1604 | 1605 |
| 1605 } // namespace rtc | 1606 } // namespace rtc |
| OLD | NEW |