obmc-console: fix socket-handler unexpected behavior
socket handler timeout error path unregister the poller within poller
callback function which will cause unexpected behavior. Fix by skip
poller unregister within poller timeout callback function, the
unregister will happen as callback return POLLER_REMOVE.
Tested:
refer to patch commit msg
http://fusion2/c5d26975-751d-3e19-b26c-bce9d856cf9b
Google-Bug-Id: 364358832
Change-Id: I994e344472874daebf815c3853ece5f278b67e78
Signed-off-by: Dan Zhang <zhdaniel@google.com>
diff --git a/recipes-phosphor/console/obmc-console/0004-Fix-unexpected-behavior-in-client-timeout-callback.patch b/recipes-phosphor/console/obmc-console/0004-Fix-unexpected-behavior-in-client-timeout-callback.patch
new file mode 100644
index 0000000..9e5f6a1
--- /dev/null
+++ b/recipes-phosphor/console/obmc-console/0004-Fix-unexpected-behavior-in-client-timeout-callback.patch
@@ -0,0 +1,31 @@
+From a3ca446f78f728a1ead81cb622e709d16da3ed36 Mon Sep 17 00:00:00 2001
+From: Dan Zhang <zhdaniel@google.com>
+Date: Sun, 9 Feb 2025 16:58:26 +0000
+Subject: [PATCH 4/5] Fix unexpected behavior in client timeout callback
+
+Avoid calling console_poller_unregister within the poller timeout
+callback to prevent reallocation of the poller array during iteration,
+which causes unexpected behavior. This ensures client_close does not
+unregister pollers in the callback context.
+
+Change-Id: If723a476d4142a42aa62e97ed0d2e2abca5e00c6
+Signed-off-by: Dan Zhang <zhdaniel@google.com>
+---
+ socket-handler.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/socket-handler.c b/socket-handler.c
+index 5f9d383..4906569 100644
+--- a/socket-handler.c
++++ b/socket-handler.c
+@@ -253,6 +253,7 @@ client_timeout(struct handler *handler __attribute__((unused)), void *data)
+
+ rc = client_drain_queue(client, 0);
+ if (rc) {
++ client->poller = NULL;
+ client_close(client);
+ return POLLER_REMOVE;
+ }
+--
+2.48.1.502.g6dc24dfdaf-goog
+
diff --git a/recipes-phosphor/console/obmc-console_%.bbappend b/recipes-phosphor/console/obmc-console_%.bbappend
index f23d531..3a80f2b 100644
--- a/recipes-phosphor/console/obmc-console_%.bbappend
+++ b/recipes-phosphor/console/obmc-console_%.bbappend
@@ -4,7 +4,8 @@
file://readonly-obmc-console-client \
file://40-console-client-override.conf \
file://ttf-console.sh \
- file://0001-Add-syslog-handler.patch \
+ file://0001-Add-syslog-handler.patch \
+ file://0004-Fix-unexpected-behavior-in-client-timeout-callback.patch \
"
do_install:append:gbmc() {
install -d -m0644 ${D}${sysconfdir}/systemd/system/serial-to-host@.service.d/