diff options
Diffstat (limited to 'main.c')
| -rw-r--r-- | main.c | 11 |
1 files changed, 9 insertions, 2 deletions
| @@ -633,11 +633,11 @@ connect: | |||
| 633 | cur_dev->use_count = 1; | 633 | cur_dev->use_count = 1; |
| 634 | cur_dev->device_id = c_req->device_id; | 634 | cur_dev->device_id = c_req->device_id; |
| 635 | cur_dev->phone = phone; | 635 | cur_dev->phone = phone; |
| 636 | cur_dev->bulk_reader = 0; | ||
| 636 | pthread_mutex_init(&cur_dev->mutex, NULL); | 637 | pthread_mutex_init(&cur_dev->mutex, NULL); |
| 637 | pthread_mutex_init(&cur_dev->writer_mutex, NULL); | 638 | pthread_mutex_init(&cur_dev->writer_mutex, NULL); |
| 638 | 639 | ||
| 639 | if (verbose >= 3) fprintf(stderr, "%s: device_use_count = %d\n", __func__, device_use_count); | 640 | if (verbose >= 3) fprintf(stderr, "%s: device_use_count = %d\n", __func__, device_use_count); |
| 640 | pthread_create(&cur_dev->bulk_reader, NULL, usbmuxd_bulk_reader_thread, cur_dev); | ||
| 641 | 641 | ||
| 642 | pthread_mutex_lock(&usbmux_mutex); | 642 | pthread_mutex_lock(&usbmux_mutex); |
| 643 | device_use_list = (struct device_use_info**)realloc(device_use_list, sizeof(struct device_use_info*) * (device_use_count+1)); | 643 | device_use_list = (struct device_use_info**)realloc(device_use_list, sizeof(struct device_use_info*) * (device_use_count+1)); |
| @@ -661,6 +661,11 @@ connect: | |||
| 661 | goto leave; | 661 | goto leave; |
| 662 | } | 662 | } |
| 663 | 663 | ||
| 664 | // start bulk reader thread (once per device) | ||
| 665 | if (cur_dev->bulk_reader == 0) { | ||
| 666 | pthread_create(&cur_dev->bulk_reader, NULL, usbmuxd_bulk_reader_thread, cur_dev); | ||
| 667 | } | ||
| 668 | |||
| 664 | // start connection handler thread | 669 | // start connection handler thread |
| 665 | cdata->handler_dead = 0; | 670 | cdata->handler_dead = 0; |
| 666 | cdata->tag = c_req->header.tag; | 671 | cdata->tag = c_req->header.tag; |
| @@ -728,7 +733,9 @@ leave: | |||
| 728 | if (verbose >= 3) fprintf(stderr, "%s: last client disconnected, cleaning up\n", __func__); | 733 | if (verbose >= 3) fprintf(stderr, "%s: last client disconnected, cleaning up\n", __func__); |
| 729 | cur_dev->use_count = 0; | 734 | cur_dev->use_count = 0; |
| 730 | pthread_mutex_unlock(&cur_dev->mutex); | 735 | pthread_mutex_unlock(&cur_dev->mutex); |
| 731 | pthread_join(cur_dev->bulk_reader, NULL); | 736 | if (cur_dev->bulk_reader != 0) { |
| 737 | pthread_join(cur_dev->bulk_reader, NULL); | ||
| 738 | } | ||
| 732 | pthread_mutex_lock(&usb_mutex); | 739 | pthread_mutex_lock(&usb_mutex); |
| 733 | iphone_free_device(cur_dev->phone); | 740 | iphone_free_device(cur_dev->phone); |
| 734 | pthread_mutex_unlock(&usb_mutex); | 741 | pthread_mutex_unlock(&usb_mutex); |
