Changeset 8565a42 in mainline for uspace/srv/locsrv


Ignore:
Timestamp:
2018-03-02T20:34:50Z (8 years ago)
Author:
GitHub <noreply@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a1a81f69, d5e5fd1
Parents:
3061bc1 (diff), 34e1206 (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.
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:34:50)
git-committer:
GitHub <noreply@…> (2018-03-02 20:34:50)
Message:

Remove all trailing whitespace, everywhere.

See individual commit messages for details.

Location:
uspace/srv/locsrv
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/locsrv/category.h

    r3061bc1 r8565a42  
    7373        /** Link to loc_service_t.cat_memb list */
    7474        link_t svc_link;
    75        
     75
    7676        /** Category */
    7777        category_t *cat;
  • uspace/srv/locsrv/locsrv.c

    r3061bc1 r8565a42  
    100100         * and implement some version of LRU algorithm, avoid overflow
    101101         */
    102        
     102
    103103        fibril_mutex_lock(&create_id_mutex);
    104104        last_id++;
    105105        fibril_mutex_unlock(&create_id_mutex);
    106        
     106
    107107        return last_id;
    108108}
     
    121121        size_t slash_offset = 0;
    122122        size_t slash_after = 0;
    123        
     123
    124124        size_t offset = 0;
    125125        size_t offset_prev = 0;
    126126        wchar_t c;
    127        
     127
    128128        while ((c = str_decode(fqsn, &offset, STR_NO_LIMIT)) != 0) {
    129129                if (c == '/') {
     
    134134                offset_prev = offset;
    135135        }
    136        
     136
    137137        /* More than one slash */
    138138        if (cnt > 1)
    139139                return false;
    140        
     140
    141141        /* No slash -> namespace is empty */
    142142        if (cnt == 0) {
     
    144144                if (*ns_name == NULL)
    145145                        return false;
    146                
     146
    147147                *name = str_dup(fqsn);
    148148                if (*name == NULL) {
     
    150150                        return false;
    151151                }
    152                
     152
    153153                if (str_cmp(*name, "") == 0) {
    154154                        free(*name);
     
    156156                        return false;
    157157                }
    158                
     158
    159159                return true;
    160160        }
    161        
     161
    162162        /* Exactly one slash */
    163163        *ns_name = str_ndup(fqsn, slash_offset);
    164164        if (*ns_name == NULL)
    165165                return false;
    166        
     166
    167167        *name = str_dup(fqsn + slash_after);
    168168        if (*name == NULL) {
     
    170170                return false;
    171171        }
    172        
     172
    173173        if (str_cmp(*name, "") == 0) {
    174174                free(*name);
     
    176176                return false;
    177177        }
    178        
     178
    179179        return true;
    180180}
     
    184184{
    185185        assert(fibril_mutex_is_locked(&services_list_mutex));
    186        
     186
    187187        list_foreach(namespaces_list, namespaces, loc_namespace_t, namespace) {
    188188                if (str_cmp(namespace->name, name) == 0)
    189189                        return namespace;
    190190        }
    191        
     191
    192192        return NULL;
    193193}
     
    201201{
    202202        assert(fibril_mutex_is_locked(&services_list_mutex));
    203        
     203
    204204        list_foreach(namespaces_list, namespaces, loc_namespace_t, namespace) {
    205205                if (namespace->id == id)
    206206                        return namespace;
    207207        }
    208        
     208
    209209        return NULL;
    210210}
     
    215215{
    216216        assert(fibril_mutex_is_locked(&services_list_mutex));
    217        
     217
    218218        list_foreach(services_list, services, loc_service_t, service) {
    219219                if ((str_cmp(service->namespace->name, ns_name) == 0)
     
    221221                        return service;
    222222        }
    223        
     223
    224224        return NULL;
    225225}
     
    233233{
    234234        assert(fibril_mutex_is_locked(&services_list_mutex));
    235        
     235
    236236        list_foreach(services_list, services, loc_service_t, service) {
    237237                if (service->id == id)
    238238                        return service;
    239239        }
    240        
     240
    241241        return NULL;
    242242}
     
    246246{
    247247        loc_namespace_t *namespace;
    248        
     248
    249249        assert(fibril_mutex_is_locked(&services_list_mutex));
    250        
     250
    251251        namespace = loc_namespace_find_name(ns_name);
    252252        if (namespace != NULL)
    253253                return namespace;
    254        
     254
    255255        namespace = (loc_namespace_t *) malloc(sizeof(loc_namespace_t));
    256256        if (namespace == NULL)
    257257                return NULL;
    258        
     258
    259259        namespace->name = str_dup(ns_name);
    260260        if (namespace->name == NULL) {
     
    262262                return NULL;
    263263        }
    264        
     264
    265265        namespace->id = loc_create_id();
    266266        namespace->refcnt = 0;
    267        
     267
    268268        /*
    269269         * Insert new namespace into list of registered namespaces
    270270         */
    271271        list_append(&(namespace->namespaces), &namespaces_list);
    272        
     272
    273273        return namespace;
    274274}
     
    281281        if (namespace->refcnt == 0) {
    282282                list_remove(&(namespace->namespaces));
    283                
     283
    284284                free(namespace->name);
    285285                free(namespace);
     
    311311        assert(fibril_mutex_is_locked(&services_list_mutex));
    312312        assert(fibril_mutex_is_locked(&cdir.mutex));
    313        
     313
    314314        loc_namespace_delref(service->namespace);
    315315        list_remove(&(service->services));
    316316        list_remove(&(service->server_services));
    317        
     317
    318318        /* Remove service from all categories. */
    319319        while (!list_empty(&service->cat_memb)) {
     
    322322                    svc_link);
    323323                category_t *cat = memb->cat;
    324                
     324
    325325                fibril_mutex_lock(&cat->mutex);
    326326                category_remove_service(memb);
    327327                fibril_mutex_unlock(&cat->mutex);
    328328        }
    329        
     329
    330330        free(service->name);
    331331        free(service);
     
    340340        ipc_call_t icall;
    341341        ipc_callid_t iid = async_get_call(&icall);
    342        
     342
    343343        if (IPC_GET_IMETHOD(icall) != LOC_SERVER_REGISTER) {
    344344                async_answer_0(iid, EREFUSED);
    345345                return NULL;
    346346        }
    347        
     347
    348348        loc_server_t *server =
    349349            (loc_server_t *) malloc(sizeof(loc_server_t));
     
    352352                return NULL;
    353353        }
    354        
     354
    355355        /*
    356356         * Get server name
     
    363363                return NULL;
    364364        }
    365        
     365
    366366        /*
    367367         * Create connection to the server
     
    374374                return NULL;
    375375        }
    376        
     376
    377377        /*
    378378         * Initialize mutex for list of services
     
    380380         */
    381381        fibril_mutex_initialize(&server->services_mutex);
    382        
     382
    383383        /*
    384384         * Initialize list of supplied services
     
    386386        list_initialize(&server->services);
    387387        link_initialize(&server->servers);
    388        
     388
    389389        fibril_mutex_lock(&servers_list_mutex);
    390        
     390
    391391        /* TODO:
    392392         * Check that no server with name equal to
    393393         * server->name is registered
    394394         */
    395        
     395
    396396        /*
    397397         * Insert new server into list of registered servers
     
    399399        list_append(&(server->servers), &servers_list);
    400400        fibril_mutex_unlock(&servers_list_mutex);
    401        
     401
    402402        async_answer_0(iid, EOK);
    403        
     403
    404404        return server;
    405405}
     
    414414        if (server == NULL)
    415415                return EEXIST;
    416        
     416
    417417        fibril_mutex_lock(&servers_list_mutex);
    418        
     418
    419419        if (server->sess)
    420420                async_hangup(server->sess);
    421        
     421
    422422        /* Remove it from list of servers */
    423423        list_remove(&(server->servers));
    424        
     424
    425425        /* Unregister all its services */
    426426        fibril_mutex_lock(&services_list_mutex);
    427427        fibril_mutex_lock(&server->services_mutex);
    428428        fibril_mutex_lock(&cdir.mutex);
    429        
     429
    430430        while (!list_empty(&server->services)) {
    431431                loc_service_t *service = list_get_instance(
     
    434434                loc_service_unregister_core(service);
    435435        }
    436        
     436
    437437        fibril_mutex_unlock(&cdir.mutex);
    438438        fibril_mutex_unlock(&server->services_mutex);
    439439        fibril_mutex_unlock(&services_list_mutex);
    440440        fibril_mutex_unlock(&servers_list_mutex);
    441        
     441
    442442        /* Free name and server */
    443443        if (server->name != NULL)
    444444                free(server->name);
    445        
     445
    446446        free(server);
    447        
     447
    448448        loc_category_change_event();
    449449        return EOK;
     
    460460                return;
    461461        }
    462        
     462
    463463        /* Create new service entry */
    464464        loc_service_t *service =
     
    468468                return;
    469469        }
    470        
     470
    471471        /* Get fqsn */
    472472        char *fqsn;
     
    478478                return;
    479479        }
    480        
     480
    481481        char *ns_name;
    482482        if (!loc_fqsn_split(fqsn, &ns_name, &service->name)) {
     
    486486                return;
    487487        }
    488        
     488
    489489        free(fqsn);
    490        
     490
    491491        fibril_mutex_lock(&services_list_mutex);
    492        
     492
    493493        loc_namespace_t *namespace = loc_namespace_create(ns_name);
    494494        free(ns_name);
     
    500500                return;
    501501        }
    502        
     502
    503503        link_initialize(&service->services);
    504504        link_initialize(&service->server_services);
    505505        list_initialize(&service->cat_memb);
    506        
     506
    507507        /* Check that service is not already registered */
    508508        if (loc_service_find_name(namespace->name, service->name) != NULL) {
     
    516516                return;
    517517        }
    518        
     518
    519519        /* Get unique service ID */
    520520        service->id = loc_create_id();
     
    522522        loc_namespace_addref(namespace, service);
    523523        service->server = server;
    524        
     524
    525525        /* Insert service into list of all services  */
    526526        list_append(&service->services, &services_list);
    527        
     527
    528528        /* Insert service into list of services supplied by one server */
    529529        fibril_mutex_lock(&service->server->services_mutex);
    530        
     530
    531531        list_append(&service->server_services, &service->server->services);
    532        
     532
    533533        fibril_mutex_unlock(&service->server->services_mutex);
    534534        fibril_condvar_broadcast(&services_list_cv);
    535535        fibril_mutex_unlock(&services_list_mutex);
    536        
     536
    537537        async_answer_1(iid, EOK, service->id);
    538538}
     
    545545{
    546546        loc_service_t *svc;
    547        
     547
    548548        fibril_mutex_lock(&services_list_mutex);
    549549        svc = loc_service_find_id(IPC_GET_ARG1(*icall));
     
    553553                return;
    554554        }
    555        
     555
    556556        fibril_mutex_lock(&cdir.mutex);
    557557        loc_service_unregister_core(svc);
     
    574574        size_t act_size;
    575575        category_t *cat;
    576        
     576
    577577        if (!async_data_read_receive(&callid, &size)) {
    578578                async_answer_0(callid, EREFUSED);
     
    580580                return;
    581581        }
    582        
     582
    583583        fibril_mutex_lock(&cdir.mutex);
    584        
     584
    585585        cat = category_get(&cdir, IPC_GET_ARG1(*icall));
    586586        if (cat == NULL) {
     
    590590                return;
    591591        }
    592        
     592
    593593        act_size = str_size(cat->name);
    594594        if (act_size > size) {
     
    598598                return;
    599599        }
    600        
     600
    601601        errno_t retval = async_data_read_finalize(callid, cat->name,
    602602            min(size, act_size));
    603        
     603
    604604        fibril_mutex_unlock(&cdir.mutex);
    605        
     605
    606606        async_answer_0(iid, retval);
    607607}
     
    614614        loc_service_t *svc;
    615615        char *fqn;
    616        
     616
    617617        if (!async_data_read_receive(&callid, &size)) {
    618618                async_answer_0(callid, EREFUSED);
     
    620620                return;
    621621        }
    622        
     622
    623623        fibril_mutex_lock(&services_list_mutex);
    624        
     624
    625625        svc = loc_service_find_id(IPC_GET_ARG1(*icall));
    626626        if (svc == NULL) {
     
    630630                return;
    631631        }
    632        
     632
    633633        if (asprintf(&fqn, "%s/%s", svc->namespace->name, svc->name) < 0) {
    634634                fibril_mutex_unlock(&services_list_mutex);
     
    637637                return;
    638638        }
    639        
     639
    640640        act_size = str_size(fqn);
    641641        if (act_size > size) {
     
    646646                return;
    647647        }
    648        
     648
    649649        errno_t retval = async_data_read_finalize(callid, fqn,
    650650            min(size, act_size));
    651651        free(fqn);
    652        
     652
    653653        fibril_mutex_unlock(&services_list_mutex);
    654        
     654
    655655        async_answer_0(iid, retval);
    656656}
     
    662662        size_t act_size;
    663663        loc_service_t *svc;
    664        
     664
    665665        if (!async_data_read_receive(&callid, &size)) {
    666666                async_answer_0(callid, EREFUSED);
     
    668668                return;
    669669        }
    670        
     670
    671671        fibril_mutex_lock(&services_list_mutex);
    672        
     672
    673673        svc = loc_service_find_id(IPC_GET_ARG1(*icall));
    674674        if (svc == NULL) {
     
    678678                return;
    679679        }
    680        
     680
    681681        if (svc->server == NULL) {
    682682                fibril_mutex_unlock(&services_list_mutex);
     
    685685                return;
    686686        }
    687        
     687
    688688        act_size = str_size(svc->server->name);
    689689        if (act_size > size) {
     
    693693                return;
    694694        }
    695        
     695
    696696        errno_t retval = async_data_read_finalize(callid, svc->server->name,
    697697            min(size, act_size));
    698        
     698
    699699        fibril_mutex_unlock(&services_list_mutex);
    700        
     700
    701701        async_answer_0(iid, retval);
    702702}
     
    711711{
    712712        fibril_mutex_lock(&services_list_mutex);
    713        
     713
    714714        /*
    715715         * Get ID from request
     
    718718        service_id_t id = IPC_GET_ARG2(*call);
    719719        loc_service_t *svc = loc_service_find_id(id);
    720        
     720
    721721        if ((svc == NULL) || (svc->server == NULL) || (!svc->server->sess)) {
    722722                fibril_mutex_unlock(&services_list_mutex);
     
    724724                return;
    725725        }
    726        
     726
    727727        async_exch_t *exch = async_exchange_begin(svc->server->sess);
    728728        async_forward_fast(callid, exch, iface, svc->id, 0, IPC_FF_NONE);
    729729        async_exchange_end(exch);
    730        
     730
    731731        fibril_mutex_unlock(&services_list_mutex);
    732732}
     
    741741{
    742742        char *fqsn;
    743        
     743
    744744        /* Get fqsn */
    745745        errno_t rc = async_data_write_accept((void **) &fqsn, true, 0,
     
    749749                return;
    750750        }
    751        
     751
    752752        char *ns_name;
    753753        char *name;
     
    757757                return;
    758758        }
    759        
     759
    760760        free(fqsn);
    761        
     761
    762762        fibril_mutex_lock(&services_list_mutex);
    763763        const loc_service_t *svc;
    764        
     764
    765765recheck:
    766        
     766
    767767        /*
    768768         * Find service name in the list of known services.
    769769         */
    770770        svc = loc_service_find_name(ns_name, name);
    771        
     771
    772772        /*
    773773         * Device was not found.
     
    780780                        goto recheck;
    781781                }
    782                
     782
    783783                async_answer_0(iid, ENOENT);
    784784                free(ns_name);
     
    787787                return;
    788788        }
    789        
     789
    790790        async_answer_1(iid, EOK, svc->id);
    791        
     791
    792792        fibril_mutex_unlock(&services_list_mutex);
    793793        free(ns_name);
     
    804804{
    805805        char *name;
    806        
     806
    807807        /* Get service name */
    808808        errno_t rc = async_data_write_accept((void **) &name, true, 0,
     
    812812                return;
    813813        }
    814        
     814
    815815        fibril_mutex_lock(&services_list_mutex);
    816816        const loc_namespace_t *namespace;
    817        
     817
    818818recheck:
    819        
     819
    820820        /*
    821821         * Find namespace name in the list of known namespaces.
    822822         */
    823823        namespace = loc_namespace_find_name(name);
    824        
     824
    825825        /*
    826826         * Namespace was not found.
     
    833833                        goto recheck;
    834834                }
    835                
     835
    836836                async_answer_0(iid, ENOENT);
    837837                free(name);
     
    839839                return;
    840840        }
    841        
     841
    842842        async_answer_1(iid, EOK, namespace->id);
    843        
     843
    844844        fibril_mutex_unlock(&services_list_mutex);
    845845        free(name);
     
    862862                return;
    863863        }
    864        
     864
    865865        async_sess_t *sess = async_callback_receive(EXCHANGE_SERIALIZE);
    866866        if (sess == NULL) {
     
    869869                return;
    870870        }
    871        
     871
    872872        cb_sess->sess = sess;
    873873        link_initialize(&cb_sess->cb_sess_list);
    874        
     874
    875875        fibril_mutex_lock(&callback_sess_mutex);
    876876        list_append(&cb_sess->cb_sess_list, &callback_sess_list);
    877877        fibril_mutex_unlock(&callback_sess_mutex);
    878        
     878
    879879        async_answer_0(iid, EOK);
    880880}
     
    883883{
    884884        fibril_mutex_lock(&callback_sess_mutex);
    885        
     885
    886886        list_foreach(callback_sess_list, cb_sess_list, cb_sess_t, cb_sess) {
    887887                async_exch_t *exch = async_exchange_begin(cb_sess->sess);
     
    889889                async_exchange_end(exch);
    890890        }
    891        
     891
    892892        fibril_mutex_unlock(&callback_sess_mutex);
    893893}
     
    903903        char *name;
    904904        category_t *cat;
    905        
     905
    906906        /* Get service name */
    907907        errno_t rc = async_data_write_accept((void **) &name, true, 0,
     
    911911                return;
    912912        }
    913        
     913
    914914        fibril_mutex_lock(&cdir.mutex);
    915915
     
    920920                goto cleanup;
    921921        }
    922        
     922
    923923        async_answer_1(iid, EOK, cat->id);
    924924cleanup:
     
    930930{
    931931        fibril_mutex_lock(&services_list_mutex);
    932        
     932
    933933        loc_namespace_t *namespace =
    934934            loc_namespace_find_id(IPC_GET_ARG1(*icall));
     
    942942        } else
    943943                async_answer_1(iid, EOK, LOC_OBJECT_NAMESPACE);
    944        
     944
    945945        fibril_mutex_unlock(&services_list_mutex);
    946946}
     
    956956{
    957957        fibril_mutex_lock(&services_list_mutex);
    958        
     958
    959959        loc_namespace_t *namespace =
    960960            loc_namespace_find_id(IPC_GET_ARG1(*icall));
     
    963963        else
    964964                async_answer_1(iid, EOK, namespace->refcnt);
    965        
     965
    966966        fibril_mutex_unlock(&services_list_mutex);
    967967}
     
    973973        size_t act_size;
    974974        errno_t rc;
    975        
     975
    976976        if (!async_data_read_receive(&callid, &size)) {
    977977                async_answer_0(callid, EREFUSED);
     
    979979                return;
    980980        }
    981        
     981
    982982        category_id_t *id_buf = (category_id_t *) malloc(size);
    983983        if (id_buf == NULL) {
     
    987987                return;
    988988        }
    989        
     989
    990990        fibril_mutex_lock(&cdir.mutex);
    991        
     991
    992992        rc = categ_dir_get_categories(&cdir, id_buf, size, &act_size);
    993993        if (rc != EOK) {
     
    997997                return;
    998998        }
    999        
     999
    10001000        fibril_mutex_unlock(&cdir.mutex);
    1001        
     1001
    10021002        errno_t retval = async_data_read_finalize(callid, id_buf, size);
    10031003        free(id_buf);
    1004        
     1004
    10051005        async_answer_1(iid, retval, act_size);
    10061006}
     
    10151015                return;
    10161016        }
    1017        
     1017
    10181018        if ((size % sizeof(loc_sdesc_t)) != 0) {
    10191019                async_answer_0(callid, EINVAL);
     
    10211021                return;
    10221022        }
    1023        
     1023
    10241024        fibril_mutex_lock(&services_list_mutex);
    1025        
     1025
    10261026        size_t count = size / sizeof(loc_sdesc_t);
    10271027        if (count != list_count(&namespaces_list)) {
     
    10311031                return;
    10321032        }
    1033        
     1033
    10341034        loc_sdesc_t *desc = (loc_sdesc_t *) malloc(size);
    10351035        if (desc == NULL) {
     
    10391039                return;
    10401040        }
    1041        
     1041
    10421042        size_t pos = 0;
    10431043        list_foreach(namespaces_list, namespaces, loc_namespace_t, namespace) {
     
    10461046                pos++;
    10471047        }
    1048        
     1048
    10491049        errno_t retval = async_data_read_finalize(callid, desc, size);
    1050        
     1050
    10511051        free(desc);
    10521052        fibril_mutex_unlock(&services_list_mutex);
    1053        
     1053
    10541054        async_answer_0(iid, retval);
    10551055}
     
    10591059        /* FIXME: Use faster algorithm which can make better use
    10601060           of namespaces */
    1061        
     1061
    10621062        ipc_callid_t callid;
    10631063        size_t size;
     
    10671067                return;
    10681068        }
    1069        
     1069
    10701070        if ((size % sizeof(loc_sdesc_t)) != 0) {
    10711071                async_answer_0(callid, EINVAL);
     
    10731073                return;
    10741074        }
    1075        
     1075
    10761076        fibril_mutex_lock(&services_list_mutex);
    1077        
     1077
    10781078        loc_namespace_t *namespace =
    10791079            loc_namespace_find_id(IPC_GET_ARG1(*icall));
     
    10841084                return;
    10851085        }
    1086        
     1086
    10871087        size_t count = size / sizeof(loc_sdesc_t);
    10881088        if (count != namespace->refcnt) {
     
    10921092                return;
    10931093        }
    1094        
     1094
    10951095        loc_sdesc_t *desc = (loc_sdesc_t *) malloc(size);
    10961096        if (desc == NULL) {
     
    11001100                return;
    11011101        }
    1102        
     1102
    11031103        size_t pos = 0;
    11041104        list_foreach(services_list, services, loc_service_t, service) {
     
    11091109                }
    11101110        }
    1111        
     1111
    11121112        errno_t retval = async_data_read_finalize(callid, desc, size);
    1113        
     1113
    11141114        free(desc);
    11151115        fibril_mutex_unlock(&services_list_mutex);
    1116        
     1116
    11171117        async_answer_0(iid, retval);
    11181118}
     
    11241124        size_t act_size;
    11251125        errno_t rc;
    1126        
     1126
    11271127        if (!async_data_read_receive(&callid, &size)) {
    11281128                async_answer_0(callid, EREFUSED);
     
    11301130                return;
    11311131        }
    1132        
     1132
    11331133        fibril_mutex_lock(&cdir.mutex);
    1134        
     1134
    11351135        category_t *cat = category_get(&cdir, IPC_GET_ARG1(*icall));
    11361136        if (cat == NULL) {
     
    11401140                return;
    11411141        }
    1142        
     1142
    11431143        category_id_t *id_buf = (category_id_t *) malloc(size);
    11441144        if (id_buf == NULL) {
     
    11481148                return;
    11491149        }
    1150        
     1150
    11511151        fibril_mutex_lock(&cat->mutex);
    1152        
     1152
    11531153        rc = category_get_services(cat, id_buf, size, &act_size);
    11541154        if (rc != EOK) {
     
    11591159                return;
    11601160        }
    1161        
     1161
    11621162        fibril_mutex_unlock(&cat->mutex);
    11631163        fibril_mutex_unlock(&cdir.mutex);
    1164        
     1164
    11651165        errno_t retval = async_data_read_finalize(callid, id_buf, size);
    11661166        free(id_buf);
    1167        
     1167
    11681168        async_answer_1(iid, retval, act_size);
    11691169}
     
    11731173{
    11741174        fibril_mutex_lock(&null_services_mutex);
    1175        
     1175
    11761176        unsigned int i;
    11771177        bool fnd = false;
    1178        
     1178
    11791179        for (i = 0; i < NULL_SERVICES; i++) {
    11801180                if (null_services[i] == NULL) {
     
    11831183                }
    11841184        }
    1185        
     1185
    11861186        if (!fnd) {
    11871187                fibril_mutex_unlock(&null_services_mutex);
     
    11891189                return;
    11901190        }
    1191        
     1191
    11921192        char null[LOC_NAME_MAXLEN];
    11931193        snprintf(null, LOC_NAME_MAXLEN, "%u", i);
    1194        
     1194
    11951195        char *dev_name = str_dup(null);
    11961196        if (dev_name == NULL) {
     
    11991199                return;
    12001200        }
    1201        
     1201
    12021202        loc_service_t *service =
    12031203            (loc_service_t *) malloc(sizeof(loc_service_t));
     
    12071207                return;
    12081208        }
    1209        
     1209
    12101210        fibril_mutex_lock(&services_list_mutex);
    1211        
     1211
    12121212        loc_namespace_t *namespace = loc_namespace_create("null");
    12131213        if (namespace == NULL) {
     
    12171217                return;
    12181218        }
    1219        
     1219
    12201220        link_initialize(&service->services);
    12211221        link_initialize(&service->server_services);
    12221222        list_initialize(&service->cat_memb);
    1223        
     1223
    12241224        /* Get unique service ID */
    12251225        service->id = loc_create_id();
    12261226        service->server = NULL;
    1227        
     1227
    12281228        loc_namespace_addref(namespace, service);
    12291229        service->name = dev_name;
    1230        
     1230
    12311231        /*
    12321232         * Insert service into list of all services and into null services array.
     
    12371237        list_append(&service->server_services, &dummy_null_services);
    12381238        null_services[i] = service;
    1239        
     1239
    12401240        fibril_mutex_unlock(&services_list_mutex);
    12411241        fibril_mutex_unlock(&null_services_mutex);
    1242        
     1242
    12431243        async_answer_1(iid, EOK, (sysarg_t) i);
    12441244}
     
    12511251                return;
    12521252        }
    1253        
     1253
    12541254        fibril_mutex_lock(&null_services_mutex);
    1255        
     1255
    12561256        if (null_services[i] == NULL) {
    12571257                fibril_mutex_unlock(&null_services_mutex);
     
    12591259                return;
    12601260        }
    1261        
     1261
    12621262        fibril_mutex_lock(&services_list_mutex);
    12631263        fibril_mutex_lock(&cdir.mutex);
     
    12651265        fibril_mutex_unlock(&cdir.mutex);
    12661266        fibril_mutex_unlock(&services_list_mutex);
    1267        
     1267
    12681268        null_services[i] = NULL;
    1269        
     1269
    12701270        fibril_mutex_unlock(&null_services_mutex);
    12711271        async_answer_0(iid, EOK);
     
    12791279        service_id_t svc_id;
    12801280        errno_t retval;
    1281        
     1281
    12821282        svc_id = IPC_GET_ARG1(*icall);
    12831283        cat_id = IPC_GET_ARG2(*icall);
    1284        
     1284
    12851285        fibril_mutex_lock(&services_list_mutex);
    12861286        fibril_mutex_lock(&cdir.mutex);
    1287        
     1287
    12881288        cat = category_get(&cdir, cat_id);
    12891289        svc = loc_service_find_id(svc_id);
    1290        
     1290
    12911291        if (cat == NULL || svc == NULL) {
    12921292                fibril_mutex_unlock(&cdir.mutex);
     
    12951295                return;
    12961296        }
    1297        
     1297
    12981298        fibril_mutex_lock(&cat->mutex);
    12991299        retval = category_add_service(cat, svc);
     
    13241324        for (i = 0; i < NULL_SERVICES; i++)
    13251325                null_services[i] = NULL;
    1326        
     1326
    13271327        categ_dir_init(&cdir);
    13281328
     
    13681368        cat = category_new("virtual");
    13691369        categ_dir_add_cat(&cdir, cat);
    1370        
     1370
    13711371        cat = category_new("nic");
    13721372        categ_dir_add_cat(&cdir, cat);
    1373        
     1373
    13741374        cat = category_new("ieee80211");
    13751375        categ_dir_add_cat(&cdir, cat);
     
    13831383        cat = category_new("renderer");
    13841384        categ_dir_add_cat(&cdir, cat);
    1385        
     1385
    13861386        cat = category_new("audio-pcm");
    13871387        categ_dir_add_cat(&cdir, cat);
    1388        
     1388
    13891389        return true;
    13901390}
     
    13971397        /* Accept connection */
    13981398        async_answer_0(iid, EOK);
    1399        
     1399
    14001400        loc_server_t *server = loc_server_register();
    14011401        if (server == NULL)
    14021402                return;
    1403        
     1403
    14041404        while (true) {
    14051405                ipc_call_t call;
    14061406                ipc_callid_t callid = async_get_call(&call);
    1407                
     1407
    14081408                if (!IPC_GET_IMETHOD(call))
    14091409                        break;
    1410                
     1410
    14111411                switch (IPC_GET_IMETHOD(call)) {
    14121412                case LOC_SERVER_UNREGISTER:
     
    14381438                }
    14391439        }
    1440        
     1440
    14411441        if (server != NULL) {
    14421442                /*
     
    14551455        /* Accept connection */
    14561456        async_answer_0(iid, EOK);
    1457        
     1457
    14581458        while (true) {
    14591459                ipc_call_t call;
    14601460                ipc_callid_t callid = async_get_call(&call);
    1461                
     1461
    14621462                if (!IPC_GET_IMETHOD(call))
    14631463                        break;
    1464                
     1464
    14651465                switch (IPC_GET_IMETHOD(call)) {
    14661466                case LOC_SERVICE_GET_ID:
     
    15241524{
    15251525        printf("%s: HelenOS Location Service\n", NAME);
    1526        
     1526
    15271527        if (!loc_init()) {
    15281528                printf("%s: Error while initializing service\n", NAME);
    15291529                return -1;
    15301530        }
    1531        
     1531
    15321532        port_id_t port;
    15331533        errno_t rc = async_create_port(INTERFACE_LOC_SUPPLIER,
     
    15371537                return rc;
    15381538        }
    1539        
     1539
    15401540        rc = async_create_port(INTERFACE_LOC_CONSUMER,
    15411541            loc_connection_consumer, NULL, &port);
     
    15441544                return rc;
    15451545        }
    1546        
     1546
    15471547        /* Set a handler of incomming connections */
    15481548        async_set_fallback_port_handler(loc_forward, NULL);
    1549        
     1549
    15501550        /* Register location service at naming service */
    15511551        rc = service_register(SERVICE_LOC);
     
    15541554                return rc;
    15551555        }
    1556        
     1556
    15571557        printf("%s: Accepting connections\n", NAME);
    15581558        async_manager();
    1559        
     1559
    15601560        /* Never reached */
    15611561        return 0;
  • uspace/srv/locsrv/locsrv.h

    r3061bc1 r8565a42  
    4949        /** Link to servers_list */
    5050        link_t servers;
    51        
     51
    5252        /** List of services supplied by this server */
    5353        list_t services;
    54        
     54
    5555        /** Session asociated with this server */
    5656        async_sess_t *sess;
    57        
     57
    5858        /** Server name */
    5959        char *name;
    60        
     60
    6161        /** Fibril mutex for list of services owned by this server */
    6262        fibril_mutex_t services_mutex;
     
    6969        /** Link to namespaces_list */
    7070        link_t namespaces;
    71        
     71
    7272        /** Unique namespace identifier */
    7373        service_id_t id;
    74        
     74
    7575        /** Namespace name */
    7676        char *name;
    77        
     77
    7878        /** Reference count */
    7979        size_t refcnt;
     
    8686        /** Link to global list of services (services_list) */
    8787        link_t services;
    88        
     88
    8989        /** Link to server list of services (loc_server_t.services) */
    9090        link_t server_services;
    91        
     91
    9292        /** Link to list of services in category (category_t.services) */
    9393        link_t cat_services;
    94        
     94
    9595        /** List of category memberships (svc_categ_t) */
    9696        list_t cat_memb;
    97        
     97
    9898        /** Unique service identifier */
    9999        service_id_t id;
    100        
     100
    101101        /** Service namespace */
    102102        loc_namespace_t *namespace;
    103        
     103
    104104        /** Service name */
    105105        char *name;
    106        
     106
    107107        /** Supplier of this service */
    108108        loc_server_t *server;
Note: See TracChangeset for help on using the changeset viewer.