Changeset 5559712 in mainline for uspace/srv/locsrv
- Timestamp:
- 2019-08-03T09:28:50Z (6 years ago)
- Children:
- c0e4fc50
- Parents:
- 2dda1d4
- git-author:
- Michal Koutný <xm.koutny+hos@…> (2015-05-07 11:49:47)
- git-committer:
- Matthieu Riolo <matthieu.riolo@…> (2019-08-03 09:28:50)
- Location:
- uspace/srv/locsrv
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/locsrv/Makefile
r2dda1d4 r5559712 29 29 30 30 USPACE_PREFIX = ../.. 31 LIBS = $(LIBSYSMAN_PREFIX)/libsysman.a 32 EXTRA_CFLAGS += -I$(LIBSYSMAN_PREFIX)/include 31 33 BINARY = locsrv 32 34 STATIC_NEEDED = y -
uspace/srv/locsrv/locsrv.c
r2dda1d4 r5559712 36 36 */ 37 37 38 #include <assert.h> 39 #include <async.h> 40 #include <errno.h> 41 #include <ipc/loc.h> 38 42 #include <ipc/services.h> 39 #include <ns.h>40 #include <async.h>41 #include <stdio.h>42 #include <errno.h>43 #include <stdbool.h>44 43 #include <fibril_synch.h> 45 44 #include <macros.h> 45 #include <ns.h> 46 #include <stdbool.h> 47 #include <stdio.h> 46 48 #include <stdlib.h> 47 49 #include <str.h> 48 50 #include <str_error.h> 49 #include < ipc/loc.h>50 #include < assert.h>51 #include <sysman/broker.h> 52 #include <sysman/ctl.h> 51 53 52 54 #include "category.h" … … 331 333 free(service->name); 332 334 free(service); 335 } 336 337 static int loc_service_request_start(const char *ns_name, const char *name) 338 { 339 char *service_name = NULL; 340 341 if (str_cmp(ns_name, LOC_DEVICE_NAMESPACE) == 0) { 342 asprintf(&service_name, "%s", SERVICE_NAME_DEVMAN); 343 } else if (str_cmp(ns_name, "") == 0) { 344 asprintf(&service_name, "%s", name); 345 } else { 346 asprintf(&service_name, "%s%s%s", 347 ns_name, LOC_UNIT_NAMESPACE_SEPARATOR, name); 348 } 349 if (service_name == NULL) { 350 return ENOMEM; 351 } 352 353 char *unit_name; 354 asprintf(&unit_name, "%s%c%s", 355 service_name, UNIT_NAME_SEPARATOR, UNIT_SVC_TYPE_NAME); 356 if (unit_name == NULL) { 357 free(service_name); 358 return ENOMEM; 359 } 360 361 printf("%s(%s) before\n", __func__, unit_name); 362 int rc = sysman_unit_start(unit_name, IPC_FLAG_BLOCKING); 363 printf("%s(%s) after %i\n", __func__, unit_name, rc); 364 free(unit_name); 365 free(service_name); 366 return rc; 333 367 } 334 368 … … 531 565 532 566 list_append(&service->server_services, &service->server->services); 567 568 printf("%s: broadcast new service '%s/%s'\n", NAME, namespace->name, 569 service->name); 533 570 534 571 fibril_mutex_unlock(&service->server->services_mutex); … … 542 579 * 543 580 */ 544 static void loc_service_unregister(ipc_call_t *icall, loc_server_t *server) 581 static void loc_service_unregister(ipc_callid_t iid, ipc_call_t *icall, 582 loc_server_t *server) 545 583 { 546 584 loc_service_t *svc; … … 762 800 fibril_mutex_lock(&services_list_mutex); 763 801 const loc_service_t *svc; 764 802 int flags = ipc_get_arg1(*icall); 803 765 804 recheck: 766 805 … … 771 810 772 811 /* 773 * Device was not found.812 * Service was not found. 774 813 */ 775 814 if (svc == NULL) { 776 if (ipc_get_arg1(icall) & IPC_FLAG_BLOCKING) { 777 /* Blocking lookup */ 815 printf("%s: service '%s/%s' not found\n", NAME, ns_name, name); 816 if (flags & (IPC_FLAG_AUTOSTART | IPC_FLAG_BLOCKING)) { 817 /* TODO: 818 * consider non-blocking service start, return 819 * some dummy id and block only after connection 820 * request (actually makes more sense as those who asks 821 * for ID might be someone else than those connecting) 822 */ 823 if (flags & IPC_FLAG_AUTOSTART) { 824 rc = loc_service_request_start(ns_name, name); 825 if (rc != EOK) { 826 goto finish; 827 } 828 } 829 778 830 fibril_condvar_wait(&services_list_cv, 779 831 &services_list_mutex); 780 832 goto recheck; 781 833 } 782 783 async_answer_0(icall, ENOENT); 784 free(ns_name); 785 free(name); 786 fibril_mutex_unlock(&services_list_mutex); 787 return; 788 } 789 790 async_answer_1(icall, EOK, svc->id); 791 834 rc = ENOENT; 835 } else { 836 printf("%s: service '%s/%s' FOUND\n", NAME, ns_name, name); 837 rc = EOK; 838 } 839 840 finish: 841 if (rc == EOK) { 842 async_answer_1(iid, EOK, svc->id); 843 } else { 844 async_answer_0(iid, rc); 845 } 846 792 847 fibril_mutex_unlock(&services_list_mutex); 793 848 free(ns_name); … … 1565 1620 if (rc != EOK) { 1566 1621 printf("%s: Error while registering broker service: %s\n", NAME, str_error(rc)); 1622 1623 /* Let sysman know we are broker */ 1624 printf("%s: sysman_broker_register : pre\n", NAME); 1625 rc = sysman_broker_register(); 1626 printf("%s: sysman_broker_register : post\n", NAME); 1627 if (rc != EOK) { 1628 printf("%s: Error registering at sysman (%i)\n", NAME, rc); 1567 1629 return rc; 1568 1630 }
Note:
See TracChangeset
for help on using the changeset viewer.
