summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--configure.ac1
-rw-r--r--dev/afccheck.c17
-rw-r--r--src/afc.c18
-rw-r--r--src/afc.h4
-rw-r--r--src/installation_proxy.c25
-rw-r--r--src/installation_proxy.h6
-rw-r--r--src/mobile_image_mounter.c14
-rw-r--r--src/mobile_image_mounter.h4
-rw-r--r--src/notification_proxy.c27
-rw-r--r--src/notification_proxy.h8
-rw-r--r--src/sbservices.c14
-rw-r--r--src/sbservices.h4
12 files changed, 50 insertions, 92 deletions
diff --git a/configure.ac b/configure.ac
index cdfaa36..5078afd 100644
--- a/configure.ac
+++ b/configure.ac
@@ -28,7 +28,6 @@ AC_PROG_LIBTOOL
# Checks for libraries.
PKG_CHECK_MODULES(libusbmuxd, libusbmuxd >= 0.1.4)
PKG_CHECK_MODULES(libglib2, glib-2.0 >= 2.14.1)
-PKG_CHECK_MODULES(libgthread2, gthread-2.0 >= 2.14.1)
PKG_CHECK_MODULES(libgnutls, gnutls >= 2.2.0)
PKG_CHECK_MODULES(libtasn1, libtasn1 >= 1.1)
PKG_CHECK_MODULES(libplist, libplist >= 0.15)
diff --git a/dev/afccheck.c b/dev/afccheck.c
index b4d8910..2dab6db 100644
--- a/dev/afccheck.c
+++ b/dev/afccheck.c
@@ -22,7 +22,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
-#include <glib.h>
+#include <pthread.h>
#include <libimobiledevice/libimobiledevice.h>
#include <libimobiledevice/lockdown.h>
@@ -38,7 +38,7 @@ typedef struct {
} param;
-static void check_afc(gpointer data)
+static void* check_afc(void *data)
{
//prepare a buffer
unsigned int buffersize = BUFFER_SIZE * sizeof(unsigned int);
@@ -85,14 +85,13 @@ static void check_afc(gpointer data)
//cleanup
afc_remove_path(((param *) data)->afc, path);
- g_thread_exit(0);
+ pthread_exit(0);
}
int main(int argc, char *argv[])
{
lockdownd_client_t client = NULL;
idevice_t phone = NULL;
- GError *err;
uint16_t port = 0;
afc_client_t afc = NULL;
@@ -121,22 +120,18 @@ int main(int argc, char *argv[])
afc_client_new(phone, port, &afc);
- //makes sure thread environment is available
- if (!g_thread_supported())
- g_thread_init(NULL);
-
- GThread *threads[NB_THREADS];
+ pthread_t threads[NB_THREADS];
param data[NB_THREADS];
int i = 0;
for (i = 0; i < NB_THREADS; i++) {
data[i].afc = afc;
data[i].id = i + 1;
- threads[i] = g_thread_create((GThreadFunc) check_afc, data + i, TRUE, &err);
+ pthread_create(&threads[i], NULL, check_afc, data + i);
}
for (i = 0; i < NB_THREADS; i++) {
- g_thread_join(threads[i]);
+ pthread_join(threads[i], NULL);
}
lockdownd_client_free(client);
diff --git a/src/afc.c b/src/afc.c
index 989d0ec..fd5143a 100644
--- a/src/afc.c
+++ b/src/afc.c
@@ -39,7 +39,7 @@ static const int MAXIMUM_PACKET_SIZE = (2 << 15);
static void afc_lock(afc_client_t client)
{
debug_info("Locked");
- g_mutex_lock(client->mutex);
+ pthread_mutex_lock(&client->mutex);
}
/**
@@ -50,7 +50,7 @@ static void afc_lock(afc_client_t client)
static void afc_unlock(afc_client_t client)
{
debug_info("Unlocked");
- g_mutex_unlock(client->mutex);
+ pthread_mutex_unlock(&client->mutex);
}
/**
@@ -69,10 +69,6 @@ static void afc_unlock(afc_client_t client)
afc_error_t afc_client_new_from_connection(idevice_connection_t connection, afc_client_t *client)
{
- /* makes sure thread environment is available */
- if (!g_thread_supported())
- g_thread_init(NULL);
-
if (!connection)
return AFC_E_INVALID_ARG;
@@ -93,7 +89,7 @@ afc_error_t afc_client_new_from_connection(idevice_connection_t connection, afc_
memcpy(client_loc->afc_packet->magic, AFC_MAGIC, AFC_MAGIC_LEN);
client_loc->file_handle = 0;
client_loc->lock = 0;
- client_loc->mutex = g_mutex_new();
+ pthread_mutex_init(&client_loc->mutex, NULL);
*client = client_loc;
return AFC_E_SUCCESS;
@@ -117,10 +113,6 @@ afc_error_t afc_client_new_from_connection(idevice_connection_t connection, afc_
*/
afc_error_t afc_client_new(idevice_t device, uint16_t port, afc_client_t * client)
{
- /* makes sure thread environment is available */
- if (!g_thread_supported())
- g_thread_init(NULL);
-
if (!device || port==0)
return AFC_E_INVALID_ARG;
@@ -155,9 +147,7 @@ afc_error_t afc_client_free(afc_client_t client)
client->connection = NULL;
}
free(client->afc_packet);
- if (client->mutex) {
- g_mutex_free(client->mutex);
- }
+ pthread_mutex_destroy(&client->mutex);
free(client);
return AFC_E_SUCCESS;
}
diff --git a/src/afc.h b/src/afc.h
index 9c9f12d..79078ec 100644
--- a/src/afc.h
+++ b/src/afc.h
@@ -19,8 +19,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include <glib.h>
#include <stdint.h>
+#include <pthread.h>
#include "libimobiledevice/afc.h"
@@ -53,7 +53,7 @@ struct afc_client_private {
AFCPacket *afc_packet;
int file_handle;
int lock;
- GMutex *mutex;
+ pthread_mutex_t mutex;
int own_connection;
};
diff --git a/src/installation_proxy.c b/src/installation_proxy.c
index 4a76dd2..e26a77d 100644
--- a/src/installation_proxy.c
+++ b/src/installation_proxy.c
@@ -43,7 +43,7 @@ struct instproxy_status_data {
static void instproxy_lock(instproxy_client_t client)
{
debug_info("InstallationProxy: Locked");
- g_mutex_lock(client->mutex);
+ pthread_mutex_lock(&client->mutex);
}
/**
@@ -54,7 +54,7 @@ static void instproxy_lock(instproxy_client_t client)
static void instproxy_unlock(instproxy_client_t client)
{
debug_info("InstallationProxy: Unlocked");
- g_mutex_unlock(client->mutex);
+ pthread_mutex_unlock(&client->mutex);
}
/**
@@ -96,10 +96,6 @@ static instproxy_error_t instproxy_error(property_list_service_error_t err)
*/
instproxy_error_t instproxy_client_new(idevice_t device, uint16_t port, instproxy_client_t *client)
{
- /* makes sure thread environment is available */
- if (!g_thread_supported())
- g_thread_init(NULL);
-
if (!device)
return INSTPROXY_E_INVALID_ARG;
@@ -110,8 +106,8 @@ instproxy_error_t instproxy_client_new(idevice_t device, uint16_t port, instprox
instproxy_client_t client_loc = (instproxy_client_t) malloc(sizeof(struct instproxy_client_private));
client_loc->parent = plistclient;
- client_loc->mutex = g_mutex_new();
- client_loc->status_updater = NULL;
+ pthread_mutex_init(&client_loc->mutex, NULL);
+ client_loc->status_updater = (pthread_t)NULL;
*client = client_loc;
return INSTPROXY_E_SUCCESS;
@@ -135,11 +131,9 @@ instproxy_error_t instproxy_client_free(instproxy_client_t client)
client->parent = NULL;
if (client->status_updater) {
debug_info("joining status_updater");
- g_thread_join(client->status_updater);
- }
- if (client->mutex) {
- g_mutex_free(client->mutex);
+ pthread_join(client->status_updater, NULL);
}
+ pthread_mutex_destroy(&client->mutex);
free(client);
return INSTPROXY_E_SUCCESS;
@@ -349,7 +343,7 @@ static instproxy_error_t instproxy_perform_operation(instproxy_client_t client,
*
* @return Always NULL.
*/
-static gpointer instproxy_status_updater(gpointer arg)
+static void* instproxy_status_updater(void* arg)
{
struct instproxy_status_data *data = (struct instproxy_status_data*)arg;
@@ -362,7 +356,7 @@ static gpointer instproxy_status_updater(gpointer arg)
if (data->operation) {
free(data->operation);
}
- data->client->status_updater = NULL;
+ data->client->status_updater = (pthread_t)NULL;
instproxy_unlock(data->client);
free(data);
@@ -397,8 +391,7 @@ static instproxy_error_t instproxy_create_status_updater(instproxy_client_t clie
data->operation = strdup(operation);
data->user_data = user_data;
- client->status_updater = g_thread_create(instproxy_status_updater, data, TRUE, NULL);
- if (client->status_updater) {
+ if (pthread_create(&client->status_updater, NULL, instproxy_status_updater, data) == 0) {
res = INSTPROXY_E_SUCCESS;
}
}
diff --git a/src/installation_proxy.h b/src/installation_proxy.h
index b497d62..811ead6 100644
--- a/src/installation_proxy.h
+++ b/src/installation_proxy.h
@@ -21,15 +21,15 @@
#ifndef IINSTALLATION_PROXY_H
#define IINSTALLATION_PROXY_H
-#include <glib.h>
+#include <pthread.h>
#include "libimobiledevice/installation_proxy.h"
#include "property_list_service.h"
struct instproxy_client_private {
property_list_service_client_t parent;
- GMutex *mutex;
- GThread *status_updater;
+ pthread_mutex_t mutex;
+ pthread_t status_updater;
};
#endif
diff --git a/src/mobile_image_mounter.c b/src/mobile_image_mounter.c
index 367bee0..18caf73 100644
--- a/src/mobile_image_mounter.c
+++ b/src/mobile_image_mounter.c
@@ -35,7 +35,7 @@
*/
static void mobile_image_mounter_lock(mobile_image_mounter_client_t client)
{
- g_mutex_lock(client->mutex);
+ pthread_mutex_lock(&client->mutex);
}
/**
@@ -45,7 +45,7 @@ static void mobile_image_mounter_lock(mobile_image_mounter_client_t client)
*/
static void mobile_image_mounter_unlock(mobile_image_mounter_client_t client)
{
- g_mutex_unlock(client->mutex);
+ pthread_mutex_unlock(&client->mutex);
}
/**
@@ -90,10 +90,6 @@ static mobile_image_mounter_error_t mobile_image_mounter_error(property_list_ser
*/
mobile_image_mounter_error_t mobile_image_mounter_new(idevice_t device, uint16_t port, mobile_image_mounter_client_t *client)
{
- /* makes sure thread environment is available */
- if (!g_thread_supported())
- g_thread_init(NULL);
-
if (!device)
return MOBILE_IMAGE_MOUNTER_E_INVALID_ARG;
@@ -105,7 +101,7 @@ mobile_image_mounter_error_t mobile_image_mounter_new(idevice_t device, uint16_t
mobile_image_mounter_client_t client_loc = (mobile_image_mounter_client_t) malloc(sizeof(struct mobile_image_mounter_client_private));
client_loc->parent = plistclient;
- client_loc->mutex = g_mutex_new();
+ pthread_mutex_init(&client_loc->mutex, NULL);
*client = client_loc;
return MOBILE_IMAGE_MOUNTER_E_SUCCESS;
@@ -127,9 +123,7 @@ mobile_image_mounter_error_t mobile_image_mounter_free(mobile_image_mounter_clie
property_list_service_client_free(client->parent);
client->parent = NULL;
- if (client->mutex) {
- g_mutex_free(client->mutex);
- }
+ pthread_mutex_destroy(&client->mutex);
free(client);
return MOBILE_IMAGE_MOUNTER_E_SUCCESS;
diff --git a/src/mobile_image_mounter.h b/src/mobile_image_mounter.h
index 2615dbc..e0828f9 100644
--- a/src/mobile_image_mounter.h
+++ b/src/mobile_image_mounter.h
@@ -21,14 +21,14 @@
#ifndef IMOBILE_IMAGE_MOUNTER_H
#define IMOBILE_IMAGE_MOUNTER_H
-#include <glib.h>
+#include <pthread.h>
#include "libimobiledevice/mobile_image_mounter.h"
#include "property_list_service.h"
struct mobile_image_mounter_client_private {
property_list_service_client_t parent;
- GMutex *mutex;
+ pthread_mutex_t mutex;
};
#endif
diff --git a/src/notification_proxy.c b/src/notification_proxy.c
index a883cfa..792a165 100644
--- a/src/notification_proxy.c
+++ b/src/notification_proxy.c
@@ -42,7 +42,7 @@ struct np_thread {
static void np_lock(np_client_t client)
{
debug_info("NP: Locked");
- g_mutex_lock(client->mutex);
+ pthread_mutex_lock(&client->mutex);
}
/**
@@ -53,7 +53,7 @@ static void np_lock(np_client_t client)
static void np_unlock(np_client_t client)
{
debug_info("NP: Unlocked");
- g_mutex_unlock(client->mutex);
+ pthread_mutex_unlock(&client->mutex);
}
/**
@@ -96,10 +96,6 @@ static np_error_t np_error(property_list_service_error_t err)
*/
np_error_t np_client_new(idevice_t device, uint16_t port, np_client_t *client)
{
- /* makes sure thread environment is available */
- if (!g_thread_supported())
- g_thread_init(NULL);
-
if (!device)
return NP_E_INVALID_ARG;
@@ -111,9 +107,9 @@ np_error_t np_client_new(idevice_t device, uint16_t port, np_client_t *client)
np_client_t client_loc = (np_client_t) malloc(sizeof(struct np_client_private));
client_loc->parent = plistclient;
- client_loc->mutex = g_mutex_new();
+ pthread_mutex_init(&client_loc->mutex, NULL);
- client_loc->notifier = NULL;
+ client_loc->notifier = (pthread_t)NULL;
*client = client_loc;
return NP_E_SUCCESS;
@@ -136,11 +132,9 @@ np_error_t np_client_free(np_client_t client)
client->parent = NULL;
if (client->notifier) {
debug_info("joining np callback");
- g_thread_join(client->notifier);
- }
- if (client->mutex) {
- g_mutex_free(client->mutex);
+ pthread_join(client->notifier, NULL);
}
+ pthread_mutex_destroy(&client->mutex);
free(client);
return NP_E_SUCCESS;
@@ -344,7 +338,7 @@ static int np_get_notification(np_client_t client, char **notification)
/**
* Internally used thread function.
*/
-gpointer np_notifier( gpointer arg )
+void* np_notifier( void* arg )
{
char *notification = NULL;
struct np_thread *npt = (struct np_thread*)arg;
@@ -399,8 +393,8 @@ np_error_t np_set_notify_callback( np_client_t client, np_notify_cb_t notify_cb,
debug_info("callback already set, removing\n");
property_list_service_client_t parent = client->parent;
client->parent = NULL;
- g_thread_join(client->notifier);
- client->notifier = NULL;
+ pthread_join(client->notifier, NULL);
+ client->notifier = (pthread_t)NULL;
client->parent = parent;
}
@@ -411,8 +405,7 @@ np_error_t np_set_notify_callback( np_client_t client, np_notify_cb_t notify_cb,
npt->cbfunc = notify_cb;
npt->user_data = user_data;
- client->notifier = g_thread_create(np_notifier, npt, TRUE, NULL);
- if (client->notifier) {
+ if (pthread_create(&client->notifier, NULL, np_notifier, npt) == 0) {
res = NP_E_SUCCESS;
}
}
diff --git a/src/notification_proxy.h b/src/notification_proxy.h
index 8d5cd24..4a9cdad 100644
--- a/src/notification_proxy.h
+++ b/src/notification_proxy.h
@@ -21,17 +21,17 @@
#ifndef INOTIFICATION_PROXY_H
#define INOTIFICATION_PROXY_H
-#include <glib.h>
+#include <pthread.h>
#include "libimobiledevice/notification_proxy.h"
#include "property_list_service.h"
struct np_client_private {
property_list_service_client_t parent;
- GMutex *mutex;
- GThread *notifier;
+ pthread_mutex_t mutex;
+ pthread_t notifier;
};
-gpointer np_notifier(gpointer arg);
+void* np_notifier(void* arg);
#endif
diff --git a/src/sbservices.c b/src/sbservices.c
index 3596cbd..dd5f571 100644
--- a/src/sbservices.c
+++ b/src/sbservices.c
@@ -36,7 +36,7 @@
static void sbs_lock(sbservices_client_t client)
{
debug_info("SBServices: Locked");
- g_mutex_lock(client->mutex);
+ pthread_mutex_lock(&client->mutex);
}
/**
@@ -47,7 +47,7 @@ static void sbs_lock(sbservices_client_t client)
static void sbs_unlock(sbservices_client_t client)
{
debug_info("SBServices: Unlocked");
- g_mutex_unlock(client->mutex);
+ pthread_mutex_unlock(&client->mutex);
}
/**
@@ -89,10 +89,6 @@ static sbservices_error_t sbservices_error(property_list_service_error_t err)
*/
sbservices_error_t sbservices_client_new(idevice_t device, uint16_t port, sbservices_client_t *client)
{
- /* makes sure thread environment is available */
- if (!g_thread_supported())
- g_thread_init(NULL);
-
if (!device)
return SBSERVICES_E_INVALID_ARG;
@@ -104,7 +100,7 @@ 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;
- client_loc->mutex = g_mutex_new();
+ pthread_mutex_init(&client_loc->mutex, NULL);
*client = client_loc;
return SBSERVICES_E_SUCCESS;
@@ -126,9 +122,7 @@ 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;
- if (client->mutex) {
- g_mutex_free(client->mutex);
- }
+ pthread_mutex_destroy(&client->mutex);
free(client);
return err;
diff --git a/src/sbservices.h b/src/sbservices.h
index 3a4120f..1c85fe8 100644
--- a/src/sbservices.h
+++ b/src/sbservices.h
@@ -21,14 +21,14 @@
#ifndef ISBSERVICES_H
#define ISBSERVICES_H
-#include <glib.h>
+#include <pthread.h>
#include "libimobiledevice/sbservices.h"
#include "property_list_service.h"
struct sbservices_client_private {
property_list_service_client_t parent;
- GMutex *mutex;
+ pthread_mutex_t mutex;
};
#endif