|
10 | 10 |
|
11 | 11 | use std::cast;
|
12 | 12 | use std::libc::{c_int, size_t, ssize_t, c_void};
|
13 |
| -use std::ptr; |
14 | 13 | use std::rt::BlockedTask;
|
15 | 14 | use std::rt::local::Local;
|
16 | 15 | use std::rt::sched::Scheduler;
|
@@ -124,35 +123,23 @@ impl StreamWatcher {
|
124 | 123 |
|
125 | 124 | // This will deallocate an internally used memory, along with closing the
|
126 | 125 | // handle (and freeing it).
|
127 |
| - // |
128 |
| - // The `synchronous` flag dictates whether this handle is closed |
129 |
| - // synchronously (the task is blocked) or asynchronously (the task is not |
130 |
| - // block, but the handle is still deallocated). |
131 |
| - pub fn close(&mut self, synchronous: bool) { |
132 |
| - if synchronous { |
133 |
| - let mut closing_task = None; |
134 |
| - unsafe { |
135 |
| - uvll::set_data_for_uv_handle(self.handle, &closing_task); |
136 |
| - } |
| 126 | + pub fn close(&mut self) { |
| 127 | + let mut closing_task = None; |
| 128 | + unsafe { |
| 129 | + uvll::set_data_for_uv_handle(self.handle, &closing_task); |
| 130 | + } |
137 | 131 |
|
138 |
| - // Wait for this stream to close because it possibly represents a remote |
139 |
| - // connection which may have consequences if we close asynchronously. |
140 |
| - let sched: ~Scheduler = Local::take(); |
141 |
| - do sched.deschedule_running_task_and_then |_, task| { |
142 |
| - closing_task = Some(task); |
143 |
| - unsafe { uvll::uv_close(self.handle, close_cb) } |
144 |
| - } |
145 |
| - } else { |
146 |
| - unsafe { |
147 |
| - uvll::set_data_for_uv_handle(self.handle, ptr::null::<u8>()); |
148 |
| - uvll::uv_close(self.handle, close_cb) |
149 |
| - } |
| 132 | + // Wait for this stream to close because it possibly represents a remote |
| 133 | + // connection which may have consequences if we close asynchronously. |
| 134 | + let sched: ~Scheduler = Local::take(); |
| 135 | + do sched.deschedule_running_task_and_then |_, task| { |
| 136 | + closing_task = Some(task); |
| 137 | + unsafe { uvll::uv_close(self.handle, close_cb) } |
150 | 138 | }
|
151 | 139 |
|
152 | 140 | extern fn close_cb(handle: *uvll::uv_handle_t) {
|
153 | 141 | let data: *c_void = unsafe { uvll::get_data_for_uv_handle(handle) };
|
154 | 142 | unsafe { uvll::free_handle(handle) }
|
155 |
| - if data.is_null() { return } |
156 | 143 |
|
157 | 144 | let closing_task: &mut Option<BlockedTask> = unsafe {
|
158 | 145 | cast::transmute(data)
|
|
0 commit comments