kopia lustrzana https://github.com/espressif/esp-idf
VFS: `select` function's timeout is now POSIX compliant
`select` function will now round up the timeout passed as a parameter (if any). It makes it POSIX compliant. * Closes https://github.com/espressif/esp-idf/issues/7514pull/7830/head
rodzic
34234792c4
commit
73303e5de0
|
@ -1,16 +1,8 @@
|
||||||
// Copyright 2015-2020 Espressif Systems (Shanghai) PTE LTD
|
/*
|
||||||
//
|
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
*
|
||||||
// you may not use this file except in compliance with the License.
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
// You may obtain a copy of the License at
|
*/
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
#ifndef __ESP_VFS_H__
|
#ifndef __ESP_VFS_H__
|
||||||
#define __ESP_VFS_H__
|
#define __ESP_VFS_H__
|
||||||
|
@ -411,7 +403,8 @@ int esp_vfs_utime(const char *path, const struct utimbuf *times);
|
||||||
* @param timeout If not NULL, then points to timeval structure which
|
* @param timeout If not NULL, then points to timeval structure which
|
||||||
* specifies the time period after which the functions should
|
* specifies the time period after which the functions should
|
||||||
* time-out and return. If it is NULL, then the function will
|
* time-out and return. If it is NULL, then the function will
|
||||||
* not time-out.
|
* not time-out. Note that the timeout period is rounded up to
|
||||||
|
* the system tick and incremented by one.
|
||||||
*
|
*
|
||||||
* @return The number of descriptors set in the descriptor sets, or -1
|
* @return The number of descriptors set in the descriptor sets, or -1
|
||||||
* when an error (specified by errno) have occurred.
|
* when an error (specified by errno) have occurred.
|
||||||
|
|
|
@ -1,16 +1,8 @@
|
||||||
// Copyright 2015-2019 Espressif Systems (Shanghai) PTE LTD
|
/*
|
||||||
//
|
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
*
|
||||||
// you may not use this file except in compliance with the License.
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
// You may obtain a copy of the License at
|
*/
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -1035,8 +1027,14 @@ int esp_vfs_select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *errorfds
|
||||||
|
|
||||||
TickType_t ticks_to_wait = portMAX_DELAY;
|
TickType_t ticks_to_wait = portMAX_DELAY;
|
||||||
if (timeout) {
|
if (timeout) {
|
||||||
uint32_t timeout_ms = timeout->tv_sec * 1000 + timeout->tv_usec / 1000;
|
uint32_t timeout_ms = (timeout->tv_sec * 1000) + (timeout->tv_usec / 1000);
|
||||||
ticks_to_wait = timeout_ms / portTICK_PERIOD_MS;
|
/* Round up the number of ticks.
|
||||||
|
* Not only we need to round up the number of ticks, but we also need to add 1.
|
||||||
|
* Indeed, `select` function shall wait for AT LEAST timeout, but on FreeRTOS,
|
||||||
|
* if we specify a timeout of 1 tick to `xSemaphoreTake`, it will take AT MOST
|
||||||
|
* 1 tick before triggering a timeout. Thus, we need to pass 2 ticks as a timeout
|
||||||
|
* to `xSemaphoreTake`. */
|
||||||
|
ticks_to_wait = ((timeout_ms + portTICK_PERIOD_MS - 1) / portTICK_PERIOD_MS) + 1;
|
||||||
ESP_LOGD(TAG, "timeout is %dms", timeout_ms);
|
ESP_LOGD(TAG, "timeout is %dms", timeout_ms);
|
||||||
}
|
}
|
||||||
ESP_LOGD(TAG, "waiting without calling socket_select");
|
ESP_LOGD(TAG, "waiting without calling socket_select");
|
||||||
|
|
|
@ -2716,7 +2716,6 @@ components/unity/unity_runner.c
|
||||||
components/usb/test/common/test_usb_mock_classes.c
|
components/usb/test/common/test_usb_mock_classes.c
|
||||||
components/usb/test/common/test_usb_mock_classes.h
|
components/usb/test/common/test_usb_mock_classes.h
|
||||||
components/usb/test/hcd/test_hcd_ctrl.c
|
components/usb/test/hcd/test_hcd_ctrl.c
|
||||||
components/vfs/include/esp_vfs.h
|
|
||||||
components/vfs/include/esp_vfs_cdcacm.h
|
components/vfs/include/esp_vfs_cdcacm.h
|
||||||
components/vfs/include/esp_vfs_common.h
|
components/vfs/include/esp_vfs_common.h
|
||||||
components/vfs/include/esp_vfs_dev.h
|
components/vfs/include/esp_vfs_dev.h
|
||||||
|
@ -2731,7 +2730,6 @@ components/vfs/test/test_vfs_lwip.c
|
||||||
components/vfs/test/test_vfs_paths.c
|
components/vfs/test/test_vfs_paths.c
|
||||||
components/vfs/test/test_vfs_select.c
|
components/vfs/test/test_vfs_select.c
|
||||||
components/vfs/test/test_vfs_uart.c
|
components/vfs/test/test_vfs_uart.c
|
||||||
components/vfs/vfs.c
|
|
||||||
components/vfs/vfs_cdcacm.c
|
components/vfs/vfs_cdcacm.c
|
||||||
components/vfs/vfs_eventfd.c
|
components/vfs/vfs_eventfd.c
|
||||||
components/vfs/vfs_semihost.c
|
components/vfs/vfs_semihost.c
|
||||||
|
|
Ładowanie…
Reference in New Issue