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


Ignore:
Timestamp:
2024-02-23T17:57:23Z (11 months ago)
Author:
GitHub <noreply@…>
Children:
192019f
Parents:
86f862c (diff), 90ba06c (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
git-author:
boba-buba <120932204+boba-buba@…> (2024-02-23 17:57:23)
git-committer:
GitHub <noreply@…> (2024-02-23 17:57:23)
Message:

Merge branch 'HelenOS:master' into topic/packet-capture

File:
1 edited

Legend:

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

    r86f862c rf2cb80a  
    9090                LOG("Join kb.thread.");
    9191                thread_join(TASK->kb.thread);
    92                 thread_put(TASK->kb.thread);
    9392                LOG("...join done.");
    9493                TASK->kb.thread = NULL;
     
    201200/** Connect phone to a task kernel-box specified by id.
    202201 *
    203  * Note that this is not completely atomic. For optimisation reasons, the task
    204  * might start cleaning up kbox after the phone has been connected and before
    205  * a kbox thread has been created. This must be taken into account in the
    206  * cleanup code.
    207  *
    208202 * @param[out] out_phone  Phone capability handle on success.
    209203 * @return Error code.
     
    212206errno_t ipc_connect_kbox(task_id_t taskid, cap_phone_handle_t *out_phone)
    213207{
    214         irq_spinlock_lock(&tasks_lock, true);
    215 
    216208        task_t *task = task_find_by_id(taskid);
    217         if (task == NULL) {
    218                 irq_spinlock_unlock(&tasks_lock, true);
     209        if (!task)
    219210                return ENOENT;
    220         }
    221 
    222         atomic_inc(&task->refcount);
    223 
    224         irq_spinlock_unlock(&tasks_lock, true);
    225211
    226212        mutex_lock(&task->kb.cleanup_lock);
    227 
    228         if (atomic_predec(&task->refcount) == 0) {
    229                 mutex_unlock(&task->kb.cleanup_lock);
    230                 task_destroy(task);
    231                 return ENOENT;
    232         }
    233213
    234214        if (task->kb.finished) {
    235215                mutex_unlock(&task->kb.cleanup_lock);
     216                task_release(task);
    236217                return EINVAL;
    237218        }
     
    244225                if (!kb_thread) {
    245226                        mutex_unlock(&task->kb.cleanup_lock);
     227                        task_release(task);
    246228                        return ENOMEM;
    247229                }
    248230
    249                 task->kb.thread = thread_ref(kb_thread);
    250                 thread_ready(kb_thread);
     231                task->kb.thread = kb_thread;
     232                thread_start(kb_thread);
    251233        }
    252234
     
    256238        if (rc != EOK) {
    257239                mutex_unlock(&task->kb.cleanup_lock);
     240                task_release(task);
    258241                return rc;
    259242        }
     
    266249
    267250        mutex_unlock(&task->kb.cleanup_lock);
     251        task_release(task);
    268252        *out_phone = phone_handle;
    269253        return EOK;
Note: See TracChangeset for help on using the changeset viewer.