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 | 10 |
(...skipping 21 matching lines...) Expand all Loading... |
32 #define WIN32_LEAN_AND_MEAN | 32 #define WIN32_LEAN_AND_MEAN |
33 #include <windows.h> | 33 #include <windows.h> |
34 #include <winsock2.h> | 34 #include <winsock2.h> |
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/basictypes.h" | 43 #include "webrtc/base/basictypes.h" |
43 #include "webrtc/base/byteorder.h" | 44 #include "webrtc/base/byteorder.h" |
44 #include "webrtc/base/common.h" | 45 #include "webrtc/base/common.h" |
45 #include "webrtc/base/logging.h" | 46 #include "webrtc/base/logging.h" |
46 #include "webrtc/base/nethelpers.h" | 47 #include "webrtc/base/nethelpers.h" |
47 #include "webrtc/base/physicalsocketserver.h" | 48 #include "webrtc/base/physicalsocketserver.h" |
48 #include "webrtc/base/timeutils.h" | 49 #include "webrtc/base/timeutils.h" |
49 #include "webrtc/base/winping.h" | 50 #include "webrtc/base/winping.h" |
50 #include "webrtc/base/win32socketinit.h" | 51 #include "webrtc/base/win32socketinit.h" |
51 | 52 |
(...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
621 // There is just a single global instance. (Signal handlers do not get any | 622 // There is just a single global instance. (Signal handlers do not get any |
622 // sort of user-defined void * parameter, so they can't access anything that | 623 // sort of user-defined void * parameter, so they can't access anything that |
623 // isn't global.) | 624 // isn't global.) |
624 static PosixSignalHandler* Instance() { | 625 static PosixSignalHandler* Instance() { |
625 RTC_DEFINE_STATIC_LOCAL(PosixSignalHandler, instance, ()); | 626 RTC_DEFINE_STATIC_LOCAL(PosixSignalHandler, instance, ()); |
626 return &instance; | 627 return &instance; |
627 } | 628 } |
628 | 629 |
629 // Returns true if the given signal number is set. | 630 // Returns true if the given signal number is set. |
630 bool IsSignalSet(int signum) const { | 631 bool IsSignalSet(int signum) const { |
631 ASSERT(signum < ARRAY_SIZE(received_signal_)); | 632 ASSERT(signum < static_cast<int>(arraysize(received_signal_))); |
632 if (signum < ARRAY_SIZE(received_signal_)) { | 633 if (signum < static_cast<int>(arraysize(received_signal_))) { |
633 return received_signal_[signum]; | 634 return received_signal_[signum]; |
634 } else { | 635 } else { |
635 return false; | 636 return false; |
636 } | 637 } |
637 } | 638 } |
638 | 639 |
639 // Clears the given signal number. | 640 // Clears the given signal number. |
640 void ClearSignal(int signum) { | 641 void ClearSignal(int signum) { |
641 ASSERT(signum < ARRAY_SIZE(received_signal_)); | 642 ASSERT(signum < static_cast<int>(arraysize(received_signal_))); |
642 if (signum < ARRAY_SIZE(received_signal_)) { | 643 if (signum < static_cast<int>(arraysize(received_signal_))) { |
643 received_signal_[signum] = false; | 644 received_signal_[signum] = false; |
644 } | 645 } |
645 } | 646 } |
646 | 647 |
647 // Returns the file descriptor to monitor for signal events. | 648 // Returns the file descriptor to monitor for signal events. |
648 int GetDescriptor() const { | 649 int GetDescriptor() const { |
649 return afd_[0]; | 650 return afd_[0]; |
650 } | 651 } |
651 | 652 |
652 // This is called directly from our real signal handler, so it must be | 653 // This is called directly from our real signal handler, so it must be |
653 // signal-handler-safe. That means it cannot assume anything about the | 654 // signal-handler-safe. That means it cannot assume anything about the |
654 // user-level state of the process, since the handler could be executed at any | 655 // user-level state of the process, since the handler could be executed at any |
655 // time on any thread. | 656 // time on any thread. |
656 void OnPosixSignalReceived(int signum) { | 657 void OnPosixSignalReceived(int signum) { |
657 if (signum >= ARRAY_SIZE(received_signal_)) { | 658 if (signum >= static_cast<int>(arraysize(received_signal_))) { |
658 // We don't have space in our array for this. | 659 // We don't have space in our array for this. |
659 return; | 660 return; |
660 } | 661 } |
661 // Set a flag saying we've seen this signal. | 662 // Set a flag saying we've seen this signal. |
662 received_signal_[signum] = true; | 663 received_signal_[signum] = true; |
663 // Notify application code that we got a signal. | 664 // Notify application code that we got a signal. |
664 const uint8_t b[1] = {0}; | 665 const uint8_t b[1] = {0}; |
665 if (-1 == write(afd_[1], b, sizeof(b))) { | 666 if (-1 == write(afd_[1], b, sizeof(b))) { |
666 // Nothing we can do here. If there's an error somehow then there's | 667 // Nothing we can do here. If there's an error somehow then there's |
667 // nothing we can safely do from a signal handler. | 668 // nothing we can safely do from a signal handler. |
(...skipping 959 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1627 break; | 1628 break; |
1628 } | 1629 } |
1629 } | 1630 } |
1630 | 1631 |
1631 // Done | 1632 // Done |
1632 return true; | 1633 return true; |
1633 } | 1634 } |
1634 #endif // WEBRTC_WIN | 1635 #endif // WEBRTC_WIN |
1635 | 1636 |
1636 } // namespace rtc | 1637 } // namespace rtc |
OLD | NEW |