g_print ("thread: wait ACK\n");
g_cond_wait (info->cond, info->mutex);
info->var = 1;
- g_print ("thread: signal\n");
+ g_print ("thread: signal var change\n");
g_cond_signal (info->cond);
g_print ("thread: unlock\n");
g_mutex_unlock (info->mutex);
ThreadInfo *info;
GThread *thread;
GError *error = NULL;
+ gint res = 0;
if (!g_thread_supported ())
g_thread_init (NULL);
if (error != NULL) {
g_print ("Unable to start thread: %s\n", error->message);
g_error_free (error);
- g_free (info);
- return -1;
+ res = -1;
+ goto done;
}
g_print ("main: wait spinup\n");
g_print ("main: signal ACK\n");
g_cond_signal (info->cond);
- g_print ("main: wait\n");
+
+ g_print ("main: waiting for thread to change var\n");
g_cond_wait (info->cond, info->mutex);
+
g_print ("main: var == %d\n", info->var);
if (info->var != 1)
g_print ("main: !!error!! expected var == 1, got %d\n", info->var);
g_print ("main: join\n");
g_thread_join (thread);
+done:
g_mutex_free (info->mutex);
g_cond_free (info->cond);
g_free (info);
- return 0;
+ return res;
}
ThreadInfo *info;
GThread *thread;
GError *error = NULL;
+ gint res = 0;
if (!g_thread_supported ())
g_thread_init (NULL);
if (error != NULL) {
g_print ("Unable to start thread: %s\n", error->message);
g_error_free (error);
- g_free (info);
- return -1;
+ res = -1;
+ goto done;
}
g_print ("main: wait spinup\n");
g_cond_wait (info->cond_t, info->mutex);
g_print ("main: var == %d\n", info->var);
- if (info->var != 1)
+ if (info->var != 1) {
g_print ("main: !!error!! expected var == 1, got %d\n", info->var);
+ }
g_mutex_unlock (info->mutex);
g_print ("main: join\n");
g_thread_join (thread);
+done:
g_mutex_free (info->mutex);
g_cond_free (info->cond_t);
g_cond_free (info->cond_p);
g_free (info);
- return 0;
+ return res;
}