Changeset ca48672 in mainline for uspace/lib/c/generic/async/ports.c
- Timestamp:
- 2025-06-20T15:18:27Z (35 hours ago)
- Branches:
- master
- Children:
- cb20b05
- Parents:
- 3951046
- File:
-
- 1 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 *
Note:
See TracChangeset
for help on using the changeset viewer.