Changes in uspace/srv/loc/loc.c [e2e56e67:03f4acf] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/loc/loc.c
re2e56e67 r03f4acf 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 64 58 LIST_INITIALIZE(services_list); 65 59 LIST_INITIALIZE(namespaces_list); … … 92 86 93 87 static FIBRIL_MUTEX_INITIALIZE(callback_sess_mutex); 94 static LIST_INITIALIZE(callback_sess_list);88 static async_sess_t *callback_sess = NULL; 95 89 96 90 service_id_t loc_create_id(void) … … 614 608 size_t act_size; 615 609 loc_service_t *svc; 616 char *fqn;617 610 618 611 if (!async_data_read_receive(&callid, &size)) { … … 632 625 } 633 626 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); 627 act_size = str_size(svc->name); 642 628 if (act_size > size) { 643 free(fqn);644 629 fibril_mutex_unlock(&services_list_mutex); 645 630 async_answer_0(callid, EOVERFLOW); … … 648 633 } 649 634 650 sysarg_t retval = async_data_read_finalize(callid, fqn,635 sysarg_t retval = async_data_read_finalize(callid, svc->name, 651 636 min(size, act_size)); 652 free(fqn);653 637 654 638 fibril_mutex_unlock(&services_list_mutex); … … 806 790 } 807 791 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. 792 /** Find ID for category specified by name. 793 * 794 * On success, answer will contain EOK int retval and service ID in arg1. 814 795 * On failure, error code will be sent in retval. 815 796 * … … 817 798 static void loc_callback_create(ipc_callid_t iid, ipc_call_t *icall) 818 799 { 819 cb_sess_t *cb_sess = calloc(1, sizeof(cb_sess_t));800 async_sess_t *cb_sess = async_callback_receive(EXCHANGE_SERIALIZE); 820 801 if (cb_sess == NULL) { 821 802 async_answer_0(iid, ENOMEM); … … 823 804 } 824 805 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 835 806 fibril_mutex_lock(&callback_sess_mutex); 836 list_append(&cb_sess->cb_sess_list, &callback_sess_list); 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; 837 814 fibril_mutex_unlock(&callback_sess_mutex); 838 815 … … 843 820 { 844 821 fibril_mutex_lock(&callback_sess_mutex); 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); 822 823 if (callback_sess != NULL) { 824 async_exch_t *exch = async_exchange_begin(callback_sess); 852 825 async_msg_0(exch, LOC_EVENT_CAT_CHANGE); 853 826 async_exchange_end(exch); 854 827 } 855 828 856 829 fibril_mutex_unlock(&callback_sess_mutex); 857 830 } … … 1294 1267 1295 1268 cat = category_new("bd"); 1296 categ_dir_add_cat(&cdir, cat);1297 1298 cat = category_new("iplink");1299 1269 categ_dir_add_cat(&cdir, cat); 1300 1270
Note:
See TracChangeset
for help on using the changeset viewer.