MCPcopy Create free account
hub / github.com/apache/nuttx / task_uninit_stream

Function task_uninit_stream

sched/tls/task_uninitinfo.c:50–102  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

48
49#ifdef CONFIG_FILE_STREAM
50static void task_uninit_stream(FAR struct task_group_s *group)
51{
52 FAR struct streamlist *list;
53 FAR struct file_struct *stream;
54 FAR sq_entry_t *curr;
55 FAR sq_entry_t *next;
56
57 DEBUGASSERT(group && group->tg_info);
58 list = &group->tg_info->ta_streamlist;
59 stream = list->sl_std;
60
61 /* Destroy the mutex and release the filelist */
62
63 nxmutex_destroy(&list->sl_lock);
64
65 /* Destroy stdin, stdout and stderr stream */
66
67#ifndef CONFIG_STDIO_DISABLE_BUFFERING
68 nxrmutex_destroy(&stream[0].fs_lock);
69 nxrmutex_destroy(&stream[1].fs_lock);
70 nxrmutex_destroy(&stream[2].fs_lock);
71#endif
72
73 /* Release each stream in the list */
74
75 sq_for_every_safe(&list->sl_queue, curr, next)
76 {
77 stream = container_of(curr, struct file_struct, fs_entry);
78
79#ifndef CONFIG_STDIO_DISABLE_BUFFERING
80 /* Destroy the mutex that protects the IO buffer */
81
82 nxrmutex_destroy(&stream->fs_lock);
83#endif
84
85 /* Release the stream */
86
87#ifdef CONFIG_BUILD_KERNEL
88 /* If the exiting group is unprivileged, then it has an address
89 * environment. Don't bother to release the memory in this case...
90 * There is no point since the memory lies in the user heap which
91 * will be destroyed anyway. But if this is a privileged group,
92 * when we still have to release the memory using the kernel
93 * allocator.
94 */
95
96 if ((group->tg_flags & GROUP_FLAG_PRIVILEGED) != 0)
97#endif
98 {
99 group_free(group, stream);
100 }
101 }
102}
103#endif
104
105/****************************************************************************

Callers 1

task_uninit_infoFunction · 0.85

Calls 4

nxmutex_destroyFunction · 0.85
nxrmutex_destroyFunction · 0.85
container_ofFunction · 0.85
group_freeFunction · 0.85

Tested by

no test coverage detected