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