diff options
| -rw-r--r-- | iphone.c | 2 | ||||
| -rw-r--r-- | main.c | 11 | ||||
| -rw-r--r-- | sock_stuff.c | 4 | 
3 files changed, 8 insertions, 9 deletions
| @@ -1086,7 +1086,7 @@ int iphone_mux_pullbulk(iphone_device_t phone)      // start the cursor off just ahead of the leftover.      char* cursor = &phone->usbReceive.buffer[phone->usbReceive.leftover];      // pull in content, note that the amount we can pull is capacity minus leftover -    int readlen = recv_from_phone_timeout(phone, cursor, phone->usbReceive.capacity - phone->usbReceive.leftover, 5000); +    int readlen = recv_from_phone_timeout(phone, cursor, phone->usbReceive.capacity - phone->usbReceive.leftover, 3000);      if (readlen < 0) {  	res = readlen;          //fprintf(stderr, "recv_from_phone_timeout gave us an error.\n"); @@ -605,11 +605,11 @@ connect:      if (verbose >= 3) fprintf(stderr, "%s: Setting up connection to usb device #%d on port %d\n", __func__, c_req->device_id, ntohs(c_req->tcp_dport));      // find the device, and open usb connection +    pthread_mutex_lock(&usbmux_mutex);      phone = NULL;      cur_dev = NULL;      // first check if we already have an open connection      if (devices) { -	pthread_mutex_lock(&usbmux_mutex);  	for (i = 0; i < device_count; i++) {  	    if (devices[i]) {  		if (devices[i]->device_id == c_req->device_id) { @@ -620,7 +620,6 @@ connect:  		}  	    }  	} -	pthread_mutex_unlock(&usbmux_mutex);      }      if (!phone) {  	// if not found, make a new connection @@ -629,6 +628,7 @@ connect:  	pthread_mutex_lock(&usb_mutex);  	if (iphone_get_specific_device(0, c_req->device_id, &phone) != IPHONE_E_SUCCESS) {  	    pthread_mutex_unlock(&usb_mutex); +    	    pthread_mutex_unlock(&usbmux_mutex);  	    if (verbose >= 1) fprintf(stderr, "%s: device_id %d could not be opened\n", __func__, c_req->device_id);  	    usbmuxd_send_result(cdata->socket, c_req->header.tag, ENODEV);  	    goto leave; @@ -636,7 +636,6 @@ connect:  	pthread_mutex_unlock(&usb_mutex);  	// create device object -	pthread_mutex_lock(&usbmux_mutex);  	if (verbose >= 3) fprintf(stderr, "%s: add to device list\n", __func__);  	cur_dev = (struct device_info*)malloc(sizeof(struct device_info));  	memset(cur_dev, 0, sizeof(struct device_info)); @@ -655,10 +654,10 @@ connect:  	    devices[device_count] = cur_dev;  	    device_count++;  	} -	pthread_mutex_unlock(&usbmux_mutex);      } else {  	if (verbose >= 3) fprintf(stderr, "%s: reusing usb connection, device_id=%d\n", __func__, c_req->device_id);      } +    pthread_mutex_unlock(&usbmux_mutex);      // setup connection to iPhone/iPod  //    pthread_mutex_lock(&usbmux_mutex); @@ -712,6 +711,7 @@ leave:      // this has to be freed only if it's not in use anymore as it closes      // the USB connection +    pthread_mutex_lock(&usbmux_mutex);      if (cur_dev) {  	pthread_mutex_lock(&cur_dev->mutex);  	if (cur_dev->use_count > 1) { @@ -733,7 +733,6 @@ leave:  	    pthread_mutex_destroy(&cur_dev->mutex);  	    free(cur_dev);  	    cur_dev = NULL; -	    pthread_mutex_lock(&usbmux_mutex);  	    if (device_count > 1) {  		struct device_info **newlist;  		int j; @@ -752,9 +751,9 @@ leave:  		devices = NULL;  		device_count = 0;  	    } -	    pthread_mutex_unlock(&usbmux_mutex);  	}      } +    pthread_mutex_unlock(&usbmux_mutex);      cdata->dead = 1;      close(cdata->socket); diff --git a/sock_stuff.c b/sock_stuff.c index 78249e6..8a06135 100644 --- a/sock_stuff.c +++ b/sock_stuff.c @@ -11,7 +11,7 @@  #include <arpa/inet.h>  #include "sock_stuff.h" -#define RECV_TIMEOUT 10000 +#define RECV_TIMEOUT 20000  static int verbose = 0; @@ -75,7 +75,7 @@ int connect_unix_socket(const char *filename)      // check if socket file exists...      if (stat(filename, &fst) != 0) { -    	if (verbose >= 2) fprintf(stderr, "%s: stat '%s': %s\n", __func__, filename, strerror(errno)); +	if (verbose >= 2) fprintf(stderr, "%s: stat '%s': %s\n", __func__, filename, strerror(errno));  	return -1;      } | 
