OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 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 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
425 OutstandingCallCompleted(); | 425 OutstandingCallCompleted(); |
426 return -1; | 426 return -1; |
427 } | 427 } |
428 | 428 |
429 void UdpSocket2Windows::IOCompleted(PerIoContext* pIOContext, | 429 void UdpSocket2Windows::IOCompleted(PerIoContext* pIOContext, |
430 uint32_t ioSize, uint32_t error) | 430 uint32_t ioSize, uint32_t error) |
431 { | 431 { |
432 if(pIOContext == NULL || error == ERROR_OPERATION_ABORTED) | 432 if(pIOContext == NULL || error == ERROR_OPERATION_ABORTED) |
433 { | 433 { |
434 if ((pIOContext != NULL) && | 434 if ((pIOContext != NULL) && |
435 !pIOContext->ioInitiatedByThreadWrapper && | 435 !pIOContext->ioInitiatedByPlatformThread && |
436 (error == ERROR_OPERATION_ABORTED) && | 436 (error == ERROR_OPERATION_ABORTED) && |
437 (pIOContext->ioOperation == OP_READ) && | 437 (pIOContext->ioOperation == OP_READ) && |
438 _outstandingCallsDisabled) | 438 _outstandingCallsDisabled) |
439 { | 439 { |
440 // !pIOContext->initiatedIOByThreadWrapper indicate that the I/O | 440 // !pIOContext->initiatedIOByPlatformThread indicate that the I/O |
441 // was not initiated by a ThreadWrapper thread. | 441 // was not initiated by a PlatformThread thread. |
442 // This may happen if the thread that initiated receiving (e.g. | 442 // This may happen if the thread that initiated receiving (e.g. |
443 // by calling StartListen())) is deleted before any packets have | 443 // by calling StartListen())) is deleted before any packets have |
444 // been received. | 444 // been received. |
445 // In this case there is no packet in the PerIoContext. Re-use it | 445 // In this case there is no packet in the PerIoContext. Re-use it |
446 // to post a new PostRecv(..). | 446 // to post a new PostRecv(..). |
447 // Note 1: the PerIoContext will henceforth be posted by a thread | 447 // Note 1: the PerIoContext will henceforth be posted by a thread |
448 // that is controlled by the socket implementation. | 448 // that is controlled by the socket implementation. |
449 // Note 2: This is more likely to happen to RTCP packets as | 449 // Note 2: This is more likely to happen to RTCP packets as |
450 // they are less frequent than RTP packets. | 450 // they are less frequent than RTP packets. |
451 // Note 3: _outstandingCallsDisabled being false indicates | 451 // Note 3: _outstandingCallsDisabled being false indicates |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
512 ioSize, | 512 ioSize, |
513 &pIOContext->from); | 513 &pIOContext->from); |
514 } | 514 } |
515 _ptrCbRWLock->ReleaseLockShared(); | 515 _ptrCbRWLock->ReleaseLockShared(); |
516 } | 516 } |
517 int32_t err = PostRecv(pIOContext); | 517 int32_t err = PostRecv(pIOContext); |
518 if(err == 0) | 518 if(err == 0) |
519 { | 519 { |
520 // The PerIoContext was posted by a thread controlled by the socket | 520 // The PerIoContext was posted by a thread controlled by the socket |
521 // implementation. | 521 // implementation. |
522 pIOContext->ioInitiatedByThreadWrapper = true; | 522 pIOContext->ioInitiatedByPlatformThread = true; |
523 } | 523 } |
524 OutstandingCallCompleted(); | 524 OutstandingCallCompleted(); |
525 return; | 525 return; |
526 } else { | 526 } else { |
527 // Unknown operation. Should not happen. Return pIOContext to avoid | 527 // Unknown operation. Should not happen. Return pIOContext to avoid |
528 // memory leak. | 528 // memory leak. |
529 assert(false); | 529 assert(false); |
530 _mgr->PushIoContext(pIOContext); | 530 _mgr->PushIoContext(pIOContext); |
531 } | 531 } |
532 OutstandingCallCompleted(); | 532 OutstandingCallCompleted(); |
533 // Don't touch any members after OutstandingCallCompleted() since the socket | 533 // Don't touch any members after OutstandingCallCompleted() since the socket |
534 // may be deleted at this point. | 534 // may be deleted at this point. |
535 } | 535 } |
536 | 536 |
537 int32_t UdpSocket2Windows::PostRecv() | 537 int32_t UdpSocket2Windows::PostRecv() |
538 { | 538 { |
539 PerIoContext* pIoContext=_mgr->PopIoContext(); | 539 PerIoContext* pIoContext=_mgr->PopIoContext(); |
540 if(pIoContext == 0) | 540 if(pIoContext == 0) |
541 { | 541 { |
542 WEBRTC_TRACE(kTraceError, kTraceTransport, _id, | 542 WEBRTC_TRACE(kTraceError, kTraceTransport, _id, |
543 "UdpSocket2Windows(%d)::PostRecv(), pIoContext == 0", | 543 "UdpSocket2Windows(%d)::PostRecv(), pIoContext == 0", |
544 (int32_t)this); | 544 (int32_t)this); |
545 return -1; | 545 return -1; |
546 } | 546 } |
547 // This function may have been called by thread not controlled by the socket | 547 // This function may have been called by thread not controlled by the socket |
548 // implementation. | 548 // implementation. |
549 pIoContext->ioInitiatedByThreadWrapper = false; | 549 pIoContext->ioInitiatedByPlatformThread = false; |
550 return PostRecv(pIoContext); | 550 return PostRecv(pIoContext); |
551 } | 551 } |
552 | 552 |
553 int32_t UdpSocket2Windows::PostRecv(PerIoContext* pIoContext) | 553 int32_t UdpSocket2Windows::PostRecv(PerIoContext* pIoContext) |
554 { | 554 { |
555 if(pIoContext==0) | 555 if(pIoContext==0) |
556 { | 556 { |
557 WEBRTC_TRACE(kTraceError, kTraceTransport, _id, | 557 WEBRTC_TRACE(kTraceError, kTraceTransport, _id, |
558 "UdpSocket2Windows(%d)::PostRecv(?), pIoContext==0", | 558 "UdpSocket2Windows(%d)::PostRecv(?), pIoContext==0", |
559 (int32_t)this); | 559 (int32_t)this); |
(...skipping 805 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1365 "UdpSocket2Windows(%d)::InvalidateSocket() WSAerror: %d", | 1365 "UdpSocket2Windows(%d)::InvalidateSocket() WSAerror: %d", |
1366 (int32_t)this, WSAGetLastError()); | 1366 (int32_t)this, WSAGetLastError()); |
1367 } | 1367 } |
1368 _socket = INVALID_SOCKET; | 1368 _socket = INVALID_SOCKET; |
1369 _ptrSocketRWLock->ReleaseLockExclusive(); | 1369 _ptrSocketRWLock->ReleaseLockExclusive(); |
1370 return true; | 1370 return true; |
1371 } | 1371 } |
1372 | 1372 |
1373 } // namespace test | 1373 } // namespace test |
1374 } // namespace webrtc | 1374 } // namespace webrtc |
OLD | NEW |