diff options
Diffstat (limited to 'src/afc.c')
| -rw-r--r-- | src/afc.c | 24 |
1 files changed, 4 insertions, 20 deletions
| @@ -43,11 +43,7 @@ static const int MAXIMUM_PACKET_SIZE = (2 << 15); | |||
| 43 | static void afc_lock(afc_client_t client) | 43 | static void afc_lock(afc_client_t client) |
| 44 | { | 44 | { |
| 45 | debug_info("Locked"); | 45 | debug_info("Locked"); |
| 46 | #ifdef WIN32 | 46 | mutex_lock(&client->mutex); |
| 47 | EnterCriticalSection(&client->mutex); | ||
| 48 | #else | ||
| 49 | pthread_mutex_lock(&client->mutex); | ||
| 50 | #endif | ||
| 51 | } | 47 | } |
| 52 | 48 | ||
| 53 | /** | 49 | /** |
| @@ -58,11 +54,7 @@ static void afc_lock(afc_client_t client) | |||
| 58 | static void afc_unlock(afc_client_t client) | 54 | static void afc_unlock(afc_client_t client) |
| 59 | { | 55 | { |
| 60 | debug_info("Unlocked"); | 56 | debug_info("Unlocked"); |
| 61 | #ifdef WIN32 | 57 | mutex_unlock(&client->mutex); |
| 62 | LeaveCriticalSection(&client->mutex); | ||
| 63 | #else | ||
| 64 | pthread_mutex_unlock(&client->mutex); | ||
| 65 | #endif | ||
| 66 | } | 58 | } |
| 67 | 59 | ||
| 68 | /** | 60 | /** |
| @@ -99,11 +91,7 @@ afc_error_t afc_client_new_with_service_client(service_client_t service_client, | |||
| 99 | memcpy(client_loc->afc_packet->magic, AFC_MAGIC, AFC_MAGIC_LEN); | 91 | memcpy(client_loc->afc_packet->magic, AFC_MAGIC, AFC_MAGIC_LEN); |
| 100 | client_loc->file_handle = 0; | 92 | client_loc->file_handle = 0; |
| 101 | client_loc->lock = 0; | 93 | client_loc->lock = 0; |
| 102 | #ifdef WIN32 | 94 | mutex_init(&client_loc->mutex); |
| 103 | InitializeCriticalSection(&client_loc->mutex); | ||
| 104 | #else | ||
| 105 | pthread_mutex_init(&client_loc->mutex, NULL); | ||
| 106 | #endif | ||
| 107 | 95 | ||
| 108 | *client = client_loc; | 96 | *client = client_loc; |
| 109 | return AFC_E_SUCCESS; | 97 | return AFC_E_SUCCESS; |
| @@ -156,11 +144,7 @@ afc_error_t afc_client_free(afc_client_t client) | |||
| 156 | client->parent = NULL; | 144 | client->parent = NULL; |
| 157 | } | 145 | } |
| 158 | free(client->afc_packet); | 146 | free(client->afc_packet); |
| 159 | #ifdef WIN32 | 147 | mutex_destroy(&client->mutex); |
| 160 | DeleteCriticalSection(&client->mutex); | ||
| 161 | #else | ||
| 162 | pthread_mutex_destroy(&client->mutex); | ||
| 163 | #endif | ||
| 164 | free(client); | 148 | free(client); |
| 165 | return AFC_E_SUCCESS; | 149 | return AFC_E_SUCCESS; |
| 166 | } | 150 | } |
