Skip to content

Commit 658a322

Browse files
committed
---
yaml --- r: 29824 b: refs/heads/incoming c: 821fa33 h: refs/heads/master v: v3
1 parent 8ff89c0 commit 658a322

File tree

2 files changed

+46
-4
lines changed

2 files changed

+46
-4
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: d324a424d8f84b1eb049b12cf34182bda91b0024
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: d0c6ce338884ee21843f4b40bf6bf18d222ce5df
9-
refs/heads/incoming: 4f3aeb4703f26d4063cd87bf2a0862051394b504
9+
refs/heads/incoming: 821fa337ffbc81fe5dad7dd1b3fa49dac84aa4ef
1010
refs/heads/dist-snap: 2f32a1581f522e524009138b33b1c7049ced668d
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/incoming/src/libstd/sync.rs

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -763,9 +763,51 @@ mod tests {
763763
assert result.is_err();
764764
// child task must have finished by the time try returns
765765
do m.lock_cond |cond| {
766-
let _woken = cond.signal();
767-
// FIXME(#3145) this doesn't work
768-
//assert !woken;
766+
let woken = cond.signal();
767+
assert !woken;
768+
}
769+
}
770+
#[test] #[ignore(cfg(windows))]
771+
fn test_mutex_killed_broadcast() {
772+
let m = ~mutex();
773+
let m2 = ~m.clone();
774+
let (c,p) = pipes::stream();
775+
776+
let result: result::result<(),()> = do task::try {
777+
let mut sibling_convos = ~[];
778+
for 2.times {
779+
let (c,p) = pipes::stream();
780+
let c = ~mut some(c);
781+
vec::push(sibling_convos, p);
782+
let mi = ~m2.clone();
783+
// spawn sibling task
784+
do task::spawn { // linked
785+
do mi.lock_cond |cond| {
786+
let c = option::swap_unwrap(c);
787+
c.send(()); // tell sibling to go ahead
788+
let _z = send_on_failure(c);
789+
cond.wait(); // block forever
790+
}
791+
}
792+
}
793+
for vec::each(sibling_convos) |p| {
794+
let _ = p.recv(); // wait for sibling to get in the mutex
795+
}
796+
do m2.lock { }
797+
c.send(sibling_convos); // let parent wait on all children
798+
fail;
799+
};
800+
assert result.is_err();
801+
// child task must have finished by the time try returns
802+
for vec::each(p.recv()) |p| { p.recv(); } // wait on all its siblings
803+
do m.lock_cond |cond| {
804+
let woken = cond.broadcast();
805+
assert woken == 0;
806+
}
807+
struct send_on_failure {
808+
c: pipes::chan<()>;
809+
new(+c: pipes::chan<()>) { self.c = c; }
810+
drop { self.c.send(()); }
769811
}
770812
}
771813
/************************************************************************

0 commit comments

Comments
 (0)