g_cond_wait_until: returning FALSE immediately on mips24
- GLib 2.70.4
- OpenWRT 22.03
- Compile my example code and run on the specified platform (I personally use 8devices Rambutan).
- g_cond_wait_until should return FALSE only when specified time has passed
- When called, the function does not wait for the specified interval, instead it just returns FALSE. Such behavior breaks GLib-dependent apps like GStreamer.
-
#include <gio/gio.h>
#include <stdlib.h>
#include <string.h>
gpointer
pop_data_timed (void)
{
g_print ("start timer: %lld\n", g_get_monotonic_time ());
gboolean current_data = false;
gint64 end_time;
gpointer data;
GCond data_cond;
GMutex data_mutex;
g_cond_init(&data_cond);
g_mutex_init(&data_mutex);
g_mutex_lock (&data_mutex);
end_time = g_get_monotonic_time () + 5 * G_TIME_SPAN_SECOND;
g_print ("wait until: %lld\n", end_time);
while (!current_data) {
g_print ("while\n");
if (!g_cond_wait_until (&data_cond, &data_mutex, end_time)) {
g_print ("timeout: %lld\n", g_get_monotonic_time ());
g_mutex_unlock (&data_mutex);
return NULL;
}
}
g_mutex_unlock (&data_mutex);
return data;
}
int
main (int argc, char **argv)
{
GApplication *app;
int status;
app = g_application_new ("org.gtk.TestApplication", G_APPLICATION_HANDLES_COMMAND_LINE);
g_signal_connect (app, "command-line", G_CALLBACK (pop_data_timed), NULL);
g_application_set_inactivity_timeout (app, 10000);
status = g_application_run (app, argc, argv);
g_object_unref (app);
return status;
}