File tree Expand file tree Collapse file tree 2 files changed +40
-1
lines changed Expand file tree Collapse file tree 2 files changed +40
-1
lines changed Original file line number Diff line number Diff line change @@ -156,7 +156,16 @@ fn peek<T: send>(p: recv_packet<T>) -> bool {
156
156
fn sender_terminate < T : send > ( p : * packet < T > ) {
157
157
let p = unsafe { uniquify ( p) } ;
158
158
alt swap_state_rel ( p. header . state , terminated) {
159
- empty | blocked {
159
+ empty {
160
+ // The receiver will eventually clean up.
161
+ unsafe { forget( p) }
162
+ }
163
+ blocked {
164
+ // wake up the target
165
+ let target = p. header . blocked_task . get ( ) ;
166
+ rustrt:: task_signal_event ( target,
167
+ ptr:: addr_of ( p. header ) as * libc:: c_void ) ;
168
+
160
169
// The receiver will eventually clean up.
161
170
unsafe { forget ( p) }
162
171
}
Original file line number Diff line number Diff line change
1
+ // Make sure that we can detect when one end of the pipe is closed.
2
+
3
+ // xfail-pretty
4
+
5
+ use std;
6
+ import std:: timer:: sleep;
7
+ import std:: uv;
8
+
9
+ import pipes:: { recv} ;
10
+
11
+ proto ! oneshot {
12
+ waiting: send {
13
+ signal -> signaled
14
+ }
15
+
16
+ signaled: send { }
17
+ }
18
+
19
+ fn main ( ) {
20
+ let iotask = uv:: global_loop:: get ( ) ;
21
+
22
+ let c = pipes:: spawn_service ( oneshot:: init, |p| {
23
+ alt recv ( p) {
24
+ some ( * ) { fail }
25
+ none { }
26
+ }
27
+ } ) ;
28
+
29
+ sleep ( iotask, 1000 ) ;
30
+ }
You can’t perform that action at this time.
0 commit comments