Subversion Repositories HelenOS-historic

Rev

Rev 1090 | Rev 1258 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1090 Rev 1141
Line 320... Line 320...
320
        request = list_get_instance(box->calls.next, call_t, list);
320
        request = list_get_instance(box->calls.next, call_t, list);
321
        list_remove(&request->list);
321
        list_remove(&request->list);
322
        /* Append request to dispatch queue */
322
        /* Append request to dispatch queue */
323
        list_append(&request->list, &box->dispatched_calls);
323
        list_append(&request->list, &box->dispatched_calls);
324
    } else {
324
    } else {
-
 
325
        /* This can happen regularly after ipc_cleanup, remove
-
 
326
         * the warning in the future when the IPC is
-
 
327
         * more debugged */
325
        printf("WARNING: Spurious IPC wakeup.\n");
328
        printf("WARNING: Spurious IPC wakeup.\n");
326
        spinlock_unlock(&box->lock);
329
        spinlock_unlock(&box->lock);
327
        goto restart;
330
        goto restart;
328
    }
331
    }
329
    spinlock_unlock(&box->lock);
332
    spinlock_unlock(&box->lock);
Line 337... Line 340...
337
                      sizeof(call_t),
340
                      sizeof(call_t),
338
                      0,
341
                      0,
339
                      NULL, NULL, 0);
342
                      NULL, NULL, 0);
340
}
343
}
341
 
344
 
-
 
345
/** Answer all calls from list with EHANGUP msg */
-
 
346
static void ipc_cleanup_call_list(link_t *lst)
-
 
347
{
-
 
348
    call_t *call;
-
 
349
 
-
 
350
    while (!list_empty(lst)) {
-
 
351
        call = list_get_instance(lst->next, call_t, list);
-
 
352
        list_remove(&call->list);
-
 
353
 
-
 
354
        IPC_SET_RETVAL(call->data, EHANGUP);
-
 
355
        _ipc_answer_free_call(call);
-
 
356
    }
-
 
357
}
-
 
358
 
342
/** Cleans up all IPC communication of the given task
359
/** Cleans up all IPC communication of the given task
343
 *
360
 *
344
 *
361
 *
345
 */
362
 */
346
void ipc_cleanup(task_t *task)
363
void ipc_cleanup(task_t *task)
347
{
364
{
348
    int i;
365
    int i;
-
 
366
    call_t *call;
-
 
367
    phone_t *phone;
349
 
368
   
350
    /* Disconnect all our phones ('ipc_phone_hangup') */
369
    /* Disconnect all our phones ('ipc_phone_hangup') */
351
    for (i=0;i < IPC_MAX_PHONES; i++)
370
    for (i=0;i < IPC_MAX_PHONES; i++)
352
        ipc_phone_hangup(&task->phones[i]);
371
        ipc_phone_hangup(&task->phones[i]);
353
 
372
 
354
    /* Disconnect all phones connected to answerbox */
373
    /* Disconnect all phones connected to our answerbox */
-
 
374
restart_phones:
-
 
375
    spinlock_lock(&task->answerbox.lock);
-
 
376
    while (!list_empty(&task->answerbox.connected_phones)) {
-
 
377
        phone = list_get_instance(task->answerbox.connected_phones.next,
-
 
378
                      phone_t,
-
 
379
                      list);
-
 
380
        if (! spinlock_trylock(&phone->lock)) {
-
 
381
            spinlock_unlock(&task->answerbox.lock);
-
 
382
            goto restart_phones;
-
 
383
        }
-
 
384
       
-
 
385
        /* Disconnect phone */
-
 
386
        phone->callee = NULL;
-
 
387
        list_remove(&phone->list);
-
 
388
 
-
 
389
        spinlock_unlock(&phone->lock);
-
 
390
    }
355
 
391
 
356
    /* Answer all messages in 'calls' and 'dispatched_calls' queues */
392
    /* Answer all messages in 'calls' and 'dispatched_calls' queues */
-
 
393
    spinlock_lock(&task->answerbox.lock);
-
 
394
    ipc_cleanup_call_list(&task->answerbox.dispatched_calls);
-
 
395
    ipc_cleanup_call_list(&task->answerbox.calls);
-
 
396
    spinlock_unlock(&task->answerbox.lock);
357
   
397
   
358
    /* Wait for all async answers to arrive */
398
    /* Wait for all async answers to arrive */
-
 
399
    while (atomic_get(&task->active_calls)) {
-
 
400
        call = ipc_wait_for_call(&task->answerbox, 0);
-
 
401
        ASSERT(call->flags & IPC_CALL_ANSWERED);
-
 
402
        ASSERT(! (call->flags & IPC_CALL_STATIC_ALLOC));
-
 
403
       
-
 
404
        atomic_dec(&task->active_calls);
-
 
405
        ipc_call_free(call);
-
 
406
    }
359
}
407
}