This is an automated email from the git hooks/post-receive script.
git pushed a commit to branch feat/e-wl-proxy-planb
in repository enlightenment.
View the commit online.
commit 555cf899dd3bdc2c11438b7c86623953a7929e49
Author: [email protected] <[email protected]>
AuthorDate: Mon Jun 8 10:44:33 2026 -0600
fix(e_wl_proxy): throttle accept on EMFILE, check MSG_CTRUNC, harden teardown
---
src/bin/e_wl_proxy/e_wl_proxy_conn.c | 4 ++--
src/bin/e_wl_proxy/e_wl_proxy_main.c | 40 ++++++++++++++++++++++++++++--------
src/bin/e_wl_proxy/e_wl_proxy_pipe.c | 10 +++++++++
3 files changed, 44 insertions(+), 10 deletions(-)
diff --git a/src/bin/e_wl_proxy/e_wl_proxy_conn.c b/src/bin/e_wl_proxy/e_wl_proxy_conn.c
index caa9df614..f2eb5e236 100644
--- a/src/bin/e_wl_proxy/e_wl_proxy_conn.c
+++ b/src/bin/e_wl_proxy/e_wl_proxy_conn.c
@@ -114,7 +114,7 @@ e_wl_proxy_conn_del(E_Wl_Proxy_Conn *conn)
if (!conn) return;
if (conn->client_h) ecore_main_fd_handler_del(conn->client_h);
if (conn->backend_h) ecore_main_fd_handler_del(conn->backend_h);
- if (conn->client_fd >= 0) close(conn->client_fd);
- if (conn->backend_fd >= 0) close(conn->backend_fd);
+ if (conn->client_fd >= 0) { close(conn->client_fd); conn->client_fd = -1; }
+ if (conn->backend_fd >= 0) { close(conn->backend_fd); conn->backend_fd = -1; }
free(conn);
}
diff --git a/src/bin/e_wl_proxy/e_wl_proxy_main.c b/src/bin/e_wl_proxy/e_wl_proxy_main.c
index 9cfd23590..328a85944 100644
--- a/src/bin/e_wl_proxy/e_wl_proxy_main.c
+++ b/src/bin/e_wl_proxy/e_wl_proxy_main.c
@@ -1,27 +1,51 @@
-#define _GNU_SOURCE
-#include "config.h"
+#include "config.h" /* defines _GNU_SOURCE (needed for accept4) before any system header */
#include "e_wl_proxy.h"
#include <Ecore.h>
#include <Eina.h>
#include <stdlib.h>
#include <stdio.h>
+#include <string.h>
#include <unistd.h>
+#include <errno.h>
#include <sys/socket.h>
static const char *_backend_name = NULL;
+static Ecore_Fd_Handler *_listen_h = NULL;
static Eina_Bool
-_accept_cb(void *data, Ecore_Fd_Handler *fdh)
+_accept_reenable(void *data EINA_UNUSED)
{
- int lfd = (int)(intptr_t)data;
+ /* fds may have freed up: resume accepting */
+ if (_listen_h)
+ ecore_main_fd_handler_active_set(_listen_h, ECORE_FD_READ | ECORE_FD_ERROR);
+ return ECORE_CALLBACK_CANCEL; /* one-shot */
+}
+
+static Eina_Bool
+_accept_cb(void *data EINA_UNUSED, Ecore_Fd_Handler *fdh)
+{
+ int lfd = ecore_main_fd_handler_fd_get(fdh);
int cfd;
- (void)fdh;
while ((cfd = accept4(lfd, NULL, NULL, SOCK_CLOEXEC | SOCK_NONBLOCK)) >= 0)
{
/* conn takes ownership of cfd (closes it on failure) */
- e_wl_proxy_conn_add(cfd, _backend_name);
+ if (!e_wl_proxy_conn_add(cfd, _backend_name))
+ fprintf(stderr, "e_wl_proxy: failed to set up connection (fd %d)\n", cfd);
}
+
+ if ((errno == EMFILE) || (errno == ENFILE))
+ {
+ /* Out of file descriptors. With level-triggered polling the listen
+ * socket would re-fire immediately and spin at 100%% CPU, so stop
+ * accepting and retry shortly once fds have (hopefully) freed up. */
+ fprintf(stderr, "e_wl_proxy: out of file descriptors, pausing accept\n");
+ ecore_main_fd_handler_active_set(fdh, ECORE_FD_ERROR);
+ ecore_timer_add(1.0, _accept_reenable, NULL);
+ }
+ else if ((errno != EAGAIN) && (errno != EWOULDBLOCK))
+ fprintf(stderr, "e_wl_proxy: accept error: %s\n", strerror(errno));
+
return ECORE_CALLBACK_RENEW;
}
@@ -49,8 +73,8 @@ main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
return 1;
}
- ecore_main_fd_handler_add(lfd, ECORE_FD_READ | ECORE_FD_ERROR,
- _accept_cb, (void *)(intptr_t)lfd, NULL, NULL);
+ _listen_h = ecore_main_fd_handler_add(lfd, ECORE_FD_READ | ECORE_FD_ERROR,
+ _accept_cb, NULL, NULL, NULL);
ecore_main_loop_begin();
diff --git a/src/bin/e_wl_proxy/e_wl_proxy_pipe.c b/src/bin/e_wl_proxy/e_wl_proxy_pipe.c
index e7435c04b..5f608494d 100644
--- a/src/bin/e_wl_proxy/e_wl_proxy_pipe.c
+++ b/src/bin/e_wl_proxy/e_wl_proxy_pipe.c
@@ -111,6 +111,16 @@ e_wl_proxy_forward(int from, int to, E_Wl_Proxy_Pipe *pipe)
}
}
+ /* If ancillary fds did not fit they were dropped by the kernel; forwarding
+ * the bytes without them would corrupt the protocol stream, so tear down. */
+ if (msg.msg_flags & MSG_CTRUNC)
+ {
+ int i;
+ for (i = 0; i < pipe->nfds; i++) close(pipe->fds[i]);
+ pipe->nfds = 0;
+ return -1;
+ }
+
pipe->len = (int)n;
pipe->off = 0;
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.