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 1452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1463 if (sigaction(signum, &act, NULL) != 0) { | 1463 if (sigaction(signum, &act, NULL) != 0) { |
1464 LOG_ERR(LS_ERROR) << "Couldn't set sigaction"; | 1464 LOG_ERR(LS_ERROR) << "Couldn't set sigaction"; |
1465 return false; | 1465 return false; |
1466 } | 1466 } |
1467 return true; | 1467 return true; |
1468 } | 1468 } |
1469 #endif // WEBRTC_POSIX | 1469 #endif // WEBRTC_POSIX |
1470 | 1470 |
1471 #if defined(WEBRTC_WIN) | 1471 #if defined(WEBRTC_WIN) |
1472 bool PhysicalSocketServer::Wait(int cmsWait, bool process_io) { | 1472 bool PhysicalSocketServer::Wait(int cmsWait, bool process_io) { |
1473 int cmsTotal = cmsWait; | 1473 int64_t cmsTotal = cmsWait; |
1474 int cmsElapsed = 0; | 1474 int64_t cmsElapsed = 0; |
1475 uint32_t msStart = Time(); | 1475 int64_t msStart = Time(); |
1476 | 1476 |
1477 fWait_ = true; | 1477 fWait_ = true; |
1478 while (fWait_) { | 1478 while (fWait_) { |
1479 std::vector<WSAEVENT> events; | 1479 std::vector<WSAEVENT> events; |
1480 std::vector<Dispatcher *> event_owners; | 1480 std::vector<Dispatcher *> event_owners; |
1481 | 1481 |
1482 events.push_back(socket_ev_); | 1482 events.push_back(socket_ev_); |
1483 | 1483 |
1484 { | 1484 { |
1485 CritScope cr(&crit_); | 1485 CritScope cr(&crit_); |
(...skipping 16 matching lines...) Expand all Loading... |
1502 events.push_back(disp->GetWSAEvent()); | 1502 events.push_back(disp->GetWSAEvent()); |
1503 event_owners.push_back(disp); | 1503 event_owners.push_back(disp); |
1504 } | 1504 } |
1505 } | 1505 } |
1506 ASSERT(iterators_.back() == &i); | 1506 ASSERT(iterators_.back() == &i); |
1507 iterators_.pop_back(); | 1507 iterators_.pop_back(); |
1508 } | 1508 } |
1509 | 1509 |
1510 // Which is shorter, the delay wait or the asked wait? | 1510 // Which is shorter, the delay wait or the asked wait? |
1511 | 1511 |
1512 int cmsNext; | 1512 int64_t cmsNext; |
1513 if (cmsWait == kForever) { | 1513 if (cmsWait == kForever) { |
1514 cmsNext = cmsWait; | 1514 cmsNext = cmsWait; |
1515 } else { | 1515 } else { |
1516 cmsNext = std::max(0, cmsTotal - cmsElapsed); | 1516 cmsNext = std::max<int64_t>(0, cmsTotal - cmsElapsed); |
1517 } | 1517 } |
1518 | 1518 |
1519 // Wait for one of the events to signal | 1519 // Wait for one of the events to signal |
1520 DWORD dw = WSAWaitForMultipleEvents(static_cast<DWORD>(events.size()), | 1520 DWORD dw = WSAWaitForMultipleEvents(static_cast<DWORD>(events.size()), |
1521 &events[0], | 1521 &events[0], |
1522 false, | 1522 false, |
1523 cmsNext, | 1523 static_cast<DWORD>(cmsNext), |
1524 false); | 1524 false); |
1525 | 1525 |
1526 if (dw == WSA_WAIT_FAILED) { | 1526 if (dw == WSA_WAIT_FAILED) { |
1527 // Failed? | 1527 // Failed? |
1528 // TODO(pthatcher): need a better strategy than this! | 1528 // TODO(pthatcher): need a better strategy than this! |
1529 WSAGetLastError(); | 1529 WSAGetLastError(); |
1530 ASSERT(false); | 1530 ASSERT(false); |
1531 return false; | 1531 return false; |
1532 } else if (dw == WSA_WAIT_TIMEOUT) { | 1532 } else if (dw == WSA_WAIT_TIMEOUT) { |
1533 // Timeout? | 1533 // Timeout? |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1627 break; | 1627 break; |
1628 } | 1628 } |
1629 } | 1629 } |
1630 | 1630 |
1631 // Done | 1631 // Done |
1632 return true; | 1632 return true; |
1633 } | 1633 } |
1634 #endif // WEBRTC_WIN | 1634 #endif // WEBRTC_WIN |
1635 | 1635 |
1636 } // namespace rtc | 1636 } // namespace rtc |
OLD | NEW |