Changeset 5298
- Timestamp:
- May 17, 2016 8:51:14 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/branches/projects/uwp/pjlib/src/pj/sock_uwp.cpp
r5256 r5298 395 395 concurrency::create_task(listener_sock->CancelIOAsync()).wait(); 396 396 } 397 while (has_pending_recv) pj_thread_sleep(10); 398 397 399 stream_sock = nullptr; 398 400 datagram_sock = nullptr; … … 434 436 435 437 HRESULT err = 0; 436 try { 437 concurrency::create_task([this, addr]() { 438 HostName ^host; 439 int port; 438 concurrency::create_task([this, addr, &err]() { 439 HostName ^host; 440 int port; 441 442 try { 440 443 sockaddr_to_hostname_port(addr, host, &port); 441 444 if (pj_sockaddr_has_addr(addr)) { … … 450 453 return listener_sock->BindServiceNameAsync(port.ToString()); 451 454 } 452 }).then([this, &err](concurrency::task<void> t) 453 { 454 try { 455 } catch (Exception^ e) { 456 err = e->HResult; 457 } 458 }).then([this, &err](concurrency::task<void> t) 459 { 460 try { 461 if (!err) 455 462 t.get(); 456 } catch (Exception^ e) { 457 err = e->HResult; 458 } 459 }).get(); 460 } catch (Exception^ e) { 461 err = e->HResult; 462 } 463 } catch (Exception^ e) { 464 err = e->HResult; 465 } 466 }).get(); 463 467 464 468 return (err? PJ_RETURN_OS_ERROR(err) : PJ_SUCCESS); … … 643 647 auto cts_token = cts.get_token(); 644 648 auto t = concurrency::create_task(socket_reader->LoadAsync(*len), 645 649 cts_token); 646 650 *len = cancel_after_timeout(t, cts, READ_TIMEOUT) 647 651 .then([this, len, buf, cts_token, &status] … … 668 672 /* Non-blocking version */ 669 673 674 concurrency::cancellation_token_source cts; 675 auto cts_token = cts.get_token(); 676 670 677 has_pending_recv = PJ_TRUE; 671 concurrency::create_task(socket_reader->LoadAsync(*len) )672 .then([this ](concurrency::task<unsigned int> t_)678 concurrency::create_task(socket_reader->LoadAsync(*len), cts_token) 679 .then([this, cts_token](concurrency::task<unsigned int> t_) 673 680 { 674 681 try { 675 // catch any exception 682 if (cts_token.is_canceled()) { 683 has_pending_recv = PJ_FALSE; 684 685 // invoke callback 686 if (cb.on_read) { 687 (*cb.on_read)(this, -PJ_EUNKNOWN); 688 } 689 return; 690 } 691 676 692 t_.get(); 677 693 has_pending_recv = PJ_FALSE; … … 682 698 (*cb.on_read)(this, read_len); 683 699 } 684 } catch ( Exception^ e) {700 } catch (...) { 685 701 has_pending_recv = PJ_FALSE; 686 702 … … 1479 1495 1480 1496 *newsock = (pj_sock_t)new_uwp_sock; 1481 pj_sockaddr_cp(addr, new_uwp_sock->GetRemoteAddr()); 1482 *addrlen = pj_sockaddr_get_len(addr); 1497 1498 if (addr) 1499 pj_sockaddr_cp(addr, new_uwp_sock->GetRemoteAddr()); 1500 1501 if (addrlen) 1502 *addrlen = pj_sockaddr_get_len(addr); 1483 1503 1484 1504 return PJ_SUCCESS;
Note: See TracChangeset
for help on using the changeset viewer.