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


Ignore:
Timestamp:
2017-12-09T18:04:23Z (6 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
0722869
Parents:
569a51a
Message:

Properly handle errors in SYS_IPC_KBOX.

Also, merge the separate 32/64-bit versions.
There is no reason to optimize such a function this way.

File:
1 edited

Legend:

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

    r569a51a r0016674  
    232232        }
    233233       
    234         if (task->kb.finished != false) {
     234        if (task->kb.finished) {
    235235                mutex_unlock(&task->kb.cleanup_lock);
    236236                return EINVAL;
    237237        }
    238238       
     239        /* Create a kbox thread if necessary. */
     240        if (task->kb.thread == NULL) {
     241                thread_t *kb_thread = thread_create(kbox_thread_proc, NULL, task,
     242                    THREAD_FLAG_NONE, "kbox");
     243               
     244                if (!kb_thread) {
     245                        mutex_unlock(&task->kb.cleanup_lock);
     246                        return ENOMEM;
     247                }
     248               
     249                task->kb.thread = kb_thread;
     250                thread_ready(kb_thread);
     251        }
     252       
     253        /* Allocate a new phone. */
    239254        cap_handle_t phone_handle = phone_alloc(TASK);
    240255        if (phone_handle < 0) {
     
    249264        (void) ipc_phone_connect(phone_obj->phone, &task->kb.box);
    250265       
    251         if (task->kb.thread != NULL) {
    252                 mutex_unlock(&task->kb.cleanup_lock);
    253                 *out_phone = phone_handle;
    254                 return EOK;
    255         }
    256        
    257         /* Create a kbox thread */
    258         thread_t *kb_thread = thread_create(kbox_thread_proc, NULL, task,
    259             THREAD_FLAG_NONE, "kbox");
    260         if (!kb_thread) {
    261                 // FIXME: Shouldn't we clean up phone_handle?
    262                 mutex_unlock(&task->kb.cleanup_lock);
    263                 return ENOMEM;
    264         }
    265        
    266         task->kb.thread = kb_thread;
    267         thread_ready(kb_thread);
    268        
    269266        mutex_unlock(&task->kb.cleanup_lock);
    270        
    271267        *out_phone = phone_handle;
    272268        return EOK;
Note: See TracChangeset for help on using the changeset viewer.