Changeset af6bd113 in mainline


Ignore:
Timestamp:
2018-03-11T07:35:05Z (6 years ago)
Author:
Jakub Jermar <jakub@…>
Children:
03d5697
Parents:
bbf38ad
git-author:
Jakub Jermar <jakub@…> (2018-03-10 19:59:41)
git-committer:
Jakub Jermar <jakub@…> (2018-03-11 07:35:05)
Message:

Hang up phones connected during ipc_cleanup()

If an answer to IPC_M_CONNECT_ME_TO arrives during ipc_cleanup(),
new phone capabilities may be published. We need to hang up these new
phones too.

File:
1 edited

Legend:

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

    rbbf38ad raf6bd113  
    753753}
    754754
    755 /** Wait for all answers to asynchronous calls to arrive. */
    756 static void ipc_wait_for_all_answered_calls(void)
    757 {
    758         while (atomic_get(&TASK->answerbox.active_calls) != 0) {
    759                 call_t *call = ipc_wait_for_call(&TASK->answerbox,
    760                     SYNCH_NO_TIMEOUT, SYNCH_FLAGS_NONE);
    761                 assert(call->flags & (IPC_CALL_ANSWERED | IPC_CALL_NOTIF));
    762 
    763                 SYSIPC_OP(answer_process, call);
    764 
    765                 kobject_put(call->kobject);
    766         }
    767 }
    768 
    769755static bool phone_cap_cleanup_cb(cap_t *cap, void *arg)
    770756{
     
    775761        cap_free(cap->task, cap->handle);
    776762        return true;
     763}
     764
     765/** Wait for all answers to asynchronous calls to arrive. */
     766static void ipc_wait_for_all_answered_calls(void)
     767{
     768        while (atomic_get(&TASK->answerbox.active_calls) != 0) {
     769                call_t *call = ipc_wait_for_call(&TASK->answerbox,
     770                    SYNCH_NO_TIMEOUT, SYNCH_FLAGS_NONE);
     771                assert(call->flags & (IPC_CALL_ANSWERED | IPC_CALL_NOTIF));
     772
     773                SYSIPC_OP(answer_process, call);
     774
     775                kobject_put(call->kobject);
     776
     777                /*
     778                 * Now there may be some new phones and new hangup calls to
     779                 * immediately forget.
     780                 */
     781                caps_apply_to_kobject_type(TASK, KOBJECT_TYPE_PHONE,
     782                    phone_cap_cleanup_cb, NULL);
     783                ipc_forget_all_active_calls();
     784        }
    777785}
    778786
     
    814822        irq_spinlock_unlock(&TASK->answerbox.lock, true);
    815823
    816         /* Disconnect all our phones ('ipc_phone_hangup') */
     824        /* Hangup all phones and destroy all phone capabilities */
    817825        caps_apply_to_kobject_type(TASK, KOBJECT_TYPE_PHONE,
    818826            phone_cap_cleanup_cb, NULL);
    819827
    820         /* Unsubscribe from any event notifications. */
     828        /* Unsubscribe from any event notifications */
    821829        event_cleanup_answerbox(&TASK->answerbox);
    822830
     
    844852        ipc_forget_all_active_calls();
    845853        ipc_wait_for_all_answered_calls();
     854
     855        assert(atomic_get(&TASK->answerbox.active_calls) == 0);
    846856}
    847857
Note: See TracChangeset for help on using the changeset viewer.