Changeset 4359 for pjproject/trunk/pjlib/src/pj/activesock.c
- Timestamp:
- Feb 21, 2013 11:18:36 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjlib/src/pj/activesock.c
r3553 r4359 44 44 }; 45 45 46 enum shutdown_dir 47 { 48 SHUT_NONE = 0, 49 SHUT_RX = 1, 50 SHUT_TX = 2 51 }; 52 46 53 struct read_op 47 54 { … … 78 85 void *user_data; 79 86 unsigned async_count; 87 unsigned shutdown; 80 88 unsigned max_loop; 81 89 pj_activesock_cb cb; … … 210 218 #endif 211 219 212 status = pj_ioqueue_register_sock(pool, ioqueue, sock, asock, 213 &ioq_cb, &asock->key); 220 status = pj_ioqueue_register_sock2(pool, ioqueue, sock, 221 (opt? opt->grp_lock : NULL), 222 asock, &ioq_cb, &asock->key); 214 223 if (status != PJ_SUCCESS) { 215 224 pj_activesock_close(asock); … … 284 293 } 285 294 286 287 295 PJ_DEF(pj_status_t) pj_activesock_close(pj_activesock_t *asock) 288 296 { 289 297 PJ_ASSERT_RETURN(asock, PJ_EINVAL); 298 asock->shutdown = SHUT_RX | SHUT_TX; 290 299 if (asock->key) { 291 300 #if defined(PJ_IPHONE_OS_HAS_MULTITASKING_SUPPORT) && \ … … 448 457 449 458 asock = (pj_activesock_t*) pj_ioqueue_get_user_data(key); 459 460 /* Ignore if we've been shutdown */ 461 if (asock->shutdown & SHUT_RX) 462 return; 450 463 451 464 do { … … 570 583 return; 571 584 585 /* Also stop further read if we've been shutdown */ 586 if (asock->shutdown & SHUT_RX) 587 return; 588 572 589 /* Only stream oriented socket may leave data in the packet */ 573 590 if (asock->stream_oriented) { … … 649 666 PJ_ASSERT_RETURN(asock && send_key && data && size, PJ_EINVAL); 650 667 668 if (asock->shutdown & SHUT_TX) 669 return PJ_EINVALIDOP; 670 651 671 send_key->activesock_data = NULL; 652 672 … … 699 719 PJ_EINVAL); 700 720 721 if (asock->shutdown & SHUT_TX) 722 return PJ_EINVALIDOP; 723 701 724 return pj_ioqueue_sendto(asock->key, send_key, data, size, flags, 702 725 addr, addr_len); … … 711 734 712 735 asock = (pj_activesock_t*) pj_ioqueue_get_user_data(key); 736 737 /* Ignore if we've been shutdown. This may cause data to be partially 738 * sent even when 'wholedata' was requested if the OS only sent partial 739 * buffer. 740 */ 741 if (asock->shutdown & SHUT_TX) 742 return; 713 743 714 744 if (bytes_sent > 0 && op_key->activesock_data) { … … 756 786 PJ_ASSERT_RETURN(asock, PJ_EINVAL); 757 787 PJ_ASSERT_RETURN(asock->accept_op==NULL, PJ_EINVALIDOP); 788 789 /* Ignore if we've been shutdown */ 790 if (asock->shutdown) 791 return PJ_EINVALIDOP; 758 792 759 793 asock->accept_op = (struct accept_op*) … … 798 832 799 833 PJ_UNUSED_ARG(new_sock); 834 835 /* Ignore if we've been shutdown */ 836 if (asock->shutdown) 837 return; 800 838 801 839 do { … … 836 874 } 837 875 876 /* Don't start another accept() if we've been shutdown */ 877 if (asock->shutdown) 878 return; 879 838 880 /* Prepare next accept() */ 839 881 accept_op->new_sock = PJ_INVALID_SOCKET; … … 854 896 { 855 897 PJ_UNUSED_ARG(pool); 898 899 if (asock->shutdown) 900 return PJ_EINVALIDOP; 901 856 902 return pj_ioqueue_connect(asock->key, remaddr, addr_len); 857 903 } … … 861 907 { 862 908 pj_activesock_t *asock = (pj_activesock_t*) pj_ioqueue_get_user_data(key); 909 910 /* Ignore if we've been shutdown */ 911 if (asock->shutdown) 912 return; 863 913 864 914 if (asock->cb.on_connect_complete) {
Note: See TracChangeset
for help on using the changeset viewer.