Changeset 97b8ca9 in mainline
- Timestamp:
- 2016-09-11T08:44:04Z (8 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 560b81c
- Parents:
- 0b00599
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/ipc/ipc.c
r0b00599 r97b8ca9 328 328 } 329 329 330 static void _ipc_call_actions_internal(phone_t *phone, call_t *call) 330 static void _ipc_call_actions_internal(phone_t *phone, call_t *call, 331 bool preforget) 331 332 { 332 333 task_t *caller = phone->caller; 333 334 334 atomic_inc(&phone->active_calls);335 335 call->caller_phone = phone; 336 call->sender = caller; 337 338 call->active = true; 339 spinlock_lock(&caller->active_calls_lock); 340 list_append(&call->ta_link, &caller->active_calls); 341 spinlock_unlock(&caller->active_calls_lock); 336 337 if (preforget) { 338 call->forget = true; 339 } else { 340 atomic_inc(&phone->active_calls); 341 call->sender = caller; 342 call->active = true; 343 spinlock_lock(&caller->active_calls_lock); 344 list_append(&call->ta_link, &caller->active_calls); 345 spinlock_unlock(&caller->active_calls_lock); 346 } 342 347 343 348 call->data.phone = phone; … … 357 362 void ipc_backsend_err(phone_t *phone, call_t *call, sysarg_t err) 358 363 { 359 _ipc_call_actions_internal(phone, call );364 _ipc_call_actions_internal(phone, call, false); 360 365 IPC_SET_RETVAL(call->data, err); 361 366 _ipc_answer_free_call(call, false); … … 364 369 /** Unsafe unchecking version of ipc_call. 365 370 * 366 * @param phone Phone structure the call comes from. 367 * @param box Destination answerbox structure. 368 * @param call Call structure with request. 369 * 370 */ 371 static void _ipc_call(phone_t *phone, answerbox_t *box, call_t *call) 371 * @param phone Phone structure the call comes from. 372 * @param box Destination answerbox structure. 373 * @param call Call structure with request. 374 * @param preforget If true, the call will be delivered already forgotten. 375 * 376 */ 377 static void _ipc_call(phone_t *phone, answerbox_t *box, call_t *call, 378 bool preforget) 372 379 { 373 380 task_t *caller = phone->caller; … … 379 386 380 387 if (!(call->flags & IPC_CALL_FORWARDED)) 381 _ipc_call_actions_internal(phone, call );388 _ipc_call_actions_internal(phone, call, preforget); 382 389 383 390 irq_spinlock_lock(&box->lock, true); … … 413 420 414 421 answerbox_t *box = phone->callee; 415 _ipc_call(phone, box, call );422 _ipc_call(phone, box, call, false); 416 423 417 424 mutex_unlock(&phone->lock); … … 451 458 call->request_method = IPC_M_PHONE_HUNGUP; 452 459 call->flags |= IPC_CALL_DISCARD_ANSWER; 453 _ipc_call(phone, box, call );460 _ipc_call(phone, box, call, false); 454 461 } 455 462 … … 610 617 phone_t *phone; 611 618 DEADLOCK_PROBE_INIT(p_phonelck); 612 613 call_t *call = notify_box ? ipc_call_alloc(0) : NULL;614 619 615 620 /* Disconnect all phones connected to our answerbox */ … … 632 637 633 638 if (notify_box) { 639 task_hold(phone->caller); 634 640 mutex_unlock(&phone->lock); 635 641 irq_spinlock_unlock(&box->lock, true); 636 642 637 // FIXME: phone can become deallocated at any time now638 639 643 /* 640 * Send one message to the answerbox for each 641 * phone. Used to make sure the kbox thread 642 * wakes up after the last phone has been 643 * disconnected. 644 * Send one call to the answerbox for each phone. 645 * Used to make sure the kbox thread wakes up after 646 * the last phone has been disconnected. The call is 647 * forgotten upon sending, so the "caller" may cease 648 * to exist as soon as we release it. 644 649 */ 650 call_t *call = ipc_call_alloc(0); 645 651 IPC_SET_IMETHOD(call->data, IPC_M_PHONE_HUNGUP); 646 652 call->request_method = IPC_M_PHONE_HUNGUP; 647 653 call->flags |= IPC_CALL_DISCARD_ANSWER; 648 _ipc_call(phone, box, call); 649 650 /* Allocate another call in advance */ 651 call = ipc_call_alloc(0); 654 _ipc_call(phone, box, call, true); 655 656 task_release(phone->caller); 652 657 653 658 /* Must start again */ … … 659 664 660 665 irq_spinlock_unlock(&box->lock, true); 661 662 /* Free unused call */663 if (call)664 ipc_call_free(call);665 666 } 666 667
Note:
See TracChangeset
for help on using the changeset viewer.