Changeset c33f39f in mainline for kernel/generic/src/ipc/ipc.c


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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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++)
Note: See TracChangeset for help on using the changeset viewer.