Changeset eaa0c3f in mainline for uspace/srv/loc/loc.c


Ignore:
Timestamp:
2012-01-21T23:55:03Z (12 years ago)
Author:
Frantisek Princ <frantisek.princ@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
c38e417
Parents:
86c71de (diff), e98fe28c (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge with mainline

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/loc/loc.c

    r86c71de reaa0c3f  
    5656#define NULL_SERVICES  256
    5757
     58/** Callback session */
     59typedef struct {
     60        link_t cb_sess_list;
     61        async_sess_t *sess;
     62} cb_sess_t;
     63
    5864LIST_INITIALIZE(services_list);
    5965LIST_INITIALIZE(namespaces_list);
     
    8692
    8793static FIBRIL_MUTEX_INITIALIZE(callback_sess_mutex);
    88 static async_sess_t *callback_sess = NULL;
     94static LIST_INITIALIZE(callback_sess_list);
    8995
    9096service_id_t loc_create_id(void)
     
    608614        size_t act_size;
    609615        loc_service_t *svc;
     616        char *fqn;
    610617       
    611618        if (!async_data_read_receive(&callid, &size)) {
     
    625632        }
    626633       
    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);
    628642        if (act_size > size) {
     643                free(fqn);
    629644                fibril_mutex_unlock(&services_list_mutex);
    630645                async_answer_0(callid, EOVERFLOW);
     
    633648        }
    634649       
    635         sysarg_t retval = async_data_read_finalize(callid, svc->name,
     650        sysarg_t retval = async_data_read_finalize(callid, fqn,
    636651            min(size, act_size));
     652        free(fqn);
    637653       
    638654        fibril_mutex_unlock(&services_list_mutex);
     
    790806}
    791807
    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.
    795814 * On failure, error code will be sent in retval.
    796  *
    797815 */
    798816static void loc_callback_create(ipc_callid_t iid, ipc_call_t *icall)
    799817{
    800         async_sess_t *cb_sess = async_callback_receive(EXCHANGE_SERIALIZE);
     818        cb_sess_t *cb_sess;
     819       
     820        cb_sess = calloc(1, sizeof(cb_sess_t));
    801821        if (cb_sess == NULL) {
    802822                async_answer_0(iid, ENOMEM);
     
    804824        }
    805825       
     826        async_sess_t *sess = async_callback_receive(EXCHANGE_SERIALIZE);
     827        if (sess == NULL) {
     828                free(cb_sess);
     829                async_answer_0(iid, ENOMEM);
     830                return;
     831        }
     832       
     833        cb_sess->sess = sess;
     834        link_initialize(&cb_sess->cb_sess_list);
     835       
    806836        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;
     837        list_append(&cb_sess->cb_sess_list, &callback_sess_list);
    814838        fibril_mutex_unlock(&callback_sess_mutex);
    815839       
     
    820844{
    821845        fibril_mutex_lock(&callback_sess_mutex);
    822 
    823         if (callback_sess != NULL) {
    824                 async_exch_t *exch = async_exchange_begin(callback_sess);
     846       
     847        list_foreach(callback_sess_list, link) {
     848                cb_sess_t *cb_sess;
     849               
     850                cb_sess = list_get_instance(link, cb_sess_t, cb_sess_list);
     851               
     852                async_exch_t *exch = async_exchange_begin(cb_sess->sess);
    825853                async_msg_0(exch, LOC_EVENT_CAT_CHANGE);
    826854                async_exchange_end(exch);
    827855        }
    828 
     856       
    829857        fibril_mutex_unlock(&callback_sess_mutex);
    830858}
Note: See TracChangeset for help on using the changeset viewer.