Changeset 12f9f0d0 in mainline for uspace/srv/loc/loc.c


Ignore:
Timestamp:
2011-08-17T13:39:53Z (13 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
e280857
Parents:
45058baa
Message:

Notifications on changes in loc categories. Limitations:

  • cannot specify single category to watch
  • max one task can register notifications with loc service
  • max one user callback function can be registered with C library

Remove devman tests as they are not applicable anymore.

File:
1 edited

Legend:

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

    r45058baa r12f9f0d0  
    8484/** Service directory ogranized by categories (yellow pages) */
    8585static categ_dir_t cdir;
     86
     87static FIBRIL_MUTEX_INITIALIZE(callback_sess_mutex);
     88static async_sess_t *callback_sess = NULL;
    8689
    8790service_id_t loc_create_id(void)
     
    728731 *
    729732 */
     733static void loc_callback_create(ipc_callid_t iid, ipc_call_t *icall)
     734{
     735        async_sess_t *cb_sess = async_callback_receive(EXCHANGE_SERIALIZE);
     736        if (cb_sess == NULL) {
     737                async_answer_0(iid, ENOMEM);
     738                return;
     739        }
     740       
     741        fibril_mutex_lock(&callback_sess_mutex);
     742        if (callback_sess != NULL) {
     743                fibril_mutex_unlock(&callback_sess_mutex);
     744                async_answer_0(iid, EEXIST);
     745                return;
     746        }
     747       
     748        callback_sess = cb_sess;
     749        fibril_mutex_unlock(&callback_sess_mutex);
     750       
     751        async_answer_0(iid, EOK);
     752}
     753
     754void loc_category_change_event(void)
     755{
     756        fibril_mutex_lock(&callback_sess_mutex);
     757
     758        if (callback_sess != NULL) {
     759                async_exch_t *exch = async_exchange_begin(callback_sess);
     760                async_msg_0(exch, LOC_EVENT_CAT_CHANGE);
     761                async_exchange_end(exch);
     762        }
     763
     764        fibril_mutex_unlock(&callback_sess_mutex);
     765}
     766
     767/** Find ID for category specified by name.
     768 *
     769 * On success, answer will contain EOK int retval and service ID in arg1.
     770 * On failure, error code will be sent in retval.
     771 *
     772 */
    730773static void loc_category_get_id(ipc_callid_t iid, ipc_call_t *icall)
    731774{
     
    11291172
    11301173        async_answer_0(iid, retval);
     1174
     1175        loc_category_change_event();
    11311176}
    11321177
     
    12431288                case LOC_NAMESPACE_GET_ID:
    12441289                        loc_namespace_get_id(callid, &call);
     1290                        break;
     1291                case LOC_CALLBACK_CREATE:
     1292                        loc_callback_create(callid, &call);
    12451293                        break;
    12461294                case LOC_CATEGORY_GET_ID:
Note: See TracChangeset for help on using the changeset viewer.