Changeset ca48672 in mainline for uspace/lib/c/generic


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

loc_service_register() needs to take a port ID argument.

Location:
uspace/lib/c/generic
Files:
3 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 *
  • uspace/lib/c/generic/loc.c

    r3951046 rca48672  
    11/*
    2  * Copyright (c) 2023 Jiri Svoboda
     2 * Copyright (c) 2025 Jiri Svoboda
    33 * Copyright (c) 2007 Josef Cejka
    44 * All rights reserved.
     
    258258 * @param srv Server object
    259259 * @param fqsn Fully qualified service name
     260 * @param portid ID of port providing the service
    260261 * @param sid  Service ID of new service
    261262 *
    262263 */
    263264errno_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)
    265266{
    266267        async_exch_t *exch = async_exchange_begin(srv->sess);
    267268        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);
    269270        errno_t retval = async_data_write_start(exch, fqsn, str_size(fqsn));
    270271
  • uspace/lib/c/generic/ns.c

    r3951046 rca48672  
    11/*
     2 * Copyright (c) 2025 Jiri Svoboda
    23 * Copyright (c) 2011 Martin Decky
    34 * All rights reserved.
     
    6869
    6970        if (rc != EOK) {
     71                async_port_destroy(port);
    7072                async_forget(req);
    7173                return rc;
     
    7476        errno_t retval;
    7577        async_wait_for(req, &retval);
     78
     79        if (rc != EOK)
     80                async_port_destroy(port);
    7681        return rc;
    7782}
Note: See TracChangeset for help on using the changeset viewer.