Subversion Repositories HelenOS

Rev

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

Rev 4420 Rev 4439
Line 356... Line 356...
356
        GET_CHECK_PHONE(cloned_phone, IPC_GET_ARG1(call->data),
356
        GET_CHECK_PHONE(cloned_phone, IPC_GET_ARG1(call->data),
357
            return ENOENT);
357
            return ENOENT);
358
        if (cloned_phone < phone) {
358
        if (cloned_phone < phone) {
359
            mutex_lock(&cloned_phone->lock);
359
            mutex_lock(&cloned_phone->lock);
360
            mutex_lock(&phone->lock);
360
            mutex_lock(&phone->lock);
361
        } else {
361
        } else if (cloned_phone > phone) {
362
            mutex_lock(&phone->lock);
362
            mutex_lock(&phone->lock);
363
            mutex_lock(&cloned_phone->lock);
363
            mutex_lock(&cloned_phone->lock);
-
 
364
        } else {
-
 
365
            mutex_lock(&phone->lock);
364
        }
366
        }
365
        if ((cloned_phone->state != IPC_PHONE_CONNECTED) ||
367
        if ((cloned_phone->state != IPC_PHONE_CONNECTED) ||
366
            phone->state != IPC_PHONE_CONNECTED) {
368
            phone->state != IPC_PHONE_CONNECTED) {
-
 
369
            if (cloned_phone != phone)
367
            mutex_unlock(&cloned_phone->lock);
370
                mutex_unlock(&cloned_phone->lock);
368
            mutex_unlock(&phone->lock);
371
            mutex_unlock(&phone->lock);
369
            return EINVAL;
372
            return EINVAL;
370
        }
373
        }
371
        /*
374
        /*
372
         * We can be pretty sure now that both tasks exist and we are
375
         * We can be pretty sure now that both tasks exist and we are
Line 374... Line 377...
374
         * we are effectively preventing them from finishing their
377
         * we are effectively preventing them from finishing their
375
         * potential cleanup.
378
         * potential cleanup.
376
         */
379
         */
377
        newphid = phone_alloc(phone->callee->task);
380
        newphid = phone_alloc(phone->callee->task);
378
        if (newphid < 0) {
381
        if (newphid < 0) {
-
 
382
            if (cloned_phone != phone)
379
            mutex_unlock(&cloned_phone->lock);
383
                mutex_unlock(&cloned_phone->lock);
380
            mutex_unlock(&phone->lock);
384
            mutex_unlock(&phone->lock);
381
            return ELIMIT;
385
            return ELIMIT;
382
        }
386
        }
383
        ipc_phone_connect(&phone->callee->task->phones[newphid],
387
        ipc_phone_connect(&phone->callee->task->phones[newphid],
384
            cloned_phone->callee);
388
            cloned_phone->callee);
-
 
389
        if (cloned_phone != phone)
385
        mutex_unlock(&cloned_phone->lock);
390
            mutex_unlock(&cloned_phone->lock);
386
        mutex_unlock(&phone->lock);
391
        mutex_unlock(&phone->lock);
387
        /* Set the new phone for the callee. */
392
        /* Set the new phone for the callee. */
388
        IPC_SET_ARG1(call->data, newphid);
393
        IPC_SET_ARG1(call->data, newphid);
389
        break;
394
        break;
390
    }
395
    }