diff options
author | Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im> | 2013-04-18 01:50:30 +0200 |
---|---|---|
committer | Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im> | 2013-04-18 01:50:30 +0200 |
commit | 13b2b2885d7cd121ee56cd2e7cb0b38372ca0189 (patch) | |
tree | b85605a513bc38a3e8eccc2aab7e10c7309e681c /libpurple/network.c | |
parent | edfec77caa0457a2f5da9c0d4111e29b9779bfce (diff) | |
download | pidgin-13b2b2885d7cd121ee56cd2e7cb0b38372ca0189.tar.gz |
Don't use deprecated threads API for recent GLib versions
Diffstat (limited to 'libpurple/network.c')
-rw-r--r-- | libpurple/network.c | 51 |
1 files changed, 50 insertions, 1 deletions
diff --git a/libpurple/network.c b/libpurple/network.c index a79a852c7f..4ed7711977 100644 --- a/libpurple/network.c +++ b/libpurple/network.c @@ -85,7 +85,12 @@ static gboolean have_nm_state = FALSE; static int current_network_count; /* Mutex for the other global vars */ +#if GLIB_CHECK_VERSION(2, 32, 0) +static GMutex mutex; +#else static GStaticMutex mutex = G_STATIC_MUTEX_INIT; +#endif + static gboolean network_initialized = FALSE; static HANDLE network_change_handle = NULL; static int (WSAAPI *MyWSANSPIoctl) ( @@ -700,11 +705,19 @@ static gpointer wpurple_network_change_thread(gpointer data) WSACOMPLETION completion; WSAOVERLAPPED overlapped; +#if GLIB_CHECK_VERSION(2, 32, 0) + g_mutex_lock(&mutex); +#else g_static_mutex_lock(&mutex); +#endif if (network_initialized == FALSE) { /* purple_network_uninit has been called */ WSACloseEvent(nla_event); +#if GLIB_CHECK_VERSION(2, 32, 0) + g_mutex_unlock(&mutex); +#else g_static_mutex_unlock(&mutex); +#endif g_thread_exit(NULL); return NULL; } @@ -722,13 +735,21 @@ static gpointer wpurple_network_change_thread(gpointer data) msg, errorid)); g_free(msg); WSACloseEvent(nla_event); +#if GLIB_CHECK_VERSION(2, 32, 0) + g_mutex_unlock(&mutex); +#else g_static_mutex_unlock(&mutex); +#endif g_thread_exit(NULL); return NULL; } } +#if GLIB_CHECK_VERSION(2, 32, 0) + g_mutex_unlock(&mutex); +#else g_static_mutex_unlock(&mutex); - +#endif + memset(&completion, 0, sizeof(WSACOMPLETION)); completion.Type = NSP_NOTIFY_EVENT; overlapped.hEvent = nla_event; @@ -739,10 +760,18 @@ static gpointer wpurple_network_change_thread(gpointer data) if (errorid == WSA_INVALID_HANDLE) { purple_timeout_add(0, _print_debug_msg, g_strdup("Invalid NLA handle; resetting.\n")); +#if GLIB_CHECK_VERSION(2, 32, 0) + g_mutex_lock(&mutex); +#else g_static_mutex_lock(&mutex); +#endif retval = WSALookupServiceEnd(network_change_handle); network_change_handle = NULL; +#if GLIB_CHECK_VERSION(2, 32, 0) + g_mutex_unlock(&mutex); +#else g_static_mutex_unlock(&mutex); +#endif continue; /* WSA_IO_PENDING indicates successful async notification will happen */ } else if (errorid != WSA_IO_PENDING) { @@ -764,11 +793,19 @@ static gpointer wpurple_network_change_thread(gpointer data) last_trigger = time(NULL); +#if GLIB_CHECK_VERSION(2, 32, 0) + g_mutex_lock(&mutex); +#else g_static_mutex_lock(&mutex); +#endif if (network_initialized == FALSE) { /* Time to die */ WSACloseEvent(nla_event); +#if GLIB_CHECK_VERSION(2, 32, 0) + g_mutex_unlock(&mutex); +#else g_static_mutex_unlock(&mutex); +#endif g_thread_exit(NULL); return NULL; } @@ -782,7 +819,11 @@ static gpointer wpurple_network_change_thread(gpointer data) } WSAResetEvent(nla_event); +#if GLIB_CHECK_VERSION(2, 32, 0) + g_mutex_unlock(&mutex); +#else g_static_mutex_unlock(&mutex); +#endif purple_timeout_add(0, wpurple_network_change_thread_cb, NULL); } @@ -1214,7 +1255,11 @@ purple_network_uninit(void) #endif #ifdef _WIN32 +#if GLIB_CHECK_VERSION(2, 32, 0) + g_mutex_lock(&mutex); +#else g_static_mutex_lock(&mutex); +#endif network_initialized = FALSE; if (network_change_handle != NULL) { int retval; @@ -1231,7 +1276,11 @@ purple_network_uninit(void) network_change_handle = NULL; } +#if GLIB_CHECK_VERSION(2, 32, 0) + g_mutex_unlock(&mutex); +#else g_static_mutex_unlock(&mutex); +#endif #endif purple_signal_unregister(purple_network_get_handle(), |