Changeset ca48672 in mainline for uspace/lib/c/generic/async/ports.c


Ignore:
Timestamp:
2025-06-20T15:18:27Z (35 hours ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master
Children:
cb20b05
Parents:
3951046
Message:

loc_service_register() needs to take a port ID argument.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/async/ports.c

    r3951046 rca48672  
    197197}
    198198
     199static 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
     207static 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
    199216errno_t async_create_port_internal(iface_t iface, async_port_handler_t handler,
    200217    void *data, port_id_t *port_id)
     
    212229        interface = async_new_interface(port, iface, handler, data);
    213230        if (interface == NULL) {
    214                 // XXX delete port
     231                async_delete_port(port);
    215232                fibril_rmutex_unlock(&port_mutex);
    216233                return ENOMEM;
     
    218235
    219236        *port_id = port->id;
     237        fibril_rmutex_unlock(&port_mutex);
     238        return EOK;
     239}
     240
     241errno_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
    220259        fibril_rmutex_unlock(&port_mutex);
    221260        return EOK;
     
    306345}
    307346
     347void 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
    308360/** Initialize the async framework ports.
    309361 *
Note: See TracChangeset for help on using the changeset viewer.