1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
|
Description: fix possible hangups of egd_close on biosemi
When stopping the handshake, URB can report of URB failure because of
timeout. This patch makes sure that whenever a URB is not resubmitted, this
will be indicated by reducing the number of running transfers
(a2dev->num_running). This should also fix the hang when closing a device
that has failed during acquisition.
Origin: upstream, http://cnbisrv02.epfl.ch/cgit/eegdev.git/commit/?id=cdf41d
Bug-Debian: http://bugs.debian.org/673681
Author: Nicolas Bourdaud <nicolas.bourdaud@gmail.com>
Last-Update: 2012-05-23
Applied-Upstream: yes
diff --git a/src/plugins/biosemi.c b/src/plugins/biosemi.c
index 473edde..6e5e4aa 100644
--- a/src/plugins/biosemi.c
+++ b/src/plugins/biosemi.c
@@ -393,7 +393,7 @@ void process_usbbuf(struct act2_eegdev* a2dev, uint32_t* buf, ssize_t bs)
#endif
static void LIBUSB_CALL req_completion_fn(struct libusb_transfer *transfer)
{
- int ret;
+ int ret, requeue = 1;
struct act2_eegdev* a2dev = transfer->user_data;
const struct core_interface* ci = &(a2dev->dev.ci);
@@ -405,20 +405,24 @@ static void LIBUSB_CALL req_completion_fn(struct libusb_transfer *transfer)
// Check that no error occured
if ((ret = proc_libusb_transfer_ret(transfer->status))) {
ci->report_error(&(a2dev->dev), ret);
- return;
+ requeue = 0;
}
- // requeue again the chunk buffer if still running
pthread_mutex_lock(&a2dev->mtx);
- if (a2dev->resubmit) {
- // Try submit
- if ((ret = libusb_submit_transfer(transfer))) {
- ci->report_error(&(a2dev->dev),
- proc_libusb_error(ret));
- a2dev->num_running--;
- }
- } else if (!--(a2dev->num_running))
+
+ // requeue again the chunk buffer if still running
+ requeue = a2dev->resubmit ? requeue : 0;
+ if (requeue && (ret = libusb_submit_transfer(transfer))) {
+ ci->report_error(&(a2dev->dev), proc_libusb_error(ret));
+ requeue = 0;
+ }
+
+ // Signal main thread that this urb stopped
+ if (!requeue) {
+ a2dev->num_running--;
pthread_cond_signal(&a2dev->cond);
+ }
+
pthread_mutex_unlock(&a2dev->mtx);
}
--
1.7.10
|