diff options
| author | 2011-09-03 02:07:09 +0200 | |
|---|---|---|
| committer | 2012-03-18 20:40:54 +0100 | |
| commit | 6a83ef58a1032e3b336587e2f3a19659ae325c25 (patch) | |
| tree | 27e12297bc66bd22a0cfc86459413a49a0d998f2 /src/afc.c | |
| parent | b586203dbef26f9e94325b57867478eda504e5a1 (diff) | |
| download | libimobiledevice-6a83ef58a1032e3b336587e2f3a19659ae325c25.tar.gz libimobiledevice-6a83ef58a1032e3b336587e2f3a19659ae325c25.tar.bz2 | |
Remove gthread dependency and use pthreads instead
Diffstat (limited to 'src/afc.c')
| -rw-r--r-- | src/afc.c | 18 |
1 files changed, 4 insertions, 14 deletions
| @@ -39,7 +39,7 @@ static const int MAXIMUM_PACKET_SIZE = (2 << 15); | |||
| 39 | static void afc_lock(afc_client_t client) | 39 | static void afc_lock(afc_client_t client) |
| 40 | { | 40 | { |
| 41 | debug_info("Locked"); | 41 | debug_info("Locked"); |
| 42 | g_mutex_lock(client->mutex); | 42 | pthread_mutex_lock(&client->mutex); |
| 43 | } | 43 | } |
| 44 | 44 | ||
| 45 | /** | 45 | /** |
| @@ -50,7 +50,7 @@ static void afc_lock(afc_client_t client) | |||
| 50 | static void afc_unlock(afc_client_t client) | 50 | static void afc_unlock(afc_client_t client) |
| 51 | { | 51 | { |
| 52 | debug_info("Unlocked"); | 52 | debug_info("Unlocked"); |
| 53 | g_mutex_unlock(client->mutex); | 53 | pthread_mutex_unlock(&client->mutex); |
| 54 | } | 54 | } |
| 55 | 55 | ||
| 56 | /** | 56 | /** |
| @@ -69,10 +69,6 @@ static void afc_unlock(afc_client_t client) | |||
| 69 | 69 | ||
| 70 | afc_error_t afc_client_new_from_connection(idevice_connection_t connection, afc_client_t *client) | 70 | afc_error_t afc_client_new_from_connection(idevice_connection_t connection, afc_client_t *client) |
| 71 | { | 71 | { |
| 72 | /* makes sure thread environment is available */ | ||
| 73 | if (!g_thread_supported()) | ||
| 74 | g_thread_init(NULL); | ||
| 75 | |||
| 76 | if (!connection) | 72 | if (!connection) |
| 77 | return AFC_E_INVALID_ARG; | 73 | return AFC_E_INVALID_ARG; |
| 78 | 74 | ||
| @@ -93,7 +89,7 @@ afc_error_t afc_client_new_from_connection(idevice_connection_t connection, afc_ | |||
| 93 | memcpy(client_loc->afc_packet->magic, AFC_MAGIC, AFC_MAGIC_LEN); | 89 | memcpy(client_loc->afc_packet->magic, AFC_MAGIC, AFC_MAGIC_LEN); |
| 94 | client_loc->file_handle = 0; | 90 | client_loc->file_handle = 0; |
| 95 | client_loc->lock = 0; | 91 | client_loc->lock = 0; |
| 96 | client_loc->mutex = g_mutex_new(); | 92 | pthread_mutex_init(&client_loc->mutex, NULL); |
| 97 | 93 | ||
| 98 | *client = client_loc; | 94 | *client = client_loc; |
| 99 | return AFC_E_SUCCESS; | 95 | return AFC_E_SUCCESS; |
| @@ -117,10 +113,6 @@ afc_error_t afc_client_new_from_connection(idevice_connection_t connection, afc_ | |||
| 117 | */ | 113 | */ |
| 118 | afc_error_t afc_client_new(idevice_t device, uint16_t port, afc_client_t * client) | 114 | afc_error_t afc_client_new(idevice_t device, uint16_t port, afc_client_t * client) |
| 119 | { | 115 | { |
| 120 | /* makes sure thread environment is available */ | ||
| 121 | if (!g_thread_supported()) | ||
| 122 | g_thread_init(NULL); | ||
| 123 | |||
| 124 | if (!device || port==0) | 116 | if (!device || port==0) |
| 125 | return AFC_E_INVALID_ARG; | 117 | return AFC_E_INVALID_ARG; |
| 126 | 118 | ||
| @@ -155,9 +147,7 @@ afc_error_t afc_client_free(afc_client_t client) | |||
| 155 | client->connection = NULL; | 147 | client->connection = NULL; |
| 156 | } | 148 | } |
| 157 | free(client->afc_packet); | 149 | free(client->afc_packet); |
| 158 | if (client->mutex) { | 150 | pthread_mutex_destroy(&client->mutex); |
| 159 | g_mutex_free(client->mutex); | ||
| 160 | } | ||
| 161 | free(client); | 151 | free(client); |
| 162 | return AFC_E_SUCCESS; | 152 | return AFC_E_SUCCESS; |
| 163 | } | 153 | } |
