Changeset 63a3276 in mainline for uspace/srv/locsrv/locsrv.c


Ignore:
Timestamp:
2019-08-06T19:20:35Z (5 years ago)
Author:
Matthieu Riolo <matthieu.riolo@…>
Children:
3f05ef7
Parents:
72c8f77
git-author:
Michal Koutný <xm.koutny+hos@…> (2015-06-17 23:02:03)
git-committer:
Matthieu Riolo <matthieu.riolo@…> (2019-08-06 19:20:35)
Message:

sysman: Instrumented locsrv for autostart

  • also refactored unit name derivation in other brokers
  • exposee creation is not used in unit's lifecycle (failed assertion)

Conflicts:

uspace/lib/c/generic/loc.c
uspace/srv/devman/driver.c
uspace/srv/devman/drv_conn.c
uspace/srv/hid/compositor/compositor.c
uspace/srv/locsrv/locsrv.c
uspace/srv/vfs/vfs.h
uspace/srv/vfs/vfs_ops.c
uspace/srv/vfs/vfs_register.c

File:
1 edited

Legend:

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

    r72c8f77 r63a3276  
    6464} cb_sess_t;
    6565
     66typedef enum {
     67        NAME_TO_START,
     68        NAME_TO_EXPOSE
     69} unit_name_t;
     70
    6671LIST_INITIALIZE(services_list);
    6772LIST_INITIALIZE(namespaces_list);
     
    335340}
    336341
    337 static int loc_service_request_start(const char *ns_name, const char *name)
     342/** Derive unit name from service name according to purpose
     343 *
     344 * All services in 'device' namespace are considered to be drivers and
     345 * devman is thus requested to start. Otherwise name of unit is made
     346 * from fully qualified name of service (namespace separator is changed
     347 * for usage in unit name.
     348 */
     349static int loc_service_unit_name(const char *ns_name, const char *name,
     350    unit_name_t name_type, char **unit_name_ptr)
    338351{
    339352        char *service_name = NULL;
    340 
    341         /*
    342          * All services in 'device' namespace are considered to be drivers and
    343          * devman is thus requested to start. Otherwise name of unit is made
    344          * from fully qualified name of service (namespace separator is changed
    345          * for usage in unit name.
    346          */
    347         if (str_cmp(ns_name, LOC_DEVICE_NAMESPACE) == 0) {
     353        if (name_type == NAME_TO_START &&
     354            str_cmp(ns_name, LOC_DEVICE_NAMESPACE) == 0) {
    348355                asprintf(&service_name, "%s", SERVICE_NAME_DEVMAN);
    349356        } else if (str_cmp(ns_name, "") == 0) {
     
    365372        }
    366373
    367         int rc = sysman_unit_start(unit_name, IPC_FLAG_BLOCKING);
     374        *unit_name_ptr = unit_name;
     375        return EOK;
     376}
     377
     378static int loc_service_request_start(const char *ns_name, const char *name)
     379{
     380        char *unit_name;
     381        int rc = loc_service_unit_name(ns_name, name, NAME_TO_START, &unit_name);
     382        if (rc != EOK) {
     383                return rc;
     384        }
     385
     386        rc = sysman_unit_start(unit_name, IPC_FLAG_BLOCKING);
    368387        free(unit_name);
    369         free(service_name);
    370388        return rc;
    371389}
     
    555573                return;
    556574        }
     575
     576        /* Notify sysman about new exposee */
     577        char *unit_name = NULL;
     578        rc = loc_service_unit_name(namespace->name, service->name,
     579            NAME_TO_EXPOSE, &unit_name);
     580        if (rc != EOK) {
     581                loc_namespace_destroy(namespace);
     582                fibril_mutex_unlock(&services_list_mutex);
     583                free(service->name);
     584                free(service);
     585                free(unit_name);
     586                async_answer_0(iid, rc);
     587                return;
     588        }
     589
     590        if (str_cmp(namespace->name, LOC_DEVICE_NAMESPACE) == 0) {
     591                sysman_exposee_added(unit_name);
     592        } else {
     593                sysman_main_exposee_added(unit_name, icall->in_task_id);
     594        }
     595        free(unit_name);
    557596
    558597        /* Get unique service ID */
     
    837876                }
    838877
    839                 if (flags & IPC_FLAG_BLOCKING) {
     878                if ((flags & IPC_FLAG_BLOCKING) || flags & IPC_FLAG_AUTOSTART) {
    840879                        fibril_condvar_wait(&services_list_cv,
    841880                            &services_list_mutex);
Note: See TracChangeset for help on using the changeset viewer.