summaryrefslogtreecommitdiffstats
path: root/src/sbservices.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/sbservices.c')
-rw-r--r--src/sbservices.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/sbservices.c b/src/sbservices.c
index dd5f571..7f050bf 100644
--- a/src/sbservices.c
+++ b/src/sbservices.c
@@ -36,7 +36,11 @@
static void sbs_lock(sbservices_client_t client)
{
debug_info("SBServices: Locked");
+#ifdef WIN32
+ EnterCriticalSection(&client->mutex);
+#else
pthread_mutex_lock(&client->mutex);
+#endif
}
/**
@@ -47,7 +51,11 @@ 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
}
/**
@@ -100,7 +108,11 @@ sbservices_error_t sbservices_client_new(idevice_t device, uint16_t port, sbserv
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
*client = client_loc;
return SBSERVICES_E_SUCCESS;
@@ -122,7 +134,11 @@ 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
free(client);
return err;