Skip to content

Commit 4560307

Browse files
committed
---
yaml --- r: 21116 b: refs/heads/snap-stage3 c: 821fa33 h: refs/heads/master v: v3
1 parent 25e3140 commit 4560307

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
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: e430a699f2c60890d9b86069fd0c68a70ece7120
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 4f3aeb4703f26d4063cd87bf2a0862051394b504
4+
refs/heads/snap-stage3: 821fa337ffbc81fe5dad7dd1b3fa49dac84aa4ef
55
refs/heads/try: ffbe0e0e00374358b789b0037bcb3a577cd218be
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/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)