Changeset ff381a7 in mainline for uspace/srv/ns/service.c
- Timestamp:
- 2015-11-02T20:54:19Z (8 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- d8513177
- Parents:
- 3feeab2 (diff), 5265eea4 (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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/ns/service.c
r3feeab2 rff381a7 40 40 #include "ns.h" 41 41 42 43 42 /** Service hash table item. */ 44 43 typedef struct { 45 44 ht_link_t link; 46 sysarg_t service; /**< Service ID. */ 47 sysarg_t phone; /**< Phone registered with the service. */ 48 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; 49 54 } hashed_service_t; 50 55 51 52 56 static size_t service_key_hash(void *key) 53 57 { 54 return *(s ysarg_t*)key;58 return *(service_t *) key; 55 59 } 56 60 57 61 static size_t service_hash(const ht_link_t *item) 58 62 { 59 hashed_service_t *hs = hash_table_get_inst(item, hashed_service_t, link); 60 return hs->service; 63 hashed_service_t *service = 64 hash_table_get_inst(item, hashed_service_t, link); 65 66 return service->service; 61 67 } 62 68 63 69 static bool service_key_equal(void *key, const ht_link_t *item) 64 70 { 65 hashed_service_t *hs = hash_table_get_inst(item, hashed_service_t, link); 66 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; 67 75 } 68 76 … … 82 90 typedef struct { 83 91 link_t link; 84 s ysarg_t service; /**< Number of the service.*/85 i pc_callid_t callid; /**< Call ID waiting for the connection*/86 sysarg_t arg2; /**< Second argument*/87 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 */ 88 96 } pending_conn_t; 89 97 … … 92 100 int service_init(void) 93 101 { 94 if (!hash_table_create(&service_hash_table, 0, 0, &service_hash_table_ops)) { 95 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); 96 105 return ENOMEM; 97 106 } … … 106 115 { 107 116 loop: 108 list_foreach(pending_conn, link, pending_conn_t, p r) {109 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); 110 119 if (!link) 111 120 continue; 112 121 113 hashed_service_t *hs = hash_table_get_inst(link, hashed_service_t, link); 114 (void) ipc_forward_fast(pr->callid, hs->phone, pr->arg2, 115 pr->arg3, 0, IPC_FF_NONE); 116 117 list_remove(&pr->link); 118 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 119 129 goto loop; 120 130 } … … 130 140 * 131 141 */ 132 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) 133 143 { 134 144 if (hash_table_find(&service_hash_table, &service)) 135 return EEXISTS; 136 137 hashed_service_t *hs = (hashed_service_t *) malloc(sizeof(hashed_service_t)); 138 if (!hs) 145 return EEXIST; 146 147 hashed_service_t *hashed_service = 148 (hashed_service_t *) malloc(sizeof(hashed_service_t)); 149 if (!hashed_service) 139 150 return ENOMEM; 140 151 141 hs->service = service; 142 hs->phone = phone; 143 hs->in_phone_hash = call->in_phone_hash; 144 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); 145 157 146 158 return EOK; … … 150 162 * 151 163 * @param service Service to be connected to. 164 * @param iface Interface to be connected to. 152 165 * @param call Pointer to call structure. 153 166 * @param callid Call ID of the request. … … 156 169 * 157 170 */ 158 void connect_to_service(sysarg_t service, ipc_call_t *call, ipc_callid_t callid) 159 { 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); 160 176 sysarg_t retval; 161 177 162 178 ht_link_t *link = hash_table_find(&service_hash_table, &service); 163 179 if (!link) { 164 if ( IPC_GET_ARG4(*call)& IPC_FLAG_BLOCKING) {180 if (flags & IPC_FLAG_BLOCKING) { 165 181 /* Blocking connection, add to pending list */ 166 pending_conn_t *p r=182 pending_conn_t *pending = 167 183 (pending_conn_t *) malloc(sizeof(pending_conn_t)); 168 if (!p r) {184 if (!pending) { 169 185 retval = ENOMEM; 170 186 goto out; 171 187 } 172 188 173 link_initialize(&pr->link); 174 pr->service = service; 175 pr->callid = callid; 176 pr->arg2 = IPC_GET_ARG2(*call); 177 pr->arg3 = IPC_GET_ARG3(*call); 178 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); 179 196 return; 180 197 } 198 181 199 retval = ENOENT; 182 200 goto out; 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_ARG2(*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
Note:
See TracChangeset
for help on using the changeset viewer.