From 323145617ead81c34e516b1b866e8fc7f20abce1 Mon Sep 17 00:00:00 2001 From: seflerZ Date: Thu, 23 May 2024 22:33:00 +0800 Subject: [PATCH] apply ibus patach for disable busy waiting --- sesman/chansrv/input_ibus.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/sesman/chansrv/input_ibus.c b/sesman/chansrv/input_ibus.c index c247efed51..7b803e3a55 100644 --- a/sesman/chansrv/input_ibus.c +++ b/sesman/chansrv/input_ibus.c @@ -220,8 +220,21 @@ xrdp_input_unicode_init(void) return 0; } - /* Wait becasue ibus daemon may not be ready in first login. Do we have a flag to avoid busy waiting? */ - sleep(3); + /* Wait because the ibus daemon may not be ready on first login */ + const char *addr = ibus_get_address(); + unsigned int cnt = 0; + while (!addr && cnt < 10) + { + usleep(500 * 1000); // half a second + addr = ibus_get_address(); + ++cnt; + } + if (!addr) + { + LOG(LOG_LEVEL_ERROR, + "xrdp_ibus_init: Timed out waiting for iBus daemon"); + return 1; + } LOG(LOG_LEVEL_INFO, "xrdp_ibus_init: Initializing the iBus engine"); ibus_init();