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/afc.c | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) (limited to 'src/afc.c') 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; } -- cgit v1.1-32-gdbae