summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar BALATON Zoltan2015-05-05 01:16:38 +0200
committerGravatar BALATON Zoltan2015-05-05 01:19:41 +0200
commit9a53b8f2bc3c2ac366d208b620d6404e936e2a92 (patch)
tree821796eeb2fc096ffb886aa8fb9b297421065d37
parente96e7dea1c2cd12ddb2679b7f91775c48aff4d11 (diff)
downloadidevicerestore-9a53b8f2bc3c2ac366d208b620d6404e936e2a92.tar.gz
idevicerestore-9a53b8f2bc3c2ac366d208b620d6404e936e2a92.tar.bz2
Update fdr implementation for thread function changes in latest
libimobiledevice version
-rw-r--r--src/fdr.c6
-rw-r--r--src/restore.c6
-rw-r--r--src/socket.c6
-rw-r--r--src/socket.h6
-rw-r--r--src/thread.c21
-rw-r--r--src/thread.h9
6 files changed, 31 insertions, 23 deletions
diff --git a/src/fdr.c b/src/fdr.c
index 8d5c9c5..aae92ef 100644
--- a/src/fdr.c
+++ b/src/fdr.c
@@ -21,7 +21,6 @@
#include <sys/types.h>
#include <sys/stat.h>
-#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
@@ -33,6 +32,7 @@
#include "common.h"
#include "idevicerestore.h"
#include "fdr.h"
+#include <endianness.h> /* from libimobiledevice */
#define CTRL_PROTO_VERSION 2
#define CTRL_PORT 0x43a /*14852*/
@@ -313,7 +313,7 @@ static int fdr_handle_sync_cmd(fdr_client_t fdr_ctrl)
{
idevice_error_t device_error = IDEVICE_E_SUCCESS;
fdr_client_t fdr;
- thread_t fdr_thread = 0;
+ thread_t fdr_thread = NULL;
int res = 0;
uint32_t bytes = 0;
char buf[4096];
@@ -329,7 +329,7 @@ static int fdr_handle_sync_cmd(fdr_client_t fdr_ctrl)
return -1;
}
debug("FDR connected in reply to sync message, starting command thread\n");
- res = thread_create(&fdr_thread, fdr_listener_thread, fdr);
+ res = thread_new(&fdr_thread, fdr_listener_thread, fdr);
if(res) {
error("ERROR: Failed to start FDR command thread\n");
fdr_free(fdr);
diff --git a/src/restore.c b/src/restore.c
index aa352c5..b324470 100644
--- a/src/restore.c
+++ b/src/restore.c
@@ -1655,7 +1655,7 @@ int restore_device(struct idevicerestore_client_t* client, plist_t build_identit
idevice_t device = NULL;
restored_client_t restore = NULL;
restored_error_t restore_error = RESTORE_E_SUCCESS;
- thread_t fdr_thread = 0;
+ thread_t fdr_thread = NULL;
restore_finished = 0;
@@ -1744,9 +1744,9 @@ int restore_device(struct idevicerestore_client_t* client, plist_t build_identit
fdr_client_t fdr_control_channel = NULL;
info("FDRSupport indicated, starting FDR listener thread\n");
if (!fdr_connect(device, FDR_CTRL, &fdr_control_channel)) {
- if(thread_create(&fdr_thread, fdr_listener_thread, fdr_control_channel)) {
+ if(thread_new(&fdr_thread, fdr_listener_thread, fdr_control_channel)) {
error("ERROR: Failed to start FDR listener thread\n");
- fdr_thread = 0; /* undefined after failure */
+ fdr_thread = NULL; /* undefined after failure */
}
} else {
error("ERROR: Failed to start FDR Ctrl channel\n");
diff --git a/src/socket.c b/src/socket.c
index c35de33..b276864 100644
--- a/src/socket.c
+++ b/src/socket.c
@@ -8,15 +8,15 @@
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
- *
+ *
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <stdio.h>
diff --git a/src/socket.h b/src/socket.h
index c2b2599..81ee083 100644
--- a/src/socket.h
+++ b/src/socket.h
@@ -8,15 +8,15 @@
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
- *
+ *
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef __SOCKET_SOCKET_H
diff --git a/src/thread.c b/src/thread.c
index d6d6c1a..fdc8112 100644
--- a/src/thread.c
+++ b/src/thread.c
@@ -8,26 +8,26 @@
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
- *
+ *
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "thread.h"
-int thread_create(thread_t *thread, thread_func_t thread_func, void* data)
+int thread_new(thread_t *thread, thread_func_t thread_func, void* data)
{
#ifdef WIN32
HANDLE th = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)thread_func, data, 0, NULL);
- if (th == NULL) {
+ if (th == NULL) {
return -1;
- }
+ }
*thread = th;
return 0;
#else
@@ -36,6 +36,13 @@ int thread_create(thread_t *thread, thread_func_t thread_func, void* data)
#endif
}
+void thread_free(thread_t thread)
+{
+#ifdef WIN32
+ CloseHandle(thread);
+#endif
+}
+
void thread_join(thread_t thread)
{
/* wait for thread to complete */
@@ -95,5 +102,5 @@ void thread_once(thread_once_t *once_control, void (*init_routine)(void))
InterlockedExchange(&(once_control->lock), 0);
#else
pthread_once(once_control, init_routine);
-#endif
+#endif
}
diff --git a/src/thread.h b/src/thread.h
index 9b15cc4..bd53c5b 100644
--- a/src/thread.h
+++ b/src/thread.h
@@ -8,15 +8,15 @@
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
- *
+ *
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef __THREAD_H
@@ -43,7 +43,8 @@ typedef pthread_once_t thread_once_t;
typedef void* (*thread_func_t)(void* data);
-int thread_create(thread_t* thread, thread_func_t thread_func, void* data);
+int thread_new(thread_t* thread, thread_func_t thread_func, void* data);
+void thread_free(thread_t thread);
void thread_join(thread_t thread);
void mutex_init(mutex_t* mutex);