Changeset 9cfbf2f in mainline
- Timestamp:
- 2015-08-22T03:53:34Z (9 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 57dea62
- Parents:
- 1a522e5
- Location:
- uspace/srv/ns
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/ns/clonable.c
r1a522e5 r9cfbf2f 46 46 typedef struct { 47 47 link_t link; 48 s ysarg_t service;49 i pc_call_t call;48 service_t service; 49 iface_t iface; 50 50 ipc_callid_t callid; 51 sysarg_t arg3; 51 52 } cs_req_t; 52 53 … … 61 62 62 63 /** Return true if @a service is clonable. */ 63 bool service_clonable( int service)64 bool service_clonable(service_t service) 64 65 { 65 66 return (service == SERVICE_LOAD); … … 73 74 * 74 75 */ 75 void register_clonable(s ysarg_t service, sysarg_t phone, ipc_call_t *call,76 void register_clonable(service_t service, sysarg_t phone, ipc_call_t *call, 76 77 ipc_callid_t callid) 77 78 { 78 link_t *req_link; 79 80 req_link = list_first(&cs_req); 79 link_t *req_link = list_first(&cs_req); 81 80 if (req_link == NULL) { 82 81 /* There was no pending connection request. */ … … 94 93 ipc_answer_0(callid, EOK); 95 94 96 ipc_forward_fast(csr->callid, phone, IPC_GET_ARG1(csr->call),97 IPC_ GET_ARG3(csr->call), 0, IPC_FF_NONE);95 ipc_forward_fast(csr->callid, phone, csr->iface, csr->arg3, 0, 96 IPC_FF_NONE); 98 97 99 98 free(csr); … … 104 103 * 105 104 * @param service Service to be connected to. 105 * @param iface Interface to be connected to. 106 106 * @param call Pointer to call structure. 107 107 * @param callid Call ID of the request. … … 110 110 * 111 111 */ 112 void connect_to_clonable(s ysarg_t service, ipc_call_t *call,112 void connect_to_clonable(service_t service, iface_t iface, ipc_call_t *call, 113 113 ipc_callid_t callid) 114 114 { … … 132 132 link_initialize(&csr->link); 133 133 csr->service = service; 134 csr-> call = *call;134 csr->iface = iface; 135 135 csr->callid = callid; 136 csr->arg3 = IPC_GET_ARG3(*call); 136 137 137 138 /* -
uspace/srv/ns/clonable.h
r1a522e5 r9cfbf2f 36 36 #include <ipc/common.h> 37 37 #include <sys/types.h> 38 #include <ipc/services.h> 39 #include <abi/ipc/interfaces.h> 38 40 #include <stdbool.h> 39 41 40 42 extern int clonable_init(void); 41 43 42 extern bool service_clonable(int); 43 extern void register_clonable(sysarg_t, sysarg_t, ipc_call_t *, ipc_callid_t); 44 extern void connect_to_clonable(sysarg_t, ipc_call_t *, ipc_callid_t); 44 extern bool service_clonable(service_t); 45 extern void register_clonable(service_t, sysarg_t, ipc_call_t *, 46 ipc_callid_t); 47 extern void connect_to_clonable(service_t, iface_t, ipc_call_t *, ipc_callid_t); 45 48 46 49 #endif -
uspace/srv/ns/ns.c
r1a522e5 r9cfbf2f 84 84 break; 85 85 case IPC_M_CONNECT_TO_ME: 86 iface = IPC_GET_ARG1(call);87 86 service = IPC_GET_ARG2(call); 88 87 phone = IPC_GET_ARG5(call); 89 90 (void) iface;91 88 92 89 /* … … 104 101 service = IPC_GET_ARG2(call); 105 102 106 (void) iface;107 108 103 /* 109 104 * Client requests to be connected to a service. 110 105 */ 111 106 if (service_clonable(service)) { 112 connect_to_clonable(service, &call, callid);107 connect_to_clonable(service, iface, &call, callid); 113 108 continue; 114 109 } else { 115 connect_to_service(service, &call, callid);110 connect_to_service(service, iface, &call, callid); 116 111 continue; 117 112 } -
uspace/srv/ns/service.c
r1a522e5 r9cfbf2f 43 43 typedef struct { 44 44 ht_link_t link; 45 sysarg_t service; /**< Service ID. */ 46 sysarg_t phone; /**< Phone registered with the service. */ 47 sysarg_t in_phone_hash; /**< Incoming phone hash. */ 45 46 /** Service ID */ 47 service_t service; 48 49 /** Phone registered with the interface */ 50 sysarg_t phone; 51 52 /** Incoming phone hash */ 53 sysarg_t in_phone_hash; 48 54 } hashed_service_t; 49 55 50 51 56 static size_t service_key_hash(void *key) 52 57 { 53 return *(s ysarg_t*)key;58 return *(service_t *) key; 54 59 } 55 60 56 61 static size_t service_hash(const ht_link_t *item) 57 62 { 58 hashed_service_t *hs = hash_table_get_inst(item, hashed_service_t, link); 59 return hs->service; 63 hashed_service_t *service = 64 hash_table_get_inst(item, hashed_service_t, link); 65 66 return service->service; 60 67 } 61 68 62 69 static bool service_key_equal(void *key, const ht_link_t *item) 63 70 { 64 hashed_service_t *hs = hash_table_get_inst(item, hashed_service_t, link); 65 return hs->service == *(sysarg_t*)key; 71 hashed_service_t *service = 72 hash_table_get_inst(item, hashed_service_t, link); 73 74 return service->service == *(service_t *) key; 66 75 } 67 76 … … 81 90 typedef struct { 82 91 link_t link; 83 s ysarg_t service; /**< Number of the service.*/84 i pc_callid_t callid; /**< Call ID waiting for the connection*/85 sysarg_t iface; /**< Interface argument*/86 sysarg_t arg3; 92 service_t service; /**< Service ID */ 93 iface_t iface; /**< Interface ID */ 94 ipc_callid_t callid; /**< Call ID waiting for the connection */ 95 sysarg_t arg3; /**< Third argument */ 87 96 } pending_conn_t; 88 97 … … 91 100 int service_init(void) 92 101 { 93 if (!hash_table_create(&service_hash_table, 0, 0, &service_hash_table_ops)) { 94 printf(NAME ": No memory available for services\n"); 102 if (!hash_table_create(&service_hash_table, 0, 0, 103 &service_hash_table_ops)) { 104 printf("%s: No memory available for services\n", NAME); 95 105 return ENOMEM; 96 106 } … … 105 115 { 106 116 loop: 107 list_foreach(pending_conn, link, pending_conn_t, p r) {108 ht_link_t *link = hash_table_find(&service_hash_table, &p r->service);117 list_foreach(pending_conn, link, pending_conn_t, pending) { 118 ht_link_t *link = hash_table_find(&service_hash_table, &pending->service); 109 119 if (!link) 110 120 continue; 111 121 112 hashed_service_t *hs = hash_table_get_inst(link, hashed_service_t, link); 113 (void) ipc_forward_fast(pr->callid, hs->phone, pr->iface, pr->arg3, 0, 114 IPC_FF_NONE); 115 116 list_remove(&pr->link); 117 free(pr); 122 hashed_service_t *hashed_service = hash_table_get_inst(link, hashed_service_t, link); 123 (void) ipc_forward_fast(pending->callid, hashed_service->phone, 124 pending->iface, pending->arg3, 0, IPC_FF_NONE); 125 126 list_remove(&pending->link); 127 free(pending); 128 118 129 goto loop; 119 130 } … … 129 140 * 130 141 */ 131 int register_service(s ysarg_t service, sysarg_t phone, ipc_call_t *call)142 int register_service(service_t service, sysarg_t phone, ipc_call_t *call) 132 143 { 133 144 if (hash_table_find(&service_hash_table, &service)) 134 145 return EEXISTS; 135 146 136 hashed_service_t *hs = (hashed_service_t *) malloc(sizeof(hashed_service_t)); 137 if (!hs) 147 hashed_service_t *hashed_service = 148 (hashed_service_t *) malloc(sizeof(hashed_service_t)); 149 if (!hashed_service) 138 150 return ENOMEM; 139 151 140 hs->service = service; 141 hs->phone = phone; 142 hs->in_phone_hash = call->in_phone_hash; 143 hash_table_insert(&service_hash_table, &hs->link); 152 hashed_service->service = service; 153 hashed_service->phone = phone; 154 hashed_service->in_phone_hash = call->in_phone_hash; 155 156 hash_table_insert(&service_hash_table, &hashed_service->link); 144 157 145 158 return EOK; … … 149 162 * 150 163 * @param service Service to be connected to. 164 * @param iface Interface to be connected to. 151 165 * @param call Pointer to call structure. 152 166 * @param callid Call ID of the request. … … 155 169 * 156 170 */ 157 void connect_to_service(sysarg_t service, ipc_call_t *call, ipc_callid_t callid) 158 { 171 void connect_to_service(service_t service, iface_t iface, ipc_call_t *call, 172 ipc_callid_t callid) 173 { 174 sysarg_t arg3 = IPC_GET_ARG3(*call); 175 sysarg_t flags = IPC_GET_ARG4(*call); 159 176 sysarg_t retval; 160 177 161 178 ht_link_t *link = hash_table_find(&service_hash_table, &service); 162 179 if (!link) { 163 if ( IPC_GET_ARG4(*call)& IPC_FLAG_BLOCKING) {180 if (flags & IPC_FLAG_BLOCKING) { 164 181 /* Blocking connection, add to pending list */ 165 pending_conn_t *p r=182 pending_conn_t *pending = 166 183 (pending_conn_t *) malloc(sizeof(pending_conn_t)); 167 if (!p r) {184 if (!pending) { 168 185 retval = ENOMEM; 169 186 goto out; 170 187 } 171 188 172 link_initialize(&pr->link); 173 pr->service = service; 174 pr->callid = callid; 175 pr->iface = IPC_GET_ARG1(*call); 176 pr->arg3 = IPC_GET_ARG3(*call); 177 list_append(&pr->link, &pending_conn); 189 link_initialize(&pending->link); 190 pending->service = service; 191 pending->iface = iface; 192 pending->callid = callid; 193 pending->arg3 = arg3; 194 195 list_append(&pending->link, &pending_conn); 178 196 return; 179 197 } … … 183 201 } 184 202 185 hashed_service_t *h s= hash_table_get_inst(link, hashed_service_t, link);186 (void) ipc_forward_fast(callid, h s->phone, IPC_GET_ARG1(*call),187 IPC_GET_ARG3(*call),0, IPC_FF_NONE);203 hashed_service_t *hashed_service = hash_table_get_inst(link, hashed_service_t, link); 204 (void) ipc_forward_fast(callid, hashed_service->phone, iface, arg3, 205 0, IPC_FF_NONE); 188 206 return; 189 207 -
uspace/srv/ns/service.h
r1a522e5 r9cfbf2f 36 36 #include <sys/types.h> 37 37 #include <ipc/common.h> 38 #include <ipc/services.h> 39 #include <abi/ipc/interfaces.h> 38 40 39 41 extern int service_init(void); 40 42 extern void process_pending_conn(void); 41 43 42 extern int register_service(s ysarg_t, sysarg_t, ipc_call_t *);43 extern void connect_to_service(s ysarg_t, ipc_call_t *, ipc_callid_t);44 extern int register_service(service_t, sysarg_t, ipc_call_t *); 45 extern void connect_to_service(service_t, iface_t, ipc_call_t *, ipc_callid_t); 44 46 45 47 #endif
Note:
See TracChangeset
for help on using the changeset viewer.