Changeset 214c5a0 in mainline


Ignore:
Timestamp:
2006-06-05T10:36:43Z (19 years ago)
Author:
Ondrej Palkovsky <ondrap@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
e090e1bc
Parents:
c778c1a
Message:

Modified ipc_cleanup.

Location:
generic
Files:
3 edited

Legend:

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

    rc778c1a r214c5a0  
    225225extern void task_print_list(void);
    226226extern int ipc_forward(call_t *call, phone_t *newphone, answerbox_t *oldbox);
    227 extern void ipc_cleanup(task_t *task);
     227void ipc_cleanup(void);
    228228extern int ipc_phone_hangup(phone_t *phone, int aggressive);
    229229extern void ipc_backsend_err(phone_t *phone, call_t *call, __native err);
  • generic/src/console/cmd.c

    rc778c1a r214c5a0  
    309309static cmd_info_t ipc_task_info = {
    310310        .name = "ipc_task",
    311         .description = "Show memory zone structure.",
     311        .description = "ipc_task <taskid> Show IPC information of given task",
    312312        .func = cmd_ipc_task,
    313313        .argc = 1,
  • generic/src/ipc/ipc.c

    rc778c1a r214c5a0  
    370370}
    371371
    372 /** Cleans up all IPC communication of the given task
    373  *
    374  *
    375  */
    376 void ipc_cleanup(task_t *task)
     372/** Cleans up all IPC communication of the current task
     373 *
     374 * Note: ipc_hangup sets returning answerbox to TASK->answerbox, you
     375 * have to change it as well if you want to cleanup other current then current.
     376 */
     377void ipc_cleanup(void)
    377378{
    378379        int i;
    379380        call_t *call;
    380381        phone_t *phone;
    381        
     382
    382383        /* Disconnect all our phones ('ipc_phone_hangup') */
    383384        for (i=0;i < IPC_MAX_PHONES; i++)
    384                 ipc_phone_hangup(&task->phones[i], 1);
     385                ipc_phone_hangup(&TASK->phones[i], 1);
    385386
    386387        /* Disconnect all connected irqs */
    387         ipc_irq_cleanup(&task->answerbox);
     388        ipc_irq_cleanup(&TASK->answerbox);
    388389
    389390        /* Disconnect all phones connected to our answerbox */
    390391restart_phones:
    391         spinlock_lock(&task->answerbox.lock);
    392         while (!list_empty(&task->answerbox.connected_phones)) {
    393                 phone = list_get_instance(task->answerbox.connected_phones.next,
     392        spinlock_lock(&TASK->answerbox.lock);
     393        while (!list_empty(&TASK->answerbox.connected_phones)) {
     394                phone = list_get_instance(TASK->answerbox.connected_phones.next,
    394395                                          phone_t, link);
    395396                if (! spinlock_trylock(&phone->lock)) {
    396                         spinlock_unlock(&task->answerbox.lock);
     397                        spinlock_unlock(&TASK->answerbox.lock);
    397398                        goto restart_phones;
    398399                }
     
    407408
    408409        /* Answer all messages in 'calls' and 'dispatched_calls' queues */
    409         spinlock_lock(&task->answerbox.lock);
    410         ipc_cleanup_call_list(&task->answerbox.dispatched_calls);
    411         ipc_cleanup_call_list(&task->answerbox.calls);
    412         spinlock_unlock(&task->answerbox.lock);
     410        ipc_cleanup_call_list(&TASK->answerbox.dispatched_calls);
     411        ipc_cleanup_call_list(&TASK->answerbox.calls);
     412        spinlock_unlock(&TASK->answerbox.lock);
    413413       
    414414        /* Wait for all async answers to arrive */
     
    418418                 * it, when we are in cleanup */
    419419                for (i=0;i < IPC_MAX_PHONES; i++) {
    420                         if (task->phones[i].state == IPC_PHONE_HUNGUP && \
    421                             atomic_get(&task->phones[i].active_calls) == 0)
    422                                 task->phones[i].state = IPC_PHONE_FREE;
    423                         if (task->phones[i].state != IPC_PHONE_FREE)
     420                        if (TASK->phones[i].state == IPC_PHONE_HUNGUP && \
     421                            atomic_get(&TASK->phones[i].active_calls) == 0)
     422                                TASK->phones[i].state = IPC_PHONE_FREE;
     423                       
     424                        if (TASK->phones[i].state == IPC_PHONE_CONNECTED)
     425                                ipc_phone_hangup(&TASK->phones[i], 1);
     426                       
     427                        if (TASK->phones[i].state != IPC_PHONE_FREE)
    424428                                break;
    425429                }
     
    428432                        break;
    429433               
    430                 call = ipc_wait_for_call(&task->answerbox, SYNCH_NO_TIMEOUT, SYNCH_FLAGS_NONE);
     434                call = ipc_wait_for_call(&TASK->answerbox, SYNCH_NO_TIMEOUT, SYNCH_FLAGS_NONE);
    431435                ASSERT((call->flags & IPC_CALL_ANSWERED) || (call->flags & IPC_CALL_NOTIF));
    432436                ASSERT(! (call->flags & IPC_CALL_STATIC_ALLOC));
    433437               
    434                 atomic_dec(&task->active_calls);
     438                atomic_dec(&TASK->active_calls);
    435439                ipc_call_free(call);
    436440        }
Note: See TracChangeset for help on using the changeset viewer.