Skip to content

Commit b4e59ba

Browse files
authored
dfs v2 修改 fd_new 的 startfd 起始值为 0 ;修复 futex_wait 超时时间换算异常; (#7705)
Signed-off-by: yangfasheng <[email protected]>
1 parent 3e4797c commit b4e59ba

File tree

3 files changed

+32
-8
lines changed

3 files changed

+32
-8
lines changed

components/dfs/dfs_v2/src/dfs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ int fdt_fd_new(struct dfs_fdtable *fdt)
197197
dfs_file_lock();
198198

199199
/* find an empty fd entry */
200-
idx = fd_alloc(fdt, DFS_STDIO_OFFSET);
200+
idx = fd_alloc(fdt, 0);
201201
/* can't find an empty fd entry */
202202
if (idx < 0)
203203
{

components/libc/posix/io/stdio/libc.c

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,34 @@ int libc_system_init(void)
3030
dev_console = rt_console_get_device();
3131
if (dev_console)
3232
{
33-
int fd = libc_stdio_set_console(dev_console->parent.name, O_RDWR);
34-
if (fd < 0)
33+
int fd, ret;
34+
char name[STDIO_DEVICE_NAME_MAX];
35+
36+
rt_snprintf(name, sizeof(name) - 1, "/dev/%s", dev_console->parent.name);
37+
name[STDIO_DEVICE_NAME_MAX - 1] = '\0';
38+
39+
fd = open(name, O_RDWR);
40+
if (fd >= 0)
41+
{
42+
/* set fd (0, 1, 2) */
43+
ret = sys_dup2(fd, 0);
44+
if (ret != fd)
45+
{
46+
close(fd);
47+
}
48+
sys_dup2(ret, 1);
49+
sys_dup2(ret, 2);
50+
51+
ret = libc_stdio_set_console(dev_console->parent.name, O_RDWR);
52+
if (ret < 0)
53+
{
54+
return -1;
55+
}
56+
}
57+
else
3558
{
3659
return -1;
3760
}
38-
/* set fd (0, 1, 2) */
39-
sys_dup2(fd, 0);
40-
sys_dup2(fd, 1);
41-
sys_dup2(fd, 2);
4261
}
4362
#endif /* RT_USING_POSIX_STDIO */
4463
return 0;

components/lwp/lwp_futex.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,12 @@ int futex_wait(struct rt_futex *futex, int value, const struct timespec *timeout
124124
/* with timeout */
125125
if (timeout)
126126
{
127-
rt_int32_t time = rt_timespec_to_tick(timeout);
127+
rt_int32_t time = timeout->tv_sec * RT_TICK_PER_SECOND + timeout->tv_nsec * RT_TICK_PER_SECOND / NANOSECOND_PER_SECOND;
128+
129+
if (time < 0)
130+
{
131+
time = 0;
132+
}
128133

129134
/* start the timer of thread */
130135
rt_timer_control(&(thread->thread_timer),

0 commit comments

Comments
 (0)