Changeset ca48672 in mainline for uspace/lib/c
- Timestamp:
- 2025-06-20T15:18:27Z (4 weeks ago)
- Branches:
- master
- Children:
- cb20b05
- Parents:
- 3951046
- Location:
- uspace/lib/c
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/async/ports.c
r3951046 rca48672 197 197 } 198 198 199 static bool destroy_if(ht_link_t *link, void *arg) 200 { 201 port_t *port = (port_t *)arg; 202 203 hash_table_remove_item(&port->interface_hash_table, link); 204 return false; 205 } 206 207 static void async_delete_port(port_t *port) 208 { 209 /* Destroy interfaces */ 210 hash_table_apply(&port->interface_hash_table, destroy_if, NULL); 211 212 hash_table_destroy(&port->interface_hash_table); 213 free(port); 214 } 215 199 216 errno_t async_create_port_internal(iface_t iface, async_port_handler_t handler, 200 217 void *data, port_id_t *port_id) … … 212 229 interface = async_new_interface(port, iface, handler, data); 213 230 if (interface == NULL) { 214 // XXX delete port231 async_delete_port(port); 215 232 fibril_rmutex_unlock(&port_mutex); 216 233 return ENOMEM; … … 218 235 219 236 *port_id = port->id; 237 fibril_rmutex_unlock(&port_mutex); 238 return EOK; 239 } 240 241 errno_t async_port_create_interface(port_id_t port_id, iface_t iface, 242 async_port_handler_t handler, void *data) 243 { 244 ht_link_t *link; 245 port_t *port; 246 interface_t *interface; 247 248 fibril_rmutex_lock(&port_mutex); 249 link = hash_table_find(&port_hash_table, &port_id); 250 assert(link != NULL); 251 port = hash_table_get_inst(link, port_t, link); 252 253 interface = async_new_interface(port, iface, handler, data); 254 if (interface == NULL) { 255 fibril_rmutex_unlock(&port_mutex); 256 return ENOMEM; 257 } 258 220 259 fibril_rmutex_unlock(&port_mutex); 221 260 return EOK; … … 306 345 } 307 346 347 void async_port_destroy(port_id_t port_id) 348 { 349 ht_link_t *link; 350 port_t *port; 351 352 fibril_rmutex_lock(&port_mutex); 353 link = hash_table_find(&port_hash_table, &port_id); 354 assert(link != NULL); 355 port = hash_table_get_inst(link, port_t, link); 356 async_delete_port(port); 357 fibril_rmutex_unlock(&port_mutex); 358 } 359 308 360 /** Initialize the async framework ports. 309 361 * -
uspace/lib/c/generic/loc.c
r3951046 rca48672 1 1 /* 2 * Copyright (c) 202 3Jiri Svoboda2 * Copyright (c) 2025 Jiri Svoboda 3 3 * Copyright (c) 2007 Josef Cejka 4 4 * All rights reserved. … … 258 258 * @param srv Server object 259 259 * @param fqsn Fully qualified service name 260 * @param portid ID of port providing the service 260 261 * @param sid Service ID of new service 261 262 * 262 263 */ 263 264 errno_t loc_service_register(loc_srv_t *srv, const char *fqsn, 264 service_id_t *sid)265 port_id_t portid, service_id_t *sid) 265 266 { 266 267 async_exch_t *exch = async_exchange_begin(srv->sess); 267 268 ipc_call_t answer; 268 aid_t req = async_send_ 0(exch, LOC_SERVICE_REGISTER, &answer);269 aid_t req = async_send_1(exch, LOC_SERVICE_REGISTER, portid, &answer); 269 270 errno_t retval = async_data_write_start(exch, fqsn, str_size(fqsn)); 270 271 -
uspace/lib/c/generic/ns.c
r3951046 rca48672 1 1 /* 2 * Copyright (c) 2025 Jiri Svoboda 2 3 * Copyright (c) 2011 Martin Decky 3 4 * All rights reserved. … … 68 69 69 70 if (rc != EOK) { 71 async_port_destroy(port); 70 72 async_forget(req); 71 73 return rc; … … 74 76 errno_t retval; 75 77 async_wait_for(req, &retval); 78 79 if (rc != EOK) 80 async_port_destroy(port); 76 81 return rc; 77 82 } -
uspace/lib/c/include/async.h
r3951046 rca48672 1 1 /* 2 * Copyright (c) 2025 Jiri Svoboda 2 3 * Copyright (c) 2006 Ondrej Palkovsky 3 4 * All rights reserved. … … 99 100 } exch_mgmt_t; 100 101 102 enum { 103 fallback_port_id = 0 104 }; 105 101 106 /** Forward declarations */ 102 107 struct async_exch; … … 134 139 extern errno_t async_create_port(iface_t, async_port_handler_t, void *, 135 140 port_id_t *); 141 extern void async_port_destroy(port_id_t); 142 extern errno_t async_port_create_interface(port_id_t, iface_t, 143 async_port_handler_t, void *); 136 144 extern void async_set_fallback_port_handler(async_port_handler_t, void *); 137 145 extern errno_t async_create_callback_port(async_exch_t *, iface_t, sysarg_t, -
uspace/lib/c/include/loc.h
r3951046 rca48672 1 1 /* 2 * Copyright (c) 202 3Jiri Svoboda2 * Copyright (c) 2025 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 49 49 extern errno_t loc_server_register(const char *, loc_srv_t **); 50 50 extern void loc_server_unregister(loc_srv_t *); 51 extern errno_t loc_service_register(loc_srv_t *, const char *, service_id_t *); 51 extern errno_t loc_service_register(loc_srv_t *, const char *, port_id_t, 52 service_id_t *); 52 53 extern errno_t loc_service_unregister(loc_srv_t *, service_id_t); 53 54 extern errno_t loc_service_add_to_cat(loc_srv_t *, service_id_t, category_id_t); -
uspace/lib/c/test/loc.c
r3951046 rca48672 1 1 /* 2 * Copyright (c) 202 3Jiri Svoboda2 * Copyright (c) 2025 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 51 51 52 52 // XXX Without a unique name this is not reentrant 53 rc = loc_service_register(sa, "test/libc-service-a", &svca); 53 rc = loc_service_register(sa, "test/libc-service-a", 54 fallback_port_id, &svca); 54 55 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 55 56 56 57 // XXX Without a unique name this is not reentrant 57 rc = loc_service_register(sb, "test/libc-service-b", &svcb); 58 rc = loc_service_register(sb, "test/libc-service-b", 59 fallback_port_id, &svcb); 58 60 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 59 61
Note:
See TracChangeset
for help on using the changeset viewer.