Skip to content

Commit

Permalink
Remove the wait for the ibus daemon to start
Browse files Browse the repository at this point in the history
The initial implementation of Uinicode input via IBus used a startup delay
of 3 seconds to wait for the daemon to be ready before connecting to it.

This commit introduces a poll-wait loop which can remove the delay
entirely if the daemon is up when chansrv starts the interface.
  • Loading branch information
matt335672 committed May 23, 2024
1 parent de57116 commit f006945
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions sesman/chansrv/input_ibus.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit f006945

Please sign in to comment.