File: condtimedwait-kfreebsd-bug-workaround.patch

package info (click to toggle)
eegdev 0.2-3
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 4,972 kB
  • sloc: ansic: 32,259; sh: 10,941; makefile: 247; lex: 128; yacc: 118
file content (38 lines) | stat: -rw-r--r-- 1,358 bytes parent folder | download | duplicates (6)
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
Description: temporary workaround of kfreebsd bug
 pthread_cond_timedwait on kfreebsd is buggy (Debian bug: #673711)
Origin: vendor
Bug-Debian: http://bugs.debian.org/673681
Forwarded: not-needed
Author: Nicolas Bourdaud <nicolas.bourdaud@gmail.com>
Last-Update: 2012-05-21
diff --git a/tests/fakelibs/activetwo.c b/tests/fakelibs/activetwo.c
index f11ce0e..777593f 100644
--- a/tests/fakelibs/activetwo.c
+++ b/tests/fakelibs/activetwo.c
@@ -162,8 +162,10 @@ int wait_transfer(struct event_queue* eq,
 		// Wait for the timeout or for a request to be added
 		if (req < 0)
 			pthread_cond_wait(&eq->cond, &eq->lock);
-		else if (pthread_cond_timedwait(&eq->cond, &eq->lock, &nextts) == ETIMEDOUT)
+		else if (pthread_cond_timedwait(&eq->cond, &eq->lock, &nextts) == ETIMEDOUT) {
+			clock_nanosleep(CLOCK_REALTIME, TIMER_ABSTIME, &nextts, NULL);
 			break;
+		}
 	}
 
 	return req;
@@ -215,8 +217,10 @@ struct libusb_transfer* dequeue_transfer(struct event_queue* eq, struct timespec
 
 	pthread_mutex_lock(&eq->lock);
 	while (to && !eq->nqueued) {
-		if (pthread_cond_timedwait(&eq->cond, &eq->lock, to) == ETIMEDOUT)
+		if (pthread_cond_timedwait(&eq->cond, &eq->lock, to) == ETIMEDOUT) {
+			clock_nanosleep(CLOCK_REALTIME, TIMER_ABSTIME, to, NULL);
 			break;
+		}
 	}
 	transfer = peek_transfer(eq, 0);
 	pthread_mutex_unlock(&eq->lock);
-- 
1.7.10