Rev 4422 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4422 | Rev 4430 | ||
---|---|---|---|
Line 353... | Line 353... | ||
353 | switch (IPC_GET_METHOD(call->data)) { |
353 | switch (IPC_GET_METHOD(call->data)) { |
354 | case IPC_M_CONNECTION_CLONE: { |
354 | case IPC_M_CONNECTION_CLONE: { |
355 | phone_t *cloned_phone; |
355 | phone_t *cloned_phone; |
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 (phone == cloned_phone) |
- | |
359 | return EEXISTS; |
- | |
360 | if (cloned_phone < phone) { |
358 | if (cloned_phone < phone) { |
361 | mutex_lock(&cloned_phone->lock); |
359 | mutex_lock(&cloned_phone->lock); |
362 | mutex_lock(&phone->lock); |
360 | mutex_lock(&phone->lock); |
363 | } else { |
361 | } else if (cloned_phone > phone) { |
364 | mutex_lock(&phone->lock); |
362 | mutex_lock(&phone->lock); |
365 | mutex_lock(&cloned_phone->lock); |
363 | mutex_lock(&cloned_phone->lock); |
- | 364 | } else { |
|
- | 365 | mutex_lock(&phone->lock); |
|
366 | } |
366 | } |
367 | if ((cloned_phone->state != IPC_PHONE_CONNECTED) || |
367 | if ((cloned_phone->state != IPC_PHONE_CONNECTED) || |
368 | phone->state != IPC_PHONE_CONNECTED) { |
368 | phone->state != IPC_PHONE_CONNECTED) { |
- | 369 | if (cloned_phone != phone) |
|
369 | mutex_unlock(&cloned_phone->lock); |
370 | mutex_unlock(&cloned_phone->lock); |
370 | mutex_unlock(&phone->lock); |
371 | mutex_unlock(&phone->lock); |
371 | return EINVAL; |
372 | return EINVAL; |
372 | } |
373 | } |
373 | /* |
374 | /* |
374 | * 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 376... | Line 377... | ||
376 | * we are effectively preventing them from finishing their |
377 | * we are effectively preventing them from finishing their |
377 | * potential cleanup. |
378 | * potential cleanup. |
378 | */ |
379 | */ |
379 | newphid = phone_alloc(phone->callee->task); |
380 | newphid = phone_alloc(phone->callee->task); |
380 | if (newphid < 0) { |
381 | if (newphid < 0) { |
- | 382 | if (cloned_phone != phone) |
|
381 | mutex_unlock(&cloned_phone->lock); |
383 | mutex_unlock(&cloned_phone->lock); |
382 | mutex_unlock(&phone->lock); |
384 | mutex_unlock(&phone->lock); |
383 | return ELIMIT; |
385 | return ELIMIT; |
384 | } |
386 | } |
385 | ipc_phone_connect(&phone->callee->task->phones[newphid], |
387 | ipc_phone_connect(&phone->callee->task->phones[newphid], |
386 | cloned_phone->callee); |
388 | cloned_phone->callee); |
- | 389 | if (cloned_phone != phone) |
|
387 | mutex_unlock(&cloned_phone->lock); |
390 | mutex_unlock(&cloned_phone->lock); |
388 | mutex_unlock(&phone->lock); |
391 | mutex_unlock(&phone->lock); |
389 | /* Set the new phone for the callee. */ |
392 | /* Set the new phone for the callee. */ |
390 | IPC_SET_ARG1(call->data, newphid); |
393 | IPC_SET_ARG1(call->data, newphid); |
391 | break; |
394 | break; |
392 | } |
395 | } |