Changes in uspace/srv/locsrv/locsrv.c [3a9cf35:3e6a98c5] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/locsrv/locsrv.c
r3a9cf35 r3e6a98c5 184 184 assert(fibril_mutex_is_locked(&services_list_mutex)); 185 185 186 list_foreach(namespaces_list, namespaces, loc_namespace_t, namespace) { 186 list_foreach(namespaces_list, item) { 187 loc_namespace_t *namespace = 188 list_get_instance(item, loc_namespace_t, namespaces); 187 189 if (str_cmp(namespace->name, name) == 0) 188 190 return namespace; … … 201 203 assert(fibril_mutex_is_locked(&services_list_mutex)); 202 204 203 list_foreach(namespaces_list, namespaces, loc_namespace_t, namespace) { 205 list_foreach(namespaces_list, item) { 206 loc_namespace_t *namespace = 207 list_get_instance(item, loc_namespace_t, namespaces); 204 208 if (namespace->id == id) 205 209 return namespace; … … 215 219 assert(fibril_mutex_is_locked(&services_list_mutex)); 216 220 217 list_foreach(services_list, services, loc_service_t, service) { 221 list_foreach(services_list, item) { 222 loc_service_t *service = 223 list_get_instance(item, loc_service_t, services); 218 224 if ((str_cmp(service->namespace->name, ns_name) == 0) 219 225 && (str_cmp(service->name, name) == 0)) … … 233 239 assert(fibril_mutex_is_locked(&services_list_mutex)); 234 240 235 list_foreach(services_list, services, loc_service_t, service) { 241 list_foreach(services_list, item) { 242 loc_service_t *service = 243 list_get_instance(item, loc_service_t, services); 236 244 if (service->id == id) 237 245 return service; … … 320 328 svc_categ_t *memb = list_get_instance(link, svc_categ_t, 321 329 svc_link); 322 category_t *cat = memb->cat; 323 324 fibril_mutex_lock(&cat->mutex); 330 fibril_mutex_lock(&memb->cat->mutex); 325 331 category_remove_service(memb); 326 fibril_mutex_unlock(& cat->mutex);332 fibril_mutex_unlock(&memb->cat->mutex); 327 333 } 328 334 … … 412 418 { 413 419 if (server == NULL) 414 return EEXIST ;420 return EEXISTS; 415 421 416 422 fibril_mutex_lock(&servers_list_mutex); … … 445 451 free(server); 446 452 447 loc_category_change_event();448 453 return EOK; 449 454 } … … 468 473 } 469 474 475 /* Set the interface, if any. */ 476 service->forward_interface = IPC_GET_ARG1(*icall); 477 470 478 /* Get fqsn */ 471 479 char *fqsn; … … 512 520 free(service->name); 513 521 free(service); 514 async_answer_0(iid, EEXIST );522 async_answer_0(iid, EEXISTS); 515 523 return; 516 524 } … … 558 566 fibril_mutex_unlock(&services_list_mutex); 559 567 async_answer_0(iid, EOK); 560 561 loc_category_change_event();562 568 } 563 569 … … 702 708 * 703 709 */ 704 static void loc_forward(ipc_callid_t callid, ipc_call_t *call , void *arg)710 static void loc_forward(ipc_callid_t callid, ipc_call_t *call) 705 711 { 706 712 fibril_mutex_lock(&services_list_mutex); … … 709 715 * Get ID from request 710 716 */ 711 iface_t iface = IPC_GET_ARG1(*call);712 717 service_id_t id = IPC_GET_ARG2(*call); 713 718 loc_service_t *svc = loc_service_find_id(id); … … 720 725 721 726 async_exch_t *exch = async_exchange_begin(svc->server->sess); 722 async_forward_fast(callid, exch, iface, svc->id, 0, IPC_FF_NONE); 727 728 if (svc->forward_interface == 0) 729 async_forward_fast(callid, exch, svc->id, 0, 0, IPC_FF_NONE); 730 else 731 async_forward_fast(callid, exch, svc->forward_interface, 732 svc->id, 0, IPC_FF_NONE); 733 723 734 async_exchange_end(exch); 724 735 … … 878 889 fibril_mutex_lock(&callback_sess_mutex); 879 890 880 list_foreach(callback_sess_list, cb_sess_list, cb_sess_t, cb_sess) { 891 list_foreach(callback_sess_list, link) { 892 cb_sess_t *cb_sess; 893 894 cb_sess = list_get_instance(link, cb_sess_t, cb_sess_list); 895 881 896 async_exch_t *exch = async_exchange_begin(cb_sess->sess); 882 897 async_msg_0(exch, LOC_EVENT_CAT_CHANGE); … … 954 969 loc_namespace_find_id(IPC_GET_ARG1(*icall)); 955 970 if (namespace == NULL) 956 async_answer_0(iid, EEXIST );971 async_answer_0(iid, EEXISTS); 957 972 else 958 973 async_answer_1(iid, EOK, namespace->refcnt); … … 1035 1050 1036 1051 size_t pos = 0; 1037 list_foreach(namespaces_list, namespaces, loc_namespace_t, namespace) { 1052 list_foreach(namespaces_list, item) { 1053 loc_namespace_t *namespace = 1054 list_get_instance(item, loc_namespace_t, namespaces); 1055 1038 1056 desc[pos].id = namespace->id; 1039 1057 str_cpy(desc[pos].name, LOC_NAME_MAXLEN, namespace->name); … … 1096 1114 1097 1115 size_t pos = 0; 1098 list_foreach(services_list, services, loc_service_t, service) { 1116 list_foreach(services_list, item) { 1117 loc_service_t *service = 1118 list_get_instance(item, loc_service_t, services); 1119 1099 1120 if (service->namespace == namespace) { 1100 1121 desc[pos].id = service->id; … … 1317 1338 categ_dir_init(&cdir); 1318 1339 1319 cat = category_new("disk"); 1320 categ_dir_add_cat(&cdir, cat); 1321 1322 cat = category_new("partition"); 1340 cat = category_new("bd"); 1323 1341 categ_dir_add_cat(&cdir, cat); 1324 1342 … … 1332 1350 categ_dir_add_cat(&cdir, cat); 1333 1351 1334 cat = category_new("led");1335 categ_dir_add_cat(&cdir, cat);1336 1337 1352 cat = category_new("serial"); 1338 1353 categ_dir_add_cat(&cdir, cat); … … 1355 1370 cat = category_new("nic"); 1356 1371 categ_dir_add_cat(&cdir, cat); 1357 1358 cat = category_new("ieee80211");1359 categ_dir_add_cat(&cdir, cat);1360 1372 1361 1373 cat = category_new("visualizer"); … … 1365 1377 categ_dir_add_cat(&cdir, cat); 1366 1378 1367 cat = category_new("audio-pcm");1368 categ_dir_add_cat(&cdir, cat);1369 1370 1379 return true; 1371 1380 } … … 1374 1383 * 1375 1384 */ 1376 static void loc_connection_supplier(ipc_callid_t iid, ipc_call_t *icall , void *arg)1385 static void loc_connection_supplier(ipc_callid_t iid, ipc_call_t *icall) 1377 1386 { 1378 1387 /* Accept connection */ … … 1432 1441 * 1433 1442 */ 1434 static void loc_connection_consumer(ipc_callid_t iid, ipc_call_t *icall , void *arg)1443 static void loc_connection_consumer(ipc_callid_t iid, ipc_call_t *icall) 1435 1444 { 1436 1445 /* Accept connection */ … … 1499 1508 } 1500 1509 1510 /** Function for handling connections to location service 1511 * 1512 */ 1513 static void loc_connection(ipc_callid_t iid, ipc_call_t *icall, void *arg) 1514 { 1515 /* Select interface */ 1516 switch ((sysarg_t) (IPC_GET_ARG1(*icall))) { 1517 case LOC_PORT_SUPPLIER: 1518 loc_connection_supplier(iid, icall); 1519 break; 1520 case LOC_PORT_CONSUMER: 1521 loc_connection_consumer(iid, icall); 1522 break; 1523 case LOC_CONNECT_TO_SERVICE: 1524 /* Connect client to selected service */ 1525 loc_forward(iid, icall); 1526 break; 1527 default: 1528 /* No such interface */ 1529 async_answer_0(iid, ENOENT); 1530 } 1531 } 1532 1501 1533 /** 1502 1534 * … … 1511 1543 } 1512 1544 1513 port_id_t port; 1514 int rc = async_create_port(INTERFACE_LOC_SUPPLIER, 1515 loc_connection_supplier, NULL, &port); 1545 /* Set a handler of incomming connections */ 1546 async_set_client_connection(loc_connection); 1547 1548 /* Register location service at naming service */ 1549 int rc = service_register(SERVICE_LOC); 1516 1550 if (rc != EOK) 1517 1551 return rc; 1518 1552 1519 rc = async_create_port(INTERFACE_LOC_CONSUMER,1520 loc_connection_consumer, NULL, &port);1521 if (rc != EOK)1522 return rc;1523 1524 /* Set a handler of incomming connections */1525 async_set_fallback_port_handler(loc_forward, NULL);1526 1527 /* Register location service at naming service */1528 rc = service_register(SERVICE_LOC);1529 if (rc != EOK)1530 return rc;1531 1532 1553 printf("%s: Accepting connections\n", NAME); 1533 1554 async_manager();
Note:
See TracChangeset
for help on using the changeset viewer.