Skip to content

Commit ce84245

Browse files
committed
---
yaml --- r: 20861 b: refs/heads/snap-stage3 c: 01ca0d1 h: refs/heads/master i: 20859: 796b0f2 v: v3
1 parent 9acf2d1 commit ce84245

File tree

4 files changed

+19
-9
lines changed

4 files changed

+19
-9
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: 9e689666110e459e63f5bf4b64011fc81cc7fca2
4+
refs/heads/snap-stage3: 01ca0d1f680cf5aab5d1a81fea9de56d591f6658
55
refs/heads/try: ffbe0e0e00374358b789b0037bcb3a577cd218be
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/src/libcore/option.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,9 @@ fn swap_unwrap<T>(opt: &mut option<T>) -> T {
127127
unwrap(util::replace(opt, none))
128128
}
129129

130-
pure fn unwrap_expect<T>(-opt: option<T>, reason: ~str) -> T {
130+
pure fn unwrap_expect<T>(-opt: option<T>, reason: &str) -> T {
131131
//! As unwrap, but with a specified failure message.
132-
if opt.is_none() { fail reason; }
132+
if opt.is_none() { fail reason.to_unique(); }
133133
unwrap(opt)
134134
}
135135

branches/snap-stage3/src/libcore/pipes.rs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ Fails if the sender closes the connection.
343343
344344
*/
345345
fn recv<T: send, Tbuffer: send>(-p: recv_packet_buffered<T, Tbuffer>) -> T {
346-
option::unwrap(try_recv(p))
346+
option::unwrap_expect(try_recv(p), "connection closed")
347347
}
348348

349349
/** Attempts to receive a message from a pipe.
@@ -391,10 +391,13 @@ fn try_recv<T: send, Tbuffer: send>(-p: recv_packet_buffered<T, Tbuffer>)
391391
full {
392392
let mut payload = none;
393393
payload <-> p.payload;
394+
p.header.blocked_task = none;
394395
p.header.state = empty;
395396
return some(option::unwrap(payload))
396397
}
397398
terminated {
399+
// This assert detects when we've accidentally unsafely
400+
// casted too big of a number to a state.
398401
assert old_state == terminated;
399402
return none;
400403
}
@@ -428,10 +431,13 @@ fn sender_terminate<T: send>(p: *packet<T>) {
428431
}
429432
blocked {
430433
// wake up the target
431-
let target = p.header.blocked_task.get();
432-
rustrt::task_signal_event(target,
433-
ptr::addr_of(p.header) as *libc::c_void);
434-
434+
alt p.header.blocked_task {
435+
some(target) =>
436+
rustrt::task_signal_event(
437+
target,
438+
ptr::addr_of(p.header) as *libc::c_void),
439+
none => { debug!{"receiver is already shutting down"} }
440+
}
435441
// The receiver will eventually clean up.
436442
//unsafe { forget(p) }
437443
}
@@ -448,6 +454,7 @@ fn sender_terminate<T: send>(p: *packet<T>) {
448454
#[doc(hidden)]
449455
fn receiver_terminate<T: send>(p: *packet<T>) {
450456
let p = unsafe { &*p };
457+
assert p.header.blocked_task == none;
451458
alt swap_state_rel(p.header.state, terminated) {
452459
empty {
453460
// the sender will clean up
@@ -514,7 +521,7 @@ fn wait_many(pkts: &[*packet_header]) -> uint {
514521

515522
for pkts.each |p| { unsafe{ (*p).unblock()} }
516523

517-
debug!{"%?, %?", ready_packet, pkts[ready_packet]};
524+
debug!("%?, %?", ready_packet, pkts[ready_packet]);
518525

519526
unsafe {
520527
assert (*pkts[ready_packet]).state == full

branches/snap-stage3/src/rt/rust_task.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,9 @@ void
680680
rust_task::signal_event(void *event) {
681681
scoped_lock with(lifecycle_lock);
682682

683+
assert(task_state_blocked == state ||
684+
task_state_running == state);
685+
683686
this->event = event;
684687
event_reject = true;
685688
if(task_state_blocked == state) {

0 commit comments

Comments
 (0)