Ignore:
File:
1 edited

Legend:

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

    r455241b r07d4271  
    7171static slab_cache_t *answerbox_cache;
    7272
    73 slab_cache_t *irq_cache = NULL;
    7473slab_cache_t *phone_cache = NULL;
    7574
     
    8887        call->callerbox = NULL;
    8988        call->buffer = NULL;
    90         kobject_initialize(&call->kobject, KOBJECT_TYPE_CALL);
    91 }
    92 
    93 static void call_destroy(kobject_t *arg)
    94 {
    95         call_t *call = call_from_kobject(arg);
     89}
     90
     91static void call_destroy(void *arg)
     92{
     93        call_t *call = (call_t *) arg;
    9694
    9795        if (call->buffer)
    9896                free(call->buffer);
    9997        if (call->caller_phone)
    100                 kobject_put(&call->caller_phone->kobject);
     98                kobject_put(call->caller_phone->kobject);
    10199        slab_free(call_cache, call);
    102100}
     
    116114call_t *ipc_call_alloc(void)
    117115{
     116        // TODO: Allocate call and kobject in single allocation
     117
    118118        call_t *call = slab_alloc(call_cache, FRAME_ATOMIC);
    119119        if (!call)
    120120                return NULL;
    121121
     122        kobject_t *kobj = kobject_alloc(0);
     123        if (!kobj) {
     124                slab_free(call_cache, call);
     125                return NULL;
     126        }
     127
    122128        _ipc_call_init(call);
     129        kobject_initialize(kobj, KOBJECT_TYPE_CALL, call);
     130        call->kobject = kobj;
    123131
    124132        return call;
     
    173181        if (!connected) {
    174182                /* We still have phone->kobject's reference; drop it */
    175                 kobject_put(&phone->kobject);
     183                kobject_put(phone->kobject);
    176184        }
    177185
     
    193201        atomic_store(&phone->active_calls, 0);
    194202        phone->label = 0;
    195         kobject_initialize(&phone->kobject, KOBJECT_TYPE_PHONE);
     203        phone->kobject = NULL;
    196204}
    197205
     
    286294                /* This is a forgotten call and call->sender is not valid. */
    287295                spinlock_unlock(&call->forget_lock);
    288                 kobject_put(&call->kobject);
     296                kobject_put(call->kobject);
    289297                return;
    290298        } else {
     
    344352
    345353        call->caller_phone = phone;
    346         kobject_add_ref(&phone->kobject);
     354        kobject_add_ref(phone->kobject);
    347355
    348356        if (preforget) {
     
    354362                else
    355363                        atomic_inc(&caller->answerbox.active_calls);
    356                 kobject_add_ref(&phone->kobject);
     364                kobject_add_ref(phone->kobject);
    357365                call->sender = caller;
    358366                call->active = true;
     
    471479
    472480                /* Drop the answerbox reference */
    473                 kobject_put(&phone->kobject);
     481                kobject_put(phone->kobject);
    474482
    475483                call_t *call = phone->hangup_call;
     
    573581                atomic_dec(&request->caller_phone->active_calls);
    574582                atomic_dec(&box->active_calls);
    575                 kobject_put(&request->caller_phone->kobject);
     583                kobject_put(request->caller_phone->kobject);
    576584        } else if (!list_empty(&box->calls)) {
    577585                /* Count received call */
     
    689697                        task_release(phone->caller);
    690698
    691                         kobject_put(&phone->kobject);
     699                        kobject_put(phone->kobject);
    692700
    693701                        /* Must start again */
     
    696704
    697705                mutex_unlock(&phone->lock);
    698                 kobject_put(&phone->kobject);
     706                kobject_put(phone->kobject);
    699707        }
    700708
     
    720728         * must hold a reference to it.
    721729         */
    722         kobject_add_ref(&call->kobject);
     730        kobject_add_ref(call->kobject);
    723731
    724732        spinlock_unlock(&call->forget_lock);
     
    727735        atomic_dec(&call->caller_phone->active_calls);
    728736        atomic_dec(&TASK->answerbox.active_calls);
    729         kobject_put(&call->caller_phone->kobject);
     737        kobject_put(call->caller_phone->kobject);
    730738
    731739        SYSIPC_OP(request_forget, call);
    732740
    733         kobject_put(&call->kobject);
     741        kobject_put(call->kobject);
    734742}
    735743
     
    769777static bool phone_cap_cleanup_cb(cap_t *cap, void *arg)
    770778{
    771         ipc_phone_hangup(phone_from_kobject(cap->kobject));
     779        ipc_phone_hangup(cap->kobject->phone);
    772780        kobject_t *kobj = cap_unpublish(cap->task, cap->handle,
    773781            KOBJECT_TYPE_PHONE);
     
    790798                SYSIPC_OP(answer_process, call);
    791799
    792                 kobject_put(&call->kobject);
     800                kobject_put(call->kobject);
    793801
    794802                /*
     
    884892        answerbox_cache = slab_cache_create("answerbox_t", sizeof(answerbox_t),
    885893            0, NULL, NULL, 0);
    886         irq_cache = slab_cache_create("irq_t", sizeof(irq_kobject_t),
    887             0, NULL, NULL, 0);
    888894}
    889895
     
    921927static bool print_task_phone_cb(cap_t *cap, void *arg)
    922928{
    923         phone_t *phone = phone_from_kobject(cap->kobject);
     929        phone_t *phone = cap->kobject->phone;
    924930
    925931        mutex_lock(&phone->lock);
Note: See TracChangeset for help on using the changeset viewer.