Changeset 78bb04b in mainline for uspace/lib/c/generic/async.c
- Timestamp:
- 2015-08-22T14:11:58Z (10 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 0dd16778
- Parents:
- fc22069
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/async.c
rfc22069 r78bb04b 630 630 .remove_callback = NULL 631 631 }; 632 633 /** Wrapper for making IPC_M_CONNECT_TO_ME calls using the async framework. 634 * 635 * Ask through phone for a new connection to some service. 636 * 637 * @param exch Exchange for sending the message. 638 * @param iface Callback interface. 639 * @param arg1 User defined argument. 640 * @param arg2 User defined argument. 641 * @param handler Callback handler. 642 * @param data Handler data. 643 * @param port_id ID of the newly created port. 644 * 645 * @return Zero on success or a negative error code. 646 * 647 */ 648 int async_create_callback_port(async_exch_t *exch, iface_t iface, sysarg_t arg1, 649 sysarg_t arg2, async_port_handler_t handler, void *data, port_id_t *port_id) 650 { 651 if ((iface & IFACE_MOD_CALLBACK) != IFACE_MOD_CALLBACK) 652 return EINVAL; 653 654 if (exch == NULL) 655 return ENOENT; 656 657 ipc_call_t answer; 658 aid_t req = async_send_3(exch, IPC_M_CONNECT_TO_ME, iface, arg1, arg2, 659 &answer); 660 661 sysarg_t ret; 662 async_wait_for(req, &ret); 663 if (ret != EOK) 664 return (int) ret; 665 666 sysarg_t phone_hash = IPC_GET_ARG5(answer); 667 interface_t *interface; 668 669 futex_down(&async_futex); 670 671 ht_link_t *link = hash_table_find(&interface_hash_table, &iface); 672 if (link) 673 interface = hash_table_get_inst(link, interface_t, link); 674 else 675 interface = async_new_interface(iface); 676 677 if (!interface) { 678 futex_up(&async_futex); 679 return ENOMEM; 680 } 681 682 port_t *port = async_new_port(interface, handler, data); 683 if (!port) { 684 futex_up(&async_futex); 685 return ENOMEM; 686 } 687 688 *port_id = port->id; 689 690 futex_up(&async_futex); 691 692 fid_t fid = async_new_connection(answer.in_task_id, phone_hash, 693 0, NULL, handler, data); 694 if (fid == (uintptr_t) NULL) 695 return ENOMEM; 696 697 return EOK; 698 } 632 699 633 700 static size_t notification_key_hash(void *key)
Note:
See TracChangeset
for help on using the changeset viewer.