Changeset 48bcf49 in mainline for kernel/generic/src/ipc/kbox.c


Ignore:
Timestamp:
2017-09-28T22:08:15Z (8 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
6636fb19
Parents:
dd20cbb
Message:

Introduce reference-counted kobjects

Capabilities are thus reduced to task-local names for references to kobjects.

File:
1 edited

Legend:

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

    rdd20cbb r48bcf49  
    206206 * cleanup code.
    207207 *
    208  * @return Phone capability on success, or negative error code.
     208 * @return Phone capability handle on success, or negative error code.
    209209 *
    210210 */
     
    236236        }
    237237       
    238         int cap = phone_alloc(TASK);
    239         if (cap < 0) {
    240                 mutex_unlock(&task->kb.cleanup_lock);
    241                 return ELIMIT;
    242         }
    243        
     238        cap_handle_t phone_handle = phone_alloc(TASK);
     239        if (phone_handle < 0) {
     240                mutex_unlock(&task->kb.cleanup_lock);
     241                return phone_handle;
     242        }
     243       
     244        kobject_t *phone_obj = kobject_get(TASK, phone_handle,
     245            KOBJECT_TYPE_PHONE);
    244246        /* Connect the newly allocated phone to the kbox */
    245         (void) ipc_phone_connect(phone_get_current(cap), &task->kb.box);
     247        /* Hand over phone_obj's reference to ipc_phone_connect() */
     248        (void) ipc_phone_connect(phone_obj->phone, &task->kb.box);
    246249       
    247250        if (task->kb.thread != NULL) {
    248251                mutex_unlock(&task->kb.cleanup_lock);
    249                 return cap;
     252                return phone_handle;
    250253        }
    251254       
     
    263266        mutex_unlock(&task->kb.cleanup_lock);
    264267       
    265         return cap;
     268        return phone_handle;
    266269}
    267270
Note: See TracChangeset for help on using the changeset viewer.