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 8e119ffe97a6e2133653fa8b66389bb0d98ff0f0
Author: [email protected] <[email protected]>
AuthorDate: Mon Jun 8 11:40:00 2026 -0600

    feat(e_wl_proxy): readiness pipe handshake instead of usleep
    
    enlightenment_start passes a pipe write-end via E_WL_PROXY_READY_FD; the proxy
    writes one byte once its public socket is listening, then closes it. The parent
    blocks reading that byte, so E starts only once clients can connect, and a EOF
    (proxy died before signalling) is detected deterministically. Replaces the
    200ms usleep race and the WNOHANG poll.
---
 src/bin/e_start_main.c               | 28 +++++++++++++++++++---------
 src/bin/e_wl_proxy/e_wl_proxy_main.c | 23 +++++++++++++++++++++++
 2 files changed, 42 insertions(+), 9 deletions(-)

diff --git a/src/bin/e_start_main.c b/src/bin/e_start_main.c
index 9eebff41e..87265d194 100644
--- a/src/bin/e_start_main.c
+++ b/src/bin/e_start_main.c
@@ -526,7 +526,11 @@ _e_wl_proxy_start(void)
 {
    const char *enable = getenv("E_WL_PROXY");
    char *proxy_bin = NULL;
+   char fdbuf[16];
+   int rdy[2];
    pid_t pid;
+   char c;
+   ssize_t n;
 
    if (!enable || strcmp(enable, "1") != 0) return -1;
 
@@ -537,8 +541,12 @@ _e_wl_proxy_start(void)
 
    myasprintf(&proxy_bin, "%s/e_wl_proxy", eina_prefix_bin_get(pfx));
 
+   /* readiness pipe: the proxy writes a byte once its public socket is up, so
+    * we start E only after clients can actually connect (no startup race). */
+   if (pipe(rdy) != 0) return -1;
+
    pid = fork();
-   if (pid < 0) return -1;
+   if (pid < 0) { close(rdy[0]); close(rdy[1]); return -1; }
    if (pid == 0)
      {
         /* die with enlightenment_start so the proxy never outlives the session */
@@ -548,19 +556,21 @@ _e_wl_proxy_start(void)
         int sig = SIGTERM;
         procctl(P_PID, 0, PROC_PDEATHSIG_CTL, &sig);
 #endif
+        close(rdy[0]);   /* child only writes */
+        snprintf(fdbuf, sizeof(fdbuf), "%d", rdy[1]);
+        env_set("E_WL_PROXY_READY_FD", fdbuf);
         execl(proxy_bin, proxy_bin, (char *)NULL);
         _exit(127);
      }
 
-   /* give the proxy a moment to create the public socket before E or clients
-    * race for it; the proxy connects to the backend lazily on first client. */
-   usleep(200000);
-
-   /* if the proxy died immediately (e.g. could not create its socket), don't
-    * pretend it is running — the caller continues without it. */
-   if (waitpid(pid, NULL, WNOHANG) == pid)
+   /* parent: block until the proxy signals readiness (1 byte) or dies (EOF). */
+   close(rdy[1]);   /* parent only reads */
+   n = read(rdy[0], &c, 1);
+   close(rdy[0]);
+   if (n != 1)
      {
-        fprintf(stderr, "e_wl_proxy exited immediately; continuing without it\n");
+        fprintf(stderr, "e_wl_proxy did not come up; continuing without it\n");
+        waitpid(pid, NULL, WNOHANG);   /* reap if it already exited */
         return -1;
      }
 
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 2436692f0..84eba9a50 100644
--- a/src/bin/e_wl_proxy/e_wl_proxy_main.c
+++ b/src/bin/e_wl_proxy/e_wl_proxy_main.c
@@ -49,6 +49,26 @@ _accept_cb(void *data EINA_UNUSED, Ecore_Fd_Handler *fdh)
    return ECORE_CALLBACK_RENEW;
 }
 
+/* If enlightenment_start passed a readiness pipe fd in E_WL_PROXY_READY_FD,
+ * write one byte so the parent unblocks knowing the public socket is up, then
+ * close it. The parent sees EOF instead if we die before reaching this point. */
+static void
+_signal_ready(void)
+{
+   const char *rfd = getenv("E_WL_PROXY_READY_FD");
+   int fd;
+
+   if (!rfd || !rfd[0]) return;
+   fd = atoi(rfd);
+   if (fd > 0)
+     {
+        ssize_t r = write(fd, "1", 1);
+        (void)r;
+        close(fd);
+     }
+   unsetenv("E_WL_PROXY_READY_FD");
+}
+
 int
 main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
 {
@@ -76,6 +96,9 @@ main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
    _listen_h = ecore_main_fd_handler_add(lfd, ECORE_FD_READ | ECORE_FD_ERROR,
                                          _accept_cb, NULL, NULL, NULL);
 
+   /* if launched with a readiness pipe, tell the parent the socket is up */
+   _signal_ready();
+
    ecore_main_loop_begin();
 
    ecore_shutdown();

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

Reply via email to