Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset c713aa56 in mainline


Ignore:
Timestamp:
2010-01-30T15:31:59Z (10 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
master
Children:
89ee7ff
Parents:
e7aa9f4
Message:

Do not deadlock when the task cleans up messages it sent itself.

File:
1 edited

Legend:

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

    re7aa9f4 rc713aa56  
    212212 *
    213213 * @param call          Call structure to be answered.
    214  */
    215 static void _ipc_answer_free_call(call_t *call)
     214 * @param selflocked    If true, then TASK->answebox is locked.
     215 */
     216static void _ipc_answer_free_call(call_t *call, bool selflocked)
    216217{
    217218        answerbox_t *callerbox = call->callerbox;
     219        bool do_lock = ((!selflocked) || callerbox != (&TASK->answerbox));
    218220
    219221        call->flags |= IPC_CALL_ANSWERED;
     
    226228        }
    227229
    228         spinlock_lock(&callerbox->lock);
     230        if (do_lock)
     231                spinlock_lock(&callerbox->lock);
    229232        list_append(&call->link, &callerbox->answers);
    230         spinlock_unlock(&callerbox->lock);
     233        if (do_lock)
     234                spinlock_unlock(&callerbox->lock);
    231235        waitq_wakeup(&callerbox->wq, WAKEUP_FIRST);
    232236}
     
    244248        spinlock_unlock(&box->lock);
    245249        /* Send back answer */
    246         _ipc_answer_free_call(call);
     250        _ipc_answer_free_call(call, false);
    247251}
    248252
     
    261265        atomic_inc(&phone->active_calls);
    262266        IPC_SET_RETVAL(call->data, err);
    263         _ipc_answer_free_call(call);
     267        _ipc_answer_free_call(call, false);
    264268}
    265269
     
    300304                if (call->flags & IPC_CALL_FORWARDED) {
    301305                        IPC_SET_RETVAL(call->data, EFORWARD);
    302                         _ipc_answer_free_call(call);
     306                        _ipc_answer_free_call(call, false);
    303307                } else {
    304308                        if (phone->state == IPC_PHONE_HUNGUP)
     
    455459
    456460                IPC_SET_RETVAL(call->data, EHANGUP);
    457                 _ipc_answer_free_call(call);
     461                _ipc_answer_free_call(call, true);
    458462        }
    459463}
Note: See TracChangeset for help on using the changeset viewer.