Changeset c33f39f in mainline


Ignore:
Timestamp:
2012-09-04T21:12:43Z (12 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
983cabe8
Parents:
2541646
Message:

Do not establish callback connections after the answerbox enters cleanup.

Location:
kernel/generic
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/include/ipc/ipc.h

    r2541646 rc33f39f  
    7272typedef struct answerbox {
    7373        IRQ_SPINLOCK_DECLARE(lock);
     74
     75        /** Answerbox is active until it enters cleanup. */
     76        bool active;
    7477       
    7578        struct task *task;
     
    171174
    172175extern void ipc_phone_init(phone_t *);
    173 extern void ipc_phone_connect(phone_t *, answerbox_t *);
     176extern bool ipc_phone_connect(phone_t *, answerbox_t *);
    174177extern int ipc_phone_hangup(phone_t *);
    175178
  • kernel/generic/include/ipc/ipcrsc.h

    r2541646 rc33f39f  
    4242extern int phone_get(sysarg_t, phone_t **);
    4343extern int phone_alloc(task_t *);
    44 extern void phone_connect(int, answerbox_t *);
     44extern bool phone_connect(int, answerbox_t *);
    4545extern void phone_dealloc(int);
    4646
  • kernel/generic/src/ipc/ipc.c

    r2541646 rc33f39f  
    137137 * @param phone Initialized phone structure.
    138138 * @param box   Initialized answerbox structure.
    139  *
    140  */
    141 void ipc_phone_connect(phone_t *phone, answerbox_t *box)
    142 {
     139 * @return      True if the phone was connected, false otherwise.
     140 */
     141bool ipc_phone_connect(phone_t *phone, answerbox_t *box)
     142{
     143        bool active;
     144
    143145        mutex_lock(&phone->lock);
    144        
    145         phone->state = IPC_PHONE_CONNECTED;
    146         phone->callee = box;
    147        
    148146        irq_spinlock_lock(&box->lock, true);
    149         list_append(&phone->link, &box->connected_phones);
     147
     148        active = box->active;
     149        if (active) {
     150                phone->state = IPC_PHONE_CONNECTED;
     151                phone->callee = box;
     152                list_append(&phone->link, &box->connected_phones);
     153        }
     154
    150155        irq_spinlock_unlock(&box->lock, true);
    151        
    152156        mutex_unlock(&phone->lock);
     157
     158        return active;
    153159}
    154160
     
    684690void ipc_cleanup(void)
    685691{
     692        /*
     693         * Mark the answerbox as inactive.
     694         *
     695         * The main purpose for doing this is to prevent any pending callback
     696         * connections from getting established beyond this point.
     697         */
     698        irq_spinlock_lock(&TASK->answerbox.lock, true);
     699        TASK->answerbox.active = false;
     700        irq_spinlock_unlock(&TASK->answerbox.lock, true);
     701
    686702        /* Disconnect all our phones ('ipc_phone_hangup') */
    687703        for (size_t i = 0; i < IPC_MAX_PHONES; i++)
  • kernel/generic/src/ipc/ipcrsc.c

    r2541646 rc33f39f  
    241241 * @param phoneid Phone handle to be connected.
    242242 * @param box     Answerbox to which to connect the phone handle.
     243 * @return        True if the phone was connected, false otherwise.
    243244 *
    244245 * The procedure _enforces_ that the user first marks the phone
     
    247248 *
    248249 */
    249 void phone_connect(int phoneid, answerbox_t *box)
     250bool phone_connect(int phoneid, answerbox_t *box)
    250251{
    251252        phone_t *phone = &TASK->phones[phoneid];
    252253       
    253254        ASSERT(phone->state == IPC_PHONE_CONNECTING);
    254         ipc_phone_connect(phone, box);
     255        return ipc_phone_connect(phone, box);
    255256}
    256257
  • kernel/generic/src/ipc/kbox.c

    r2541646 rc33f39f  
    4848{
    4949        /*
     50         * Not really needed, just to be consistent with the meaning of
     51         * answerbox_t.active.
     52         */
     53        irq_spinlock_lock(&TASK->kb.box.lock, true);
     54        TASK->kb.box.active = false;
     55        irq_spinlock_unlock(&TASK->kb.box.lock, true);
     56
     57        /*
    5058         * Only hold kb.cleanup_lock while setting kb.finished -
    5159         * this is enough.
     
    234242       
    235243        /* Connect the newly allocated phone to the kbox */
    236         ipc_phone_connect(&TASK->phones[newphid], &task->kb.box);
     244        (void) ipc_phone_connect(&TASK->phones[newphid], &task->kb.box);
    237245       
    238246        if (task->kb.thread != NULL) {
  • kernel/generic/src/ipc/ops/conctmeto.c

    r2541646 rc33f39f  
    6565        /* If the user accepted call, connect */
    6666        if (IPC_GET_RETVAL(answer->data) == EOK)
    67                 ipc_phone_connect(phone, &TASK->answerbox);
     67                (void) ipc_phone_connect(phone, &TASK->answerbox);
    6868
    6969        return EOK;
  • kernel/generic/src/ipc/ops/concttome.c

    r2541646 rc33f39f  
    7373        } else if (phoneid >= 0) {
    7474                /* The connection was accepted */
    75                 phone_connect(phoneid, &answer->sender->answerbox);
    76                 /* Set 'phone hash' as arg5 of response */
    77                 IPC_SET_ARG5(answer->data, (sysarg_t) &TASK->phones[phoneid]);
     75                if (phone_connect(phoneid, &answer->sender->answerbox)) {
     76                        /* Set 'phone hash' as arg5 of response */
     77                        IPC_SET_ARG5(answer->data,
     78                            (sysarg_t) &TASK->phones[phoneid]);
     79                } else {
     80                        /* The answerbox is shutting down. */
     81                        IPC_SET_RETVAL(answer->data, ENOENT);
     82                        answer_cleanup(answer, olddata);
     83                }
    7884        } else {
    7985                IPC_SET_RETVAL(answer->data, ELIMIT);
  • kernel/generic/src/ipc/ops/connclone.c

    r2541646 rc33f39f  
    8787        }
    8888               
    89         ipc_phone_connect(&phone->callee->task->phones[newphid],
     89        (void) ipc_phone_connect(&phone->callee->task->phones[newphid],
    9090            cloned_phone->callee);
    9191        phones_unlock(cloned_phone, phone);
  • kernel/generic/src/proc/task.c

    r2541646 rc33f39f  
    206206        event_task_init(task);
    207207       
     208        task->answerbox.active = true;
     209
    208210#ifdef CONFIG_UDEBUG
    209211        /* Init debugging stuff */
     
    211213       
    212214        /* Init kbox stuff */
     215        task->kb.box.active = true;
    213216        task->kb.finished = false;
    214217#endif
     
    216219        if ((ipc_phone_0) &&
    217220            (container_check(ipc_phone_0->task->container, task->container)))
    218                 ipc_phone_connect(&task->phones[0], ipc_phone_0);
     221                (void) ipc_phone_connect(&task->phones[0], ipc_phone_0);
    219222       
    220223        btree_create(&task->futexes);
Note: See TracChangeset for help on using the changeset viewer.