Replacing evil looping code
hadess at hadess.net
Mon Nov 6 05:20:33 PST 2006
Right now, we have some evil code in Totem's browser plugin, and I'd
like to see whether it would be possible to replace it using something a
bit more stable.
Here's the code:
//Launch our binary with some special args
if (g_spawn_async_with_pipes (NULL, argv, NULL,
GSpawnFlags(0), NULL, NULL, &mPlayerPID,
use_fd ? &mSendFD : NULL, NULL, NULL, &err) == FALSE)
//Set up a signal to know when the service name has started
mWaitForSvc = g_strdup_printf
D("waiting for signal %s", mWaitForSvc);
dbus_g_proxy_add_signal (mProxy, "NameOwnerChanged",
dbus_g_proxy_connect_signal (mProxy, "NameOwnerChanged",
//Evil crappy loop to wait for the service
g_time_val_add (&then, G_USEC_PER_SEC * 5);
/* FIXME FIXME! this loop is evil! */
g_main_context_iteration (NULL, TRUE);
} while (scriptable->IsValid () &&
(now.tv_sec <= then.tv_sec));
Is it possible to replace all that crap with decent D-Bus code?
I don't think we can use a service, as we're depending on some
command-line arguments (should we pass those to the service in some
other way instead?).
Any other ideas?
Bastien Nocera <hadess at hadess.net>
More information about the dbus