Changes in uspace/srv/loc/loc.c [03f4acf:5cc9eba] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/loc/loc.c
r03f4acf r5cc9eba 56 56 #define NULL_SERVICES 256 57 57 58 /** Callback session */ 59 typedef struct { 60 link_t cb_sess_list; 61 async_sess_t *sess; 62 } cb_sess_t; 63 58 64 LIST_INITIALIZE(services_list); 59 65 LIST_INITIALIZE(namespaces_list); … … 86 92 87 93 static FIBRIL_MUTEX_INITIALIZE(callback_sess_mutex); 88 static async_sess_t *callback_sess = NULL;94 static LIST_INITIALIZE(callback_sess_list); 89 95 90 96 service_id_t loc_create_id(void) … … 608 614 size_t act_size; 609 615 loc_service_t *svc; 616 char *fqn; 610 617 611 618 if (!async_data_read_receive(&callid, &size)) { … … 625 632 } 626 633 627 act_size = str_size(svc->name); 634 if (asprintf(&fqn, "%s/%s", svc->namespace->name, svc->name) < 0) { 635 fibril_mutex_unlock(&services_list_mutex); 636 async_answer_0(callid, ENOMEM); 637 async_answer_0(iid, ENOMEM); 638 return; 639 } 640 641 act_size = str_size(fqn); 628 642 if (act_size > size) { 643 free(fqn); 629 644 fibril_mutex_unlock(&services_list_mutex); 630 645 async_answer_0(callid, EOVERFLOW); … … 633 648 } 634 649 635 sysarg_t retval = async_data_read_finalize(callid, svc->name,650 sysarg_t retval = async_data_read_finalize(callid, fqn, 636 651 min(size, act_size)); 652 free(fqn); 637 653 638 654 fibril_mutex_unlock(&services_list_mutex); … … 790 806 } 791 807 792 /** Find ID for category specified by name. 793 * 794 * On success, answer will contain EOK int retval and service ID in arg1. 808 /** Create callback connection. 809 * 810 * Create callback connection which will be used to send category change 811 * events. 812 * 813 * On success, answer will contain EOK int retval. 795 814 * On failure, error code will be sent in retval. 796 815 * … … 798 817 static void loc_callback_create(ipc_callid_t iid, ipc_call_t *icall) 799 818 { 800 async_sess_t *cb_sess = async_callback_receive(EXCHANGE_SERIALIZE);819 cb_sess_t *cb_sess = calloc(1, sizeof(cb_sess_t)); 801 820 if (cb_sess == NULL) { 802 821 async_answer_0(iid, ENOMEM); … … 804 823 } 805 824 825 async_sess_t *sess = async_callback_receive(EXCHANGE_SERIALIZE); 826 if (sess == NULL) { 827 free(cb_sess); 828 async_answer_0(iid, ENOMEM); 829 return; 830 } 831 832 cb_sess->sess = sess; 833 link_initialize(&cb_sess->cb_sess_list); 834 806 835 fibril_mutex_lock(&callback_sess_mutex); 807 if (callback_sess != NULL) { 808 fibril_mutex_unlock(&callback_sess_mutex); 809 async_answer_0(iid, EEXIST); 810 return; 811 } 812 813 callback_sess = cb_sess; 836 list_append(&cb_sess->cb_sess_list, &callback_sess_list); 814 837 fibril_mutex_unlock(&callback_sess_mutex); 815 838 … … 820 843 { 821 844 fibril_mutex_lock(&callback_sess_mutex); 822 823 if (callback_sess != NULL) { 824 async_exch_t *exch = async_exchange_begin(callback_sess); 845 846 list_foreach(callback_sess_list, link) { 847 cb_sess_t *cb_sess; 848 849 cb_sess = list_get_instance(link, cb_sess_t, cb_sess_list); 850 851 async_exch_t *exch = async_exchange_begin(cb_sess->sess); 825 852 async_msg_0(exch, LOC_EVENT_CAT_CHANGE); 826 853 async_exchange_end(exch); 827 854 } 828 855 829 856 fibril_mutex_unlock(&callback_sess_mutex); 830 857 }
Note:
See TracChangeset
for help on using the changeset viewer.