Changeset fda19b8 in mainline for uspace/lib/c/generic/async.c


Ignore:
Timestamp:
2018-05-31T15:41:31Z (6 years ago)
Author:
Jiří Zárevúcky <jiri.zarevucky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
49a796f1
Parents:
fc0b2a8
git-author:
Jiří Zárevúcky <jiri.zarevucky@…> (2018-05-31 15:35:24)
git-committer:
Jiří Zárevúcky <jiri.zarevucky@…> (2018-05-31 15:41:31)
Message:

Deduplicate async_create_port().

File:
1 edited

Legend:

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

    rfc0b2a8 rfda19b8  
    511511static FIBRIL_CONDVAR_INITIALIZE(avail_phone_cv);
    512512
    513 errno_t async_create_port(iface_t iface, async_port_handler_t handler,
    514     void *data, port_id_t *port_id)
    515 {
    516         if ((iface & IFACE_MOD_MASK) == IFACE_MOD_CALLBACK)
    517                 return EINVAL;
    518 
     513static errno_t async_create_port_internal(iface_t iface,
     514    async_port_handler_t handler, void *data, port_id_t *port_id)
     515{
    519516        interface_t *interface;
    520517
     
    543540
    544541        return EOK;
     542}
     543
     544errno_t async_create_port(iface_t iface, async_port_handler_t handler,
     545    void *data, port_id_t *port_id)
     546{
     547        if ((iface & IFACE_MOD_MASK) == IFACE_MOD_CALLBACK)
     548                return EINVAL;
     549
     550        return async_create_port_internal(iface, handler, data, port_id);
    545551}
    546552
     
    860866            &answer);
    861867
    862         errno_t ret;
    863         async_wait_for(req, &ret);
    864         if (ret != EOK)
    865                 return (errno_t) ret;
     868        errno_t rc;
     869        async_wait_for(req, &rc);
     870        if (rc != EOK)
     871                return rc;
     872
     873        rc = async_create_port_internal(iface, handler, data, port_id);
     874        if (rc != EOK)
     875                return rc;
    866876
    867877        sysarg_t phone_hash = IPC_GET_ARG5(answer);
    868         interface_t *interface;
    869 
    870         futex_down(&async_futex);
    871 
    872         ht_link_t *link = hash_table_find(&interface_hash_table, &iface);
    873         if (link)
    874                 interface = hash_table_get_inst(link, interface_t, link);
    875         else
    876                 interface = async_new_interface(iface);
    877 
    878         if (!interface) {
    879                 futex_up(&async_futex);
    880                 return ENOMEM;
    881         }
    882 
    883         port_t *port = async_new_port(interface, handler, data);
    884         if (!port) {
    885                 futex_up(&async_futex);
    886                 return ENOMEM;
    887         }
    888 
    889         *port_id = port->id;
    890 
    891         futex_up(&async_futex);
    892 
    893878        fid_t fid = async_new_connection(answer.in_task_id, phone_hash,
    894879            CAP_NIL, NULL, handler, data);
Note: See TracChangeset for help on using the changeset viewer.