-
Notifications
You must be signed in to change notification settings - Fork 7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The select function times out too early (IDFGH-5807) #7514
Comments
Hello @Emill , |
Hello @Emill , |
Thanks for fixing this! But as mentioned in the topic description, there is a similar place here: https://github.com/espressif/esp-idf/blob/master/components/lwip/port/esp32/freertos/sys_arch.c#L187. This function is called by lwip_select here: https://github.com/espressif/esp-lwip/blob/2c9c531f0a7e0ee536db9de4f9dc54e453712087/src/api/sockets.c#L2153, which is in turned called from esp_vfs_select here: Line 1005 in 7bd93e3
Could that result in the same issue as well? |
@Emill Indeed, thanks for pointing this out. It is a different (sub)project, so it will be part of another commit. |
@o-marshmallow |
`select` function will now round up the timeout passed as a parameter (if any). It makes it POSIX compliant. * Closes #7514
`select` function will now round up the timeout passed as a parameter (if any). It makes it POSIX compliant. * Closes #7514
`select` function will now round up the timeout passed as a parameter (if any). It makes it POSIX compliant. * Closes #7514
`select` function will now round up the timeout passed as a parameter (if any). It makes it POSIX compliant. * Closes #7514
@o-marshmallow |
`lwip_select` uses `sys_arch_sem_wait` function making the assumption that it is POSIX compliant. This commit makes that function wait for at least timeout (milliseconds), as required by POSIX specification. * Relates to #7514
The
select
function seems to round down the supplied timeout value to the granularity supported by the system. The POSIX standard says that the value should be rounded up instead. This makes timeouts time out too early with esp-idf. For example if you want to do something every 9 ms and the system's tick rate is set to 10 ms, then your loop will become a busyloop since 9 is rounded down to 0, makingselect
return immediately.Similar issue for
pthread_cond_timedwait
: #6901.In components/vfs/vfs.c we see this:
Similar code can be found in components/lwip/port/esp32/freertos/sys_arch.c.
The code above clearly rounds down, while it should round up.
Sample code:
Output:
To be POSIX compliant,
diff
should have been at least 9999000 ns.The text was updated successfully, but these errors were encountered: