diff options
| author | 2009-02-27 12:50:02 +0100 | |
|---|---|---|
| committer | 2009-02-27 12:50:02 +0100 | |
| commit | 2a5d90a74586d16a072f941f5e5748dc2af89daa (patch) | |
| tree | a6b600df7ca6da2ec1e253a9e3a4cbfcfdc552da | |
| parent | 365b6c9b208e483af751a43a9ccc8885553859ee (diff) | |
| download | usbmuxd-2a5d90a74586d16a072f941f5e5748dc2af89daa.tar.gz usbmuxd-2a5d90a74586d16a072f941f5e5748dc2af89daa.tar.bz2 | |
Removed the (already commented out) reader_mutex, as it is not needed, and iphone_mux_pullbulk is only running once per device and the iphone_mux_recv_timeout function does it's own locking.
| -rw-r--r-- | main.c | 12 |
1 files changed, 0 insertions, 12 deletions
| @@ -54,8 +54,6 @@ struct device_use_info { | |||
| 54 | /* mutex for mutual exclusion of calling the iphone_mux_send function | 54 | /* mutex for mutual exclusion of calling the iphone_mux_send function |
| 55 | * TODO: I don't know if we need really need this? */ | 55 | * TODO: I don't know if we need really need this? */ |
| 56 | pthread_mutex_t writer_mutex; | 56 | pthread_mutex_t writer_mutex; |
| 57 | /* mutex to keep the reader threads from reading partial packages */ | ||
| 58 | //pthread_mutex_t reader_mutex; | ||
| 59 | }; | 57 | }; |
| 60 | 58 | ||
| 61 | struct client_data { | 59 | struct client_data { |
| @@ -213,9 +211,7 @@ static void *usbmuxd_client_reader_thread(void *arg) | |||
| 213 | } | 211 | } |
| 214 | 212 | ||
| 215 | rlen = 0; | 213 | rlen = 0; |
| 216 | //pthread_mutex_lock(&cdata->duinfo->reader_mutex); | ||
| 217 | err = iphone_mux_recv_timeout(cdata->muxclient, rbuffer, rbuffersize, &rlen, DEFAULT_TIMEOUT); | 214 | err = iphone_mux_recv_timeout(cdata->muxclient, rbuffer, rbuffersize, &rlen, DEFAULT_TIMEOUT); |
| 218 | //pthread_mutex_unlock(&cdata->duinfo->reader_mutex); | ||
| 219 | if (err != 0) { | 215 | if (err != 0) { |
| 220 | fprintf(stderr, "%s[%d:%d]: encountered USB read error: %d\n", __func__, cdata->duinfo->device_id, cdata->duinfo->use_count, err); | 216 | fprintf(stderr, "%s[%d:%d]: encountered USB read error: %d\n", __func__, cdata->duinfo->device_id, cdata->duinfo->use_count, err); |
| 221 | break; | 217 | break; |
| @@ -272,9 +268,7 @@ static int usbmuxd_handleConnectResult(struct client_data *cdata) | |||
| 272 | } | 268 | } |
| 273 | } else { | 269 | } else { |
| 274 | result = 0; | 270 | result = 0; |
| 275 | //pthread_mutex_lock(&cdata->duinfo->reader_mutex); | ||
| 276 | err = iphone_mux_recv_timeout(cdata->muxclient, buffer, maxlen, &rlen, DEFAULT_TIMEOUT); | 271 | err = iphone_mux_recv_timeout(cdata->muxclient, buffer, maxlen, &rlen, DEFAULT_TIMEOUT); |
| 277 | //pthread_mutex_unlock(&cdata->duinfo->reader_mutex); | ||
| 278 | if (err != 0) { | 272 | if (err != 0) { |
| 279 | fprintf(stderr, "%s: encountered USB read error: %d\n", __func__, err); | 273 | fprintf(stderr, "%s: encountered USB read error: %d\n", __func__, err); |
| 280 | usbmuxd_send_result(cdata->socket, cdata->tag, -err); | 274 | usbmuxd_send_result(cdata->socket, cdata->tag, -err); |
| @@ -432,10 +426,8 @@ static void *usbmuxd_bulk_reader_thread(void *arg) | |||
| 432 | } | 426 | } |
| 433 | pthread_mutex_unlock(&cur_dev->mutex); | 427 | pthread_mutex_unlock(&cur_dev->mutex); |
| 434 | 428 | ||
| 435 | //pthread_mutex_lock(&cur_dev->reader_mutex); | ||
| 436 | iphone_mux_pullbulk(cur_dev->phone); | 429 | iphone_mux_pullbulk(cur_dev->phone); |
| 437 | //err = iphone_mux_get_error(cdata->muxclient); | 430 | //err = iphone_mux_get_error(cdata->muxclient); |
| 438 | //pthread_mutex_unlock(&cur_dev->reader_mutex); | ||
| 439 | //if (err != IPHONE_E_SUCCESS) { | 431 | //if (err != IPHONE_E_SUCCESS) { |
| 440 | // break; | 432 | // break; |
| 441 | //} | 433 | //} |
| @@ -593,7 +585,6 @@ static void *usbmuxd_client_init_thread(void *arg) | |||
| 593 | cur_dev->device_id = c_req.device_id; | 585 | cur_dev->device_id = c_req.device_id; |
| 594 | cur_dev->phone = phone; | 586 | cur_dev->phone = phone; |
| 595 | pthread_mutex_init(&cur_dev->mutex, NULL); | 587 | pthread_mutex_init(&cur_dev->mutex, NULL); |
| 596 | //pthread_mutex_init(&cur_dev->reader_mutex, NULL); | ||
| 597 | pthread_mutex_init(&cur_dev->writer_mutex, NULL); | 588 | pthread_mutex_init(&cur_dev->writer_mutex, NULL); |
| 598 | 589 | ||
| 599 | fprintf(stdout, "%s: device_use_count = %d\n", __func__, device_use_count); | 590 | fprintf(stdout, "%s: device_use_count = %d\n", __func__, device_use_count); |
| @@ -639,10 +630,8 @@ static void *usbmuxd_client_init_thread(void *arg) | |||
| 639 | /* | 630 | /* |
| 640 | // start reading data from the connected device | 631 | // start reading data from the connected device |
| 641 | while (!quit_flag && !cdata->handler_dead) { | 632 | while (!quit_flag && !cdata->handler_dead) { |
| 642 | pthread_mutex_lock(&cur_dev->reader_mutex); | ||
| 643 | iphone_mux_pullbulk(cur_dev->phone); | 633 | iphone_mux_pullbulk(cur_dev->phone); |
| 644 | err = iphone_mux_get_error(cdata->muxclient); | 634 | err = iphone_mux_get_error(cdata->muxclient); |
| 645 | pthread_mutex_unlock(&cur_dev->reader_mutex); | ||
| 646 | if (err != IPHONE_E_SUCCESS) { | 635 | if (err != IPHONE_E_SUCCESS) { |
| 647 | break; | 636 | break; |
| 648 | } | 637 | } |
| @@ -685,7 +674,6 @@ leave: | |||
| 685 | pthread_mutex_unlock(&cur_dev->mutex); | 674 | pthread_mutex_unlock(&cur_dev->mutex); |
| 686 | pthread_join(cur_dev->bulk_reader, NULL); | 675 | pthread_join(cur_dev->bulk_reader, NULL); |
| 687 | iphone_free_device(cur_dev->phone); | 676 | iphone_free_device(cur_dev->phone); |
| 688 | //pthread_mutex_destroy(&cur_dev->reader_mutex); | ||
| 689 | pthread_mutex_destroy(&cur_dev->writer_mutex); | 677 | pthread_mutex_destroy(&cur_dev->writer_mutex); |
| 690 | pthread_mutex_destroy(&cur_dev->mutex); | 678 | pthread_mutex_destroy(&cur_dev->mutex); |
| 691 | free(cur_dev); | 679 | free(cur_dev); |
