Skip to content

Commit

Permalink
test: Fix the tcp-accept-stress test
Browse files Browse the repository at this point in the history
It was previously asserted that each thread received at least one connection,
but this is not guaranteed to always be the case due to scheduling. This test
also deadlocked on failure due to a lingering reference to the sending half of
the channel, so that reference is now also eagerly dropped so the test can fail
properly if something bad happens.

Closes #16872
  • Loading branch information
alexcrichton committed Aug 31, 2014
1 parent c256454 commit 4ddbb0d
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions src/test/run-pass/tcp-accept-stress.rs
Expand Up @@ -8,8 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// ignore-macos #16872 spurious deadlock

#![feature(phase)]

#[phase(plugin)]
Expand Down Expand Up @@ -49,11 +47,9 @@ fn test() {
let tx = tx.clone();
spawn(proc() {
let mut a = a;
let mut mycnt = 0u;
loop {
match a.accept() {
Ok(..) => {
mycnt += 1;
if cnt.fetch_add(1, atomic::SeqCst) == N * M - 1 {
break
}
Expand All @@ -62,7 +58,6 @@ fn test() {
Err(e) => fail!("{}", e),
}
}
assert!(mycnt > 0);
tx.send(());
});
}
Expand All @@ -77,6 +72,7 @@ fn test() {
tx.send(());
});
}
drop(tx);

// wait for senders
assert_eq!(rx.iter().take(N).count(), N);
Expand Down

5 comments on commit 4ddbb0d

@bors
Copy link
Contributor

@bors bors commented on 4ddbb0d Aug 31, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from huonw
at alexcrichton@4ddbb0d

@bors
Copy link
Contributor

@bors bors commented on 4ddbb0d Aug 31, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging alexcrichton/rust/issue-16872 = 4ddbb0d into auto

@bors
Copy link
Contributor

@bors bors commented on 4ddbb0d Aug 31, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alexcrichton/rust/issue-16872 = 4ddbb0d merged ok, testing candidate = 08176a3

@bors
Copy link
Contributor

@bors bors commented on 4ddbb0d Aug 31, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = 08176a3

Please sign in to comment.