MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / channel_fops_close

Function channel_fops_close

components/lwp/lwp_ipc.c:1036–1073  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1034}
1035
1036static int channel_fops_close(struct dfs_file *file)
1037{
1038 rt_channel_t ch;
1039 rt_base_t level;
1040 RT_DEBUG_NOT_IN_INTERRUPT;
1041
1042 ch = (rt_channel_t)file->vnode->data;
1043
1044 level = rt_spin_lock_irqsave(&ch->slock);
1045
1046 if (file->vnode->ref_count == 1)
1047 {
1048 ch->ref--;
1049 if (ch->ref == 0)
1050 {
1051 /* wakeup all the suspended receivers and senders */
1052 _channel_list_resume_all_locked(&ch->parent.suspend_thread);
1053 _channel_list_resume_all_locked(&ch->wait_thread);
1054
1055 /* all ipc msg will lost */
1056 rt_list_init(&ch->wait_msg);
1057
1058 rt_spin_unlock_irqrestore(&ch->slock, level);
1059
1060 rt_object_delete(&ch->parent.parent); /* release the IPC channel structure */
1061 }
1062 else
1063 {
1064 rt_spin_unlock_irqrestore(&ch->slock, level);
1065 }
1066 }
1067 else
1068 {
1069 rt_spin_unlock_irqrestore(&ch->slock, level);
1070 }
1071
1072 return 0;
1073}
1074
1075static const struct dfs_file_ops channel_fops =
1076{

Callers

nothing calls this directly

Calls 5

rt_list_initFunction · 0.85
rt_object_deleteFunction · 0.85
rt_spin_lock_irqsaveFunction · 0.50

Tested by

no test coverage detected