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

Function sys_channel_send_recv_timeout

components/lwp/lwp_syscall.c:4198–4230  ·  view source on GitHub ↗

* @brief Sends a message through a communication channel and waits for a response with a timeout. * * This system call sends a message (`data`) through a specified communication channel identified by the file descriptor `fd`. * It then waits for a response (`data_ret`) within the specified timeout period. This is a synchronous operation * commonly used in request-response communication pattern

Source from the content-addressed store, hash-verified

4196 * enough to store the expected response to avoid memory issues or data corruption.
4197 */
4198sysret_t sys_channel_send_recv_timeout(int fd, rt_channel_msg_t data, rt_channel_msg_t data_ret, rt_int32_t time)
4199{
4200 rt_size_t ret = 0;
4201 rt_channel_msg_t kdata = RT_NULL;
4202 rt_channel_msg_t kdata_ret = RT_NULL;
4203
4204 if (!lwp_user_accessable((void *)data, sizeof(*data)))
4205 {
4206 return -EFAULT;
4207 }
4208
4209 kdata = kmem_get(sizeof(*data));
4210 if (kdata == RT_NULL)
4211 return -ENOMEM;
4212
4213 if (lwp_get_from_user(kdata, data, sizeof(*kdata)) != sizeof(*kdata))
4214 {
4215 kmem_put(kdata);
4216 return -EFAULT;
4217 }
4218
4219 kdata_ret = kmem_get(sizeof(*data_ret));
4220 if (kdata_ret == RT_NULL)
4221 return -ENOMEM;
4222
4223 ret = lwp_channel_send_recv_timeout(FDT_TYPE_LWP, fd, kdata, kdata_ret, time);
4224
4225 lwp_put_to_user(data_ret, kdata_ret, sizeof(*kdata_ret));
4226 kmem_put(kdata);
4227 kmem_put(kdata_ret);
4228
4229 return ret;
4230}
4231
4232/**
4233 * @brief Sends a reply message through a communication channel.

Callers

nothing calls this directly

Calls 6

lwp_user_accessableFunction · 0.85
kmem_getFunction · 0.85
lwp_get_from_userFunction · 0.85
kmem_putFunction · 0.85
lwp_put_to_userFunction · 0.85

Tested by

no test coverage detected