| 512 | } |
| 513 | |
| 514 | static rt_err_t _do_send_recv_timeout(rt_channel_t ch, rt_channel_msg_t data, int need_reply, rt_channel_msg_t data_ret, rt_int32_t time, rt_ipc_msg_t msg) |
| 515 | { |
| 516 | LWP_DEF_RETURN_CODE(rc); |
| 517 | rt_thread_t thread_recv; |
| 518 | rt_thread_t thread_send = 0; |
| 519 | void (*old_timeout_func)(void *) = 0; |
| 520 | rt_base_t level; |
| 521 | |
| 522 | /* IPC message : file descriptor */ |
| 523 | if (data->type == RT_CHANNEL_FD) |
| 524 | { |
| 525 | data->u.fd.file = _ipc_msg_get_file(data->u.fd.fd); |
| 526 | } |
| 527 | |
| 528 | rt_ipc_msg_init(msg, data, need_reply); |
| 529 | |
| 530 | if (need_reply) |
| 531 | { |
| 532 | thread_send = rt_thread_self(); |
| 533 | thread_send->error = RT_EOK; |
| 534 | } |
| 535 | |
| 536 | rc = RT_EOK; |
| 537 | |
| 538 | level = rt_spin_lock_irqsave(&ch->slock); |
| 539 | |
| 540 | switch (ch->stat) |
| 541 | { |
| 542 | case RT_IPC_STAT_IDLE: |
| 543 | case RT_IPC_STAT_ACTIVE: |
| 544 | if (need_reply) |
| 545 | { |
| 546 | rc = rt_channel_list_suspend(&ch->wait_thread, thread_send); |
| 547 | if (rc != RT_EOK) |
| 548 | { |
| 549 | _ipc_msg_free(msg); |
| 550 | } |
| 551 | else |
| 552 | { |
| 553 | rt_thread_wakeup_set(thread_send, wakeup_sender_wait_recv, (void *)ch); |
| 554 | if (time > 0) |
| 555 | { |
| 556 | rt_tick_t time_tick = time; |
| 557 | rt_timer_control(&(thread_send->thread_timer), |
| 558 | RT_TIMER_CTRL_GET_FUNC, |
| 559 | &old_timeout_func); |
| 560 | rt_timer_control(&(thread_send->thread_timer), |
| 561 | RT_TIMER_CTRL_SET_FUNC, |
| 562 | sender_timeout); |
| 563 | /* reset the timeout of thread timer and start it */ |
| 564 | rt_timer_control(&(thread_send->thread_timer), |
| 565 | RT_TIMER_CTRL_SET_TIME, |
| 566 | &time_tick); |
| 567 | rt_timer_start(&(thread_send->thread_timer)); |
| 568 | } |
| 569 | } |
| 570 | } |
| 571 |
no test coverage detected