summaryrefslogtreecommitdiffstats
path: root/src/afc.c
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2013-03-20 05:38:06 +0100
committerGravatar Nikias Bassen2013-03-20 05:38:06 +0100
commitb2924a1549d874fb86deaad5fd2438e567c65bf4 (patch)
treeead89f885a0492cdfc228a1c25326912e7d9b973 /src/afc.c
parentefca491e4c19868a68a099638552f9ba431dca4b (diff)
downloadlibimobiledevice-b2924a1549d874fb86deaad5fd2438e567c65bf4.tar.gz
libimobiledevice-b2924a1549d874fb86deaad5fd2438e567c65bf4.tar.bz2
use new internal common code for thread, mutex, and socket operations
Diffstat (limited to 'src/afc.c')
-rw-r--r--src/afc.c24
1 files changed, 4 insertions, 20 deletions
diff --git a/src/afc.c b/src/afc.c
index c281e2c..f39562d 100644
--- a/src/afc.c
+++ b/src/afc.c
@@ -43,11 +43,7 @@ static const int MAXIMUM_PACKET_SIZE = (2 << 15);
static void afc_lock(afc_client_t client)
{
debug_info("Locked");
-#ifdef WIN32
- EnterCriticalSection(&client->mutex);
-#else
- pthread_mutex_lock(&client->mutex);
-#endif
+ mutex_lock(&client->mutex);
}
/**
@@ -58,11 +54,7 @@ static void afc_lock(afc_client_t client)
static void afc_unlock(afc_client_t client)
{
debug_info("Unlocked");
-#ifdef WIN32
- LeaveCriticalSection(&client->mutex);
-#else
- pthread_mutex_unlock(&client->mutex);
-#endif
+ mutex_unlock(&client->mutex);
}
/**
@@ -99,11 +91,7 @@ afc_error_t afc_client_new_with_service_client(service_client_t service_client,
memcpy(client_loc->afc_packet->magic, AFC_MAGIC, AFC_MAGIC_LEN);
client_loc->file_handle = 0;
client_loc->lock = 0;
-#ifdef WIN32
- InitializeCriticalSection(&client_loc->mutex);
-#else
- pthread_mutex_init(&client_loc->mutex, NULL);
-#endif
+ mutex_init(&client_loc->mutex);
*client = client_loc;
return AFC_E_SUCCESS;
@@ -156,11 +144,7 @@ afc_error_t afc_client_free(afc_client_t client)
client->parent = NULL;
}
free(client->afc_packet);
-#ifdef WIN32
- DeleteCriticalSection(&client->mutex);
-#else
- pthread_mutex_destroy(&client->mutex);
-#endif
+ mutex_destroy(&client->mutex);
free(client);
return AFC_E_SUCCESS;
}