Changeset 36 for pjproject/main/pjlib/src/pj/ioqueue_common_abs.c
- Timestamp:
- Nov 9, 2005 3:37:19 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/main/pjlib/src/pj/ioqueue_common_abs.c
r35 r36 229 229 if (h->fd_type == PJ_SOCK_DGRAM) { 230 230 pj_list_erase(write_op); 231 write_op->op = 0; 232 231 233 if (pj_list_empty(&h->write_list)) 232 234 ioqueue_remove_from_set(ioqueue, h->fd, WRITEABLE_EVENT); … … 269 271 /* Write completion of the whole stream. */ 270 272 pj_list_erase(write_op); 273 write_op->op = 0; 271 274 272 275 /* Clear operation if there's no more data to send. */ … … 315 318 accept_op = h->accept_list.next; 316 319 pj_list_erase(accept_op); 320 accept_op->op = 0; 317 321 318 322 /* Clear bit in fdset if there is no more pending accept */ … … 348 352 read_op = h->read_list.next; 349 353 pj_list_erase(read_op); 354 read_op->op = 0; 350 355 351 356 /* Clear fdset if there is no pending read. */ … … 477 482 PJ_CHECK_STACK(); 478 483 484 read_op = (struct read_operation*)op_key; 485 read_op->op = 0; 486 479 487 /* Try to see if there's data immediately available. 480 488 */ … … 497 505 * Must schedule asynchronous operation to the ioqueue. 498 506 */ 499 read_op = (struct read_operation*)op_key;500 501 507 read_op->op = PJ_IOQUEUE_OP_RECV; 502 508 read_op->buf = buffer; … … 531 537 PJ_ASSERT_RETURN(key && op_key && buffer && length, PJ_EINVAL); 532 538 PJ_CHECK_STACK(); 539 540 read_op = (struct read_operation*)op_key; 541 read_op->op = 0; 533 542 534 543 /* Try to see if there's data immediately available. … … 553 562 * Must schedule asynchronous operation to the ioqueue. 554 563 */ 555 read_op = (struct read_operation*)op_key;556 557 564 read_op->op = PJ_IOQUEUE_OP_RECV_FROM; 558 565 read_op->buf = buffer; … … 587 594 PJ_ASSERT_RETURN(key && op_key && data && length, PJ_EINVAL); 588 595 PJ_CHECK_STACK(); 596 597 write_op = (struct write_operation*)op_key; 598 write_op->op = 0; 589 599 590 600 /* Fast track: … … 625 635 * Schedule asynchronous send. 626 636 */ 627 write_op = (struct write_operation*)op_key;628 637 write_op->op = PJ_IOQUEUE_OP_SEND; 629 638 write_op->buf = (void*)data; … … 660 669 PJ_ASSERT_RETURN(key && op_key && data && length, PJ_EINVAL); 661 670 PJ_CHECK_STACK(); 671 672 write_op = (struct write_operation*)op_key; 673 write_op->op = 0; 662 674 663 675 /* Fast track: … … 703 715 * Schedule asynchronous send. 704 716 */ 705 write_op = (struct write_operation*)op_key;706 717 write_op->op = PJ_IOQUEUE_OP_SEND_TO; 707 718 write_op->buf = (void*)data; … … 736 747 /* check parameters. All must be specified! */ 737 748 PJ_ASSERT_RETURN(key && op_key && new_sock, PJ_EINVAL); 749 750 accept_op = (struct accept_operation*)op_key; 751 accept_op->op = 0; 738 752 739 753 /* Fast track: … … 768 782 * connection available. 769 783 */ 770 accept_op = (struct accept_operation*)op_key;771 772 784 accept_op->op = PJ_IOQUEUE_OP_ACCEPT; 773 785 accept_op->accept_fd = new_sock; … … 822 834 #endif /* PJ_HAS_TCP */ 823 835 836 /* 837 * pj_ioqueue_is_pending() 838 */ 839 PJ_DEF(pj_bool_t) pj_ioqueue_is_pending( pj_ioqueue_key_t *key, 840 pj_ioqueue_op_key_t *op_key ) 841 { 842 struct generic_operation *op_rec; 843 844 PJ_UNUSED_ARG(key); 845 846 op_rec = (struct generic_operation*)op_key; 847 return op_rec->op != 0; 848 } 849 850 851 /* 852 * pj_ioqueue_post_completion() 853 */ 854 PJ_DEF(pj_status_t) pj_ioqueue_post_completion( pj_ioqueue_key_t *key, 855 pj_ioqueue_op_key_t *op_key, 856 pj_ssize_t bytes_status ) 857 { 858 struct generic_operation *op_rec; 859 860 /* 861 * Find the operation key in all pending operation list to 862 * really make sure that it's still there; then call the callback. 863 */ 864 pj_mutex_lock(key->mutex); 865 866 /* Find the operation in the pending read list. */ 867 op_rec = (struct generic_operation*)key->read_list.next; 868 while (op_rec != (void*)&key->read_list) { 869 if (op_rec == (void*)op_key) { 870 pj_list_erase(op_rec); 871 op_rec->op = 0; 872 pj_mutex_unlock(key->mutex); 873 874 (*key->cb.on_read_complete)(key, op_key, bytes_status); 875 return PJ_SUCCESS; 876 } 877 op_rec = op_rec->next; 878 } 879 880 /* Find the operation in the pending write list. */ 881 op_rec = (struct generic_operation*)key->write_list.next; 882 while (op_rec != (void*)&key->write_list) { 883 if (op_rec == (void*)op_key) { 884 pj_list_erase(op_rec); 885 op_rec->op = 0; 886 pj_mutex_unlock(key->mutex); 887 888 (*key->cb.on_write_complete)(key, op_key, bytes_status); 889 return PJ_SUCCESS; 890 } 891 op_rec = op_rec->next; 892 } 893 894 /* Find the operation in the pending accept list. */ 895 op_rec = (struct generic_operation*)key->accept_list.next; 896 while (op_rec != (void*)&key->accept_list) { 897 if (op_rec == (void*)op_key) { 898 pj_list_erase(op_rec); 899 op_rec->op = 0; 900 pj_mutex_unlock(key->mutex); 901 902 (*key->cb.on_accept_complete)(key, op_key, 903 PJ_INVALID_SOCKET, 904 bytes_status); 905 return PJ_SUCCESS; 906 } 907 op_rec = op_rec->next; 908 } 909 910 pj_mutex_unlock(key->mutex); 911 912 return PJ_EINVALIDOP; 913 } 914
Note: See TracChangeset
for help on using the changeset viewer.