raster pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=4f5b1b2fad59fef17b8f69d3a5a03e68418084d4

commit 4f5b1b2fad59fef17b8f69d3a5a03e68418084d4
Author: Carsten Haitzler (Rasterman) <ras...@rasterman.com>
Date:   Fri Jun 4 12:12:12 2021 +0100

    ecore - mainloop - select - increase max set size and check fd if over
    
    if fd's exceed max set size then things will ... god bad. how - ...
    depends on the OS but at least report that there is an issue.
---
 meson.build                |  2 ++
 meson_options.txt          |  6 ++++++
 src/lib/ecore/ecore_main.c | 34 ++++++++++++++++++++++++++++++++++
 3 files changed, 42 insertions(+)

diff --git a/meson.build b/meson.build
index 25677fcc3f..396c1dc514 100644
--- a/meson.build
+++ b/meson.build
@@ -637,6 +637,8 @@ efl_config_h.set('EFL_BUILD_ID', get_option('build-id'))
 # FIXME placeholder
 efl_config_h.set('EFL_API_LEGACY_DEF', '#define EFL_API_LEGACY_DEF "FIXME NOT 
IMPLEMENTED"')
 
+config_h.set('EFL_MAX_FD_SIZE', get_option('max-fd-size'))
+
 configure_file(
   output: 'config.h',
   configuration: config_h
diff --git a/meson_options.txt b/meson_options.txt
index 8c21e69436..992a7af975 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -376,3 +376,9 @@ option('efl-one',
   value : false,
   description : 'Build special set of .so´s as a single .so'
 )
+
+option('max-fd-size',
+  type : 'string',
+  value : '8192',
+  description : 'This is the maximim set of fds and thus maximum fd value 
allowed +1 in the ecore main loop handler'
+)
diff --git a/src/lib/ecore/ecore_main.c b/src/lib/ecore/ecore_main.c
index a037916e3a..a2ca2251b9 100644
--- a/src/lib/ecore/ecore_main.c
+++ b/src/lib/ecore/ecore_main.c
@@ -4,6 +4,19 @@
 
 #define EINA_SLSTR_INTERNAL
 
+// as per:
+//
+// 
https://forums.freebsd.org/threads/solved-enlightenment-application-menu-icons-missing-due-to-efreetd-crashing.80743/
+//
+// from ethorns - can't find more user info...
+//
+// normal fd set size (maximum fd num allowed) is limited to 1024. raise this
+// to something more useful than the default 1024 ... this doesn't affect
+// linux as it will use epoll. beware that this also will be a performance
+// hit - the higher this number the more it costs to zero and re-fill the fd
+// set every time we go into select.
+#define FD_SETSIZE EFL_MAX_FD_SIZE
+
 #ifdef _WIN32
 # ifndef USER_TIMER_MINIMUM
 #  define USER_TIMER_MINIMUM 0x0a
@@ -1768,6 +1781,25 @@ _ecore_main_prepare_handlers(Eo *obj EINA_UNUSED, 
Efl_Loop_Data *pd)
      }
 }
 
+static void
+_ecore_main_select_fd_too_big_check(int fd)
+{
+   if (fd < FD_SETSIZE) return;
+   int newsize = fd + 1 - 1;
+   newsize |= newsize >> 1;
+   newsize |= newsize >> 2;
+   newsize |= newsize >> 4;
+   newsize |= newsize >> 8;
+   newsize |= newsize >> 16;
+   newsize++;
+   fprintf(stderr,
+           "ERROR: ecore main loop, fd %i >= max possible fd %i.   "
+           "If this continues to be an issue with lots of high value fds "
+           "being needed, perhaps consider recompiling EFL with the option:   "
+           "-Dmax-fd-size=%i\n"
+           , fd, FD_SETSIZE, newsize);
+}
+
 #if !defined(USE_G_MAIN_LOOP)
 static int
 _ecore_main_select(Eo *obj, Efl_Loop_Data *pd, double timeout)
@@ -1820,6 +1852,7 @@ _ecore_main_select(Eo *obj, Efl_Loop_Data *pd, double 
timeout)
           {
              if (!fdh->delete_me)
                {
+                  _ecore_main_select_fd_too_big_check(fdh->fd);
                   if ((fdh->flags & ECORE_FD_READ) || (fdh->flags & 
ECORE_FD_ALWAYS))
                     {
                        FD_SET(fdh->fd, &rfds);
@@ -1851,6 +1884,7 @@ _ecore_main_select(Eo *obj, Efl_Loop_Data *pd, double 
timeout)
      {
         if (!fdh->delete_me)
           {
+             _ecore_main_select_fd_too_big_check(fdh->fd);
              if ((fdh->flags & ECORE_FD_READ) || (fdh->flags & 
ECORE_FD_ALWAYS))
                {
                   FD_SET(fdh->fd, &rfds);

-- 


Reply via email to