]> granicus.if.org Git - esp-idf/commitdiff
VFS: Optionally disable the VFS implementation of select()
authorRoland Dobai <dobai.roland@gmail.com>
Wed, 23 May 2018 06:25:46 +0000 (08:25 +0200)
committerRoland Dobai <dobai.roland@gmail.com>
Wed, 23 May 2018 08:14:16 +0000 (10:14 +0200)
This allows to temporarily resolve issues like
https://github.com/espressif/esp-idf/issues/1987
while bugs are fixed in the VFS implementation of select().

components/lwip/Kconfig
components/newlib/select.c
components/vfs/README.rst

index c24910e368fc271689ddcebaa5062a8ee989196c..efd053b5f209b6ad344e597a4ae3250b97d680c2 100755 (executable)
@@ -37,6 +37,16 @@ config LWIP_MAX_SOCKETS
         the maximum amount of sockets here. The valid value is from 1
         to 16.
 
+config USE_ONLY_LWIP_SELECT
+    bool "Support LWIP socket select() only"
+    default n
+    help
+        The virtual filesystem layer of select() redirects sockets to
+        lwip_select() and non-socket file descriptors to their respective driver
+        implementations. If this option is enabled then all calls of select()
+        will be redirected to lwip_select(), therefore, select can be used
+        for sockets only.
+
 config LWIP_SO_REUSE
     bool "Enable SO_REUSEADDR option"
     default y
index dc945eafb44e52f2c49ab0ac80289f751a46b070..e802a4d329204b4356de118f45eacdeb2feafe7e 100644 (file)
 
 #include <sys/select.h>
 #include "esp_vfs.h"
+#include "sdkconfig.h"
+
+#ifdef CONFIG_USE_ONLY_LWIP_SELECT
+#include "lwip/sockets.h"
+#endif
 
 int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *errorfds, struct timeval *timeout)
 {
+#ifdef CONFIG_USE_ONLY_LWIP_SELECT
+    return lwip_select(nfds, readfds, writefds, errorfds, timeout);
+#else
     return esp_vfs_select(nfds, readfds, writefds, errorfds, timeout);
+#endif
 }
index 4644689a9388b9983c4b672a529c06cacb96bcc4..36af5c388c1cb171521db0716c09d088a6d03bfd 100644 (file)
@@ -93,6 +93,10 @@ Examples demonstrating the use of :cpp:func:`select` with VFS file descriptors
 are the :example:`peripherals/uart_select` and the :example:`system/select`
 examples.
 
+If :cpp:func:`select` is used for socket file descriptors only then one can
+enable the :ref:`CONFIG_USE_ONLY_LWIP_SELECT` option which can reduce the code
+size and improve performance.
+
 Paths
 -----