|
1 | 1 | use std::ffi::{c_char, c_void}; |
2 | | -use std::ptr::{addr_of, addr_of_mut}; |
| 2 | +use std::ptr::addr_of_mut; |
3 | 3 | use std::sync::atomic::{AtomicBool, AtomicPtr, Ordering}; |
4 | 4 | use std::sync::{Arc, OnceLock}; |
5 | 5 | use std::time::Instant; |
@@ -145,24 +145,22 @@ http_request_handler!(async_access_handler, |request: &mut http::Request| { |
145 | 145 | ngx_log_debug_http!(request, "async module enabled: {}", co.enable); |
146 | 146 |
|
147 | 147 | if !co.enable { |
148 | | - return core::Status::NGX_DECLINED; |
| 148 | + return core::Status::NGX_DECLINED.into(); |
149 | 149 | } |
150 | 150 |
|
151 | | - if let Some(ctx) = |
152 | | - unsafe { request.get_module_ctx::<RequestCTX>(&*addr_of!(ngx_http_async_module)) } |
153 | | - { |
| 151 | + if let Some(ctx) = request.get_module_ctx::<RequestCTX>(Module::module()) { |
154 | 152 | if !ctx.done.load(Ordering::Relaxed) { |
155 | | - return core::Status::NGX_AGAIN; |
| 153 | + return core::Status::NGX_AGAIN.into(); |
156 | 154 | } |
157 | 155 |
|
158 | | - return core::Status::NGX_OK; |
| 156 | + return core::Status::NGX_OK.into(); |
159 | 157 | } |
160 | 158 |
|
161 | | - let ctx = request.pool().allocate(RequestCTX::default()); |
| 159 | + let ctx = request.pool().alloc_with_cleanup(RequestCTX::default()); |
162 | 160 | if ctx.is_null() { |
163 | | - return core::Status::NGX_ERROR; |
| 161 | + return core::Status::NGX_ERROR.into(); |
164 | 162 | } |
165 | | - request.set_module_ctx(ctx.cast(), unsafe { &*addr_of!(ngx_http_async_module) }); |
| 163 | + request.set_module_ctx(ctx.cast(), Module::module()); |
166 | 164 |
|
167 | 165 | let ctx = unsafe { &mut *ctx }; |
168 | 166 | ctx.event.handler = Some(check_async_work_done); |
@@ -194,7 +192,7 @@ http_request_handler!(async_access_handler, |request: &mut http::Request| { |
194 | 192 | // and use the same trick as the thread pool) |
195 | 193 | })); |
196 | 194 |
|
197 | | - core::Status::NGX_AGAIN |
| 195 | + core::Status::NGX_AGAIN.into() |
198 | 196 | }); |
199 | 197 |
|
200 | 198 | extern "C" fn ngx_http_async_commands_set_enable( |
|
0 commit comments