/pidgin/main: 8a0d96bd9cf4: Replace deprecated g_thread_create w...
Tomasz Wasilczyk
tomkiewicz at cpw.pidgin.im
Sun Apr 14 09:23:16 EDT 2013
Changeset: 8a0d96bd9cf4ee8d3dc000c025258d6a9f8fb7bd
Author: Tomasz Wasilczyk <tomkiewicz at cpw.pidgin.im>
Date: 2013-04-14 15:23 +0200
Branch: default
URL: https://hg.pidgin.im/pidgin/main/rev/8a0d96bd9cf4
Description:
Replace deprecated g_thread_create with g_thread_try_new
diffstat:
libpurple/dnsquery.c | 6 ++++--
libpurple/dnssrv.c | 8 ++++++--
libpurple/glibcompat.h | 6 ++++++
libpurple/network.c | 5 ++++-
libpurple/protocols/bonjour/bonjour.c | 8 +++++++-
5 files changed, 27 insertions(+), 6 deletions(-)
diffs (112 lines):
diff --git a/libpurple/dnsquery.c b/libpurple/dnsquery.c
--- a/libpurple/dnsquery.c
+++ b/libpurple/dnsquery.c
@@ -818,8 +818,8 @@ resolve_host(PurpleDnsQueryData *query_d
* Spin off a separate thread to perform the DNS lookup so
* that we don't block the UI.
*/
- query_data->resolver = g_thread_create(dns_thread,
- query_data, FALSE, &err);
+ query_data->resolver = g_thread_try_new("dnsquery resolver", dns_thread,
+ query_data, &err);
if (query_data->resolver == NULL)
{
char message[1024];
@@ -828,6 +828,8 @@ resolve_host(PurpleDnsQueryData *query_d
g_error_free(err);
purple_dnsquery_failed(query_data, message);
}
+ else
+ g_thread_unref(query_data->resolver);
}
#else /* not PURPLE_DNSQUERY_USE_FORK or _WIN32 */
diff --git a/libpurple/dnssrv.c b/libpurple/dnssrv.c
--- a/libpurple/dnssrv.c
+++ b/libpurple/dnssrv.c
@@ -826,11 +826,13 @@ purple_srv_resolve(PurpleAccount *accoun
return query_data;
#else
- query_data->resolver = g_thread_create(res_thread, query_data, FALSE, &err);
+ query_data->resolver = g_thread_try_new("dnssrv srv resolver", res_thread, query_data, &err);
if (query_data->resolver == NULL) {
query_data->error_message = g_strdup_printf("SRV thread create failure: %s\n", (err && err->message) ? err->message : "");
g_error_free(err);
}
+ else
+ g_thread_unref(query_data->resolver);
/* The query isn't going to happen, so finish the SRV lookup now.
* Asynchronously call the callback since stuff may not expect
@@ -945,11 +947,13 @@ PurpleSrvTxtQueryData *purple_txt_resolv
return query_data;
#else
- query_data->resolver = g_thread_create(res_thread, query_data, FALSE, &err);
+ query_data->resolver = g_thread_try_new("dnssrv srv resolver", res_thread, query_data, &err);
if (query_data->resolver == NULL) {
query_data->error_message = g_strdup_printf("TXT thread create failure: %s\n", (err && err->message) ? err->message : "");
g_error_free(err);
}
+ else
+ g_thread_unref(query_data->resolver);
/* The query isn't going to happen, so finish the TXT lookup now.
* Asynchronously call the callback since stuff may not expect
diff --git a/libpurple/glibcompat.h b/libpurple/glibcompat.h
--- a/libpurple/glibcompat.h
+++ b/libpurple/glibcompat.h
@@ -37,6 +37,12 @@
#define G_GNUC_BEGIN_IGNORE_DEPRECATIONS
#define G_GNUC_END_IGNORE_DEPRECATIONS
+static inline GThread * g_thread_try_new(const gchar *name, GThreadFunc func,
+ gpointer data, GError **error)
+{
+ return g_thread_create(func, data, TRUE, error);
+}
+
#if !GLIB_CHECK_VERSION(2, 28, 0)
static inline gint64 g_get_monotonic_time(void)
diff --git a/libpurple/network.c b/libpurple/network.c
--- a/libpurple/network.c
+++ b/libpurple/network.c
@@ -1129,7 +1129,10 @@ purple_network_init(void)
else {
current_network_count = cnt;
if ((MyWSANSPIoctl = (void*) wpurple_find_and_loadproc("ws2_32.dll", "WSANSPIoctl"))) {
- if (!g_thread_create(wpurple_network_change_thread, NULL, FALSE, &err))
+ GThread *thread = g_thread_try_new("Network Monitor thread", wpurple_network_change_thread, NULL, &err);
+ if (thread)
+ g_thread_unref(thread);
+ else
purple_debug_error("network", "Couldn't create Network Monitor thread: %s\n", err ? err->message : "");
}
}
diff --git a/libpurple/protocols/bonjour/bonjour.c b/libpurple/protocols/bonjour/bonjour.c
--- a/libpurple/protocols/bonjour/bonjour.c
+++ b/libpurple/protocols/bonjour/bonjour.c
@@ -690,6 +690,8 @@ initialize_default_account_values(void)
{
#ifndef _WIN32
struct passwd *info;
+#else
+ GThread *lookup_thread;
#endif
const char *fullname = NULL, *splitpoint, *tmp;
gchar *conv = NULL;
@@ -705,7 +707,11 @@ initialize_default_account_values(void)
fullname = NULL;
#else
/* The Win32 username lookup functions are synchronous so we do it in a thread */
- g_thread_create(_win32_name_lookup_thread, NULL, FALSE, NULL);
+ lookup_thread = g_thread_try_new("bonjour dns thread", _win32_name_lookup_thread, NULL, NULL);
+ if (lookup_thread)
+ g_thread_unref(lookup_thread);
+ else
+ purple_debug_fatal("bonjour", "failed to create lookup thread\n");
#endif
/* Make sure fullname is valid UTF-8. If not, try to convert it. */
More information about the Commits
mailing list