Branch: refs/heads/master Author: Colomban Wendling ban@herbesfolles.org Committer: Colomban Wendling ban@herbesfolles.org Date: Sun, 12 Oct 2014 12:59:21 UTC Commit: 21f9e79acf37d05e068e155f4f977d04628204de https://github.com/geany/geany-plugins/commit/21f9e79acf37d05e068e155f4f977d...
Log Message: ----------- debugger: Fix GCond usage
g_cond_wait() and the likes unlock the passed in mutex during the wait and re-lock it before returning. However, the code here used to pass in an unlocked mutex.
This used to work because GLib threading implementation was tolerant and allowed unlocking an unlocked mutex, but GLib 2.42 has a new and less tolerant implementation that would abort in such situation.
Fix this by properly locking the passed in mutex.
The implementation here also removes the second mutex only used for the condition as the one used to protect the loop body can very well be used and actually makes sense as they protect the same thing.
Doing so requires to properly wait for the thread to quit before destroying the mutex, but this probably should be done anyways to avoid forcefully killing the thread when the application quits.
Modified Paths: -------------- debugger/src/dconfig.c
Modified: debugger/src/dconfig.c 12 lines changed, 4 insertions(+), 8 deletions(-) =================================================================== @@ -270,11 +270,9 @@ static void save_to_keyfile(GKeyFile *keyfile) static gpointer saving_thread_func(gpointer data) { GTimeVal interval; - GMutex *m = g_mutex_new(); + g_mutex_lock(change_config_mutex); do { - g_mutex_lock(change_config_mutex); - if ( panel_config_changed || (debug_config_changed && DEBUG_STORE_PLUGIN == dstore) @@ -309,14 +307,12 @@ static gpointer saving_thread_func(gpointer data) debug_config_changed = FALSE; } - - g_mutex_unlock(change_config_mutex);
g_get_current_time(&interval); g_time_val_add(&interval, SAVING_INTERVAL); } - while (!g_cond_timed_wait(cond, m, &interval)); - g_mutex_free(m); + while (!g_cond_timed_wait(cond, change_config_mutex, &interval)); + g_mutex_unlock(change_config_mutex); return NULL; } @@ -471,7 +467,7 @@ void config_init(void) void config_destroy(void) { g_cond_signal(cond); - /* ??? g_thread_join(saving_thread); */ + g_thread_join(saving_thread); g_mutex_free(change_config_mutex); g_cond_free(cond);
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).
plugins-commits@lists.geany.org