From b2924a1549d874fb86deaad5fd2438e567c65bf4 Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Wed, 20 Mar 2013 05:38:06 +0100 Subject: use new internal common code for thread, mutex, and socket operations --- src/sbservices.c | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) (limited to 'src/sbservices.c') diff --git a/src/sbservices.c b/src/sbservices.c index 00f2862..1cd17db 100644 --- a/src/sbservices.c +++ b/src/sbservices.c @@ -36,11 +36,7 @@ static void sbs_lock(sbservices_client_t client) { debug_info("SBServices: Locked"); -#ifdef WIN32 - EnterCriticalSection(&client->mutex); -#else - pthread_mutex_lock(&client->mutex); -#endif + mutex_lock(&client->mutex); } /** @@ -51,11 +47,7 @@ static void sbs_lock(sbservices_client_t client) static void sbs_unlock(sbservices_client_t client) { debug_info("SBServices: Unlocked"); -#ifdef WIN32 - LeaveCriticalSection(&client->mutex); -#else - pthread_mutex_unlock(&client->mutex); -#endif + mutex_unlock(&client->mutex); } /** @@ -105,11 +97,7 @@ sbservices_error_t sbservices_client_new(idevice_t device, lockdownd_service_des sbservices_client_t client_loc = (sbservices_client_t) malloc(sizeof(struct sbservices_client_private)); client_loc->parent = plistclient; -#ifdef WIN32 - InitializeCriticalSection(&client_loc->mutex); -#else - pthread_mutex_init(&client_loc->mutex, NULL); -#endif + mutex_init(&client_loc->mutex); *client = client_loc; return SBSERVICES_E_SUCCESS; @@ -131,11 +119,7 @@ sbservices_error_t sbservices_client_free(sbservices_client_t client) sbservices_error_t err = sbservices_error(property_list_service_client_free(client->parent)); client->parent = NULL; -#ifdef WIN32 - DeleteCriticalSection(&client->mutex); -#else - pthread_mutex_destroy(&client->mutex); -#endif + mutex_destroy(&client->mutex); free(client); return err; -- cgit v1.1-32-gdbae