Changeset 26a6ed4 in mainline for kernel/generic/src/ipc/ipcrsc.c


Ignore:
Timestamp:
2018-03-11T07:35:05Z (7 years ago)
Author:
Jakub Jermar <jakub@…>
Children:
bbf38ad
Parents:
813fc8c
git-author:
Jakub Jermar <jakub@…> (2018-03-10 18:18:12)
git-committer:
Jakub Jermar <jakub@…> (2018-03-11 07:35:05)
Message:

Allow phone_alloc to not publish the capability

This makes it possible and race-free to defer publishing the new
capability until the phone object is connected.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/ipc/ipcrsc.c

    r813fc8c r26a6ed4  
    150150/** Allocate new phone in the specified task.
    151151 *
    152  * @param task  Task for which to allocate a new phone.
    153  *
    154  * @param[out] out_handle  New phone capability handle.
     152 * @param[in]  task     Task for which to allocate a new phone.
     153 * @param[in]  publish  If true, the new capability will be published.
     154 * @param[out] phandle  New phone capability handle.
     155 * @param[out] kobject  New phone kobject.
    155156 *
    156157 * @return  An error code if a new capability cannot be allocated.
    157158 */
    158 errno_t phone_alloc(task_t *task, cap_handle_t *out_handle)
     159errno_t phone_alloc(task_t *task, bool publish, cap_handle_t *phandle,
     160    kobject_t **kobject)
    159161{
    160162        cap_handle_t handle;
     
    166168                        return ENOMEM;
    167169                }
    168                 kobject_t *kobject = malloc(sizeof(kobject_t), FRAME_ATOMIC);
    169                 if (!kobject) {
     170                kobject_t *kobj = malloc(sizeof(kobject_t), FRAME_ATOMIC);
     171                if (!kobj) {
    170172                        cap_free(TASK, handle);
    171173                        slab_free(phone_cache, phone);
     
    176178                phone->state = IPC_PHONE_CONNECTING;
    177179
    178                 kobject_initialize(kobject, KOBJECT_TYPE_PHONE, phone,
     180                kobject_initialize(kobj, KOBJECT_TYPE_PHONE, phone,
    179181                    &phone_kobject_ops);
    180                 phone->kobject = kobject;
    181 
    182                 cap_publish(task, handle, kobject);
    183 
    184                 *out_handle = handle;
     182                phone->kobject = kobj;
     183
     184                if (publish)
     185                        cap_publish(task, handle, kobj);
     186
     187                *phandle = handle;
     188                if (kobject)
     189                        *kobject = kobj;
    185190        }
    186191        return rc;
Note: See TracChangeset for help on using the changeset viewer.