aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog8
-rw-r--r--libsylph/imap.c6
-rw-r--r--libsylph/socket.c4
-rw-r--r--libsylph/utils.c4
-rw-r--r--src/query_search.c4
5 files changed, 17 insertions, 9 deletions
diff --git a/ChangeLog b/ChangeLog
index 180bf5df..e2f0f09f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2009-10-13
+
+ * libsylph/utils.c
+ libsylph/imap.c
+ libsylph/socket.c
+ src/query_search.c: use g_atomic_int_{get,set} for thread
+ terminate flags.
+
2009-10-09
* src/send_message.c: made send dialog non-modal.
diff --git a/libsylph/imap.c b/libsylph/imap.c
index 198bbc72..129c0485 100644
--- a/libsylph/imap.c
+++ b/libsylph/imap.c
@@ -4775,7 +4775,7 @@ static void imap_thread_run_proxy(gpointer push_data, gpointer data)
g_print("imap_thread_run_proxy (%p): calling thread_func\n", g_thread_self());
real->retval = real->thread_func(IMAP_SESSION(real), real->thread_data);
- real->flag = 1;
+ g_atomic_int_set(&real->flag, 1);
g_print("imap_thread_run_proxy (%p): thread_func done\n", g_thread_self());
g_main_context_wakeup(NULL);
}
@@ -4806,7 +4806,7 @@ static gint imap_thread_run(IMAPSession *session, IMAPThreadFunc func,
g_thread_pool_push(real->pool, real, NULL);
- while (real->flag == 0)
+ while (g_atomic_int_get(&real->flag) == 0)
event_loop_iterate();
real->is_running = FALSE;
@@ -4850,7 +4850,7 @@ static gint imap_thread_run_progress(IMAPSession *session, IMAPThreadFunc func,
g_thread_pool_push(real->pool, real, NULL);
- while (real->flag == 0) {
+ while (g_atomic_int_get(&real->flag) == 0) {
event_loop_iterate();
if (prev_count != real->prog_count && real->prog_total > 0) {
progress_func(session, real->prog_count,
diff --git a/libsylph/socket.c b/libsylph/socket.c
index 47aa7ec1..566d940b 100644
--- a/libsylph/socket.c
+++ b/libsylph/socket.c
@@ -1332,7 +1332,7 @@ static gpointer sock_connect_async_func(gpointer data)
SockConnectData *conn_data = (SockConnectData *)data;
conn_data->sock = sock_connect(conn_data->hostname, conn_data->port);
- conn_data->flag = 1;
+ g_atomic_int_set(&conn_data->flag, 1);
debug_print("sock_connect_async_func: connected\n");
g_main_context_wakeup(NULL);
@@ -1382,7 +1382,7 @@ gint sock_connect_async_thread_wait(gint id, SockInfo **sock)
}
debug_print("sock_connect_async_thread_wait: waiting thread\n");
- while (conn_data->flag == 0)
+ while (g_atomic_int_get(&conn_data->flag) == 0)
event_loop_iterate();
g_thread_join(conn_data->thread);
diff --git a/libsylph/utils.c b/libsylph/utils.c
index ace360a7..b675c4fe 100644
--- a/libsylph/utils.c
+++ b/libsylph/utils.c
@@ -3881,7 +3881,7 @@ static gpointer execute_command_line_async_func(gpointer data)
debug_print("execute_command_line_async_func: exec done: %s\n",
cmd_data->cmdline);
- cmd_data->flag = 1;
+ g_atomic_int_set(&cmd_data->flag, 1);
g_main_context_wakeup(NULL);
return GINT_TO_POINTER(0);
@@ -3909,7 +3909,7 @@ gint execute_command_line_async_wait(const gchar *cmdline)
return -1;
debug_print("execute_command_line_async_wait: waiting thread\n");
- while (data.flag == 0)
+ while (g_atomic_int_get(&data.flag) == 0)
event_loop_iterate();
g_thread_join(thread);
diff --git a/src/query_search.c b/src/query_search.c
index 30e7ff51..0e74a808 100644
--- a/src/query_search.c
+++ b/src/query_search.c
@@ -665,7 +665,7 @@ static gpointer query_search_folder_func(gpointer data)
g_async_queue_unref(qdata->queue);
#endif
- qdata->flag = 1;
+ g_atomic_int_set(&qdata->flag, 1);
g_main_context_wakeup(NULL);
debug_print("query_search_folder_func end\n");
@@ -710,7 +710,7 @@ static void query_search_folder(FolderItem *item)
thread = g_thread_create(query_search_folder_func, &data, TRUE, NULL);
debug_print("query_search_folder: thread started\n");
- while (data.flag == 0) {
+ while (g_atomic_int_get(&data.flag) == 0) {
gtk_main_iteration();
if (prev_count != data.count) {
prev_count = data.count;