Skip to content

Commit f708d0d

Browse files
JyJyJcrdekobon
authored andcommitted
refactor: use addr_of_mut()! if possible
1 parent ba82864 commit f708d0d

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

examples/async.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ use ngx::ffi::{
77
use ngx::http::MergeConfigError;
88
use ngx::{core, core::Status, http, http::HTTPModule};
99
use ngx::{http_request_handler, ngx_log_debug_http, ngx_modules, ngx_null_command, ngx_string};
10-
use std::borrow::{Borrow, BorrowMut};
10+
use std::borrow::Borrow;
1111
use std::os::raw::{c_char, c_void};
12+
use std::ptr::addr_of_mut;
1213
use std::sync::atomic::AtomicBool;
1314
use std::sync::Arc;
1415
use std::time::Instant;
@@ -132,7 +133,7 @@ unsafe extern "C" fn check_async_work_done(event: *mut ngx_event_t) {
132133
// this doesn't have have good performance but works as a simple thread-safe example and doesn't causes
133134
// segfault. The best method that provides both thread-safety and performance requires
134135
// an nginx patch.
135-
post_event(event, ngx_posted_events.borrow_mut());
136+
post_event(event, addr_of_mut!(ngx_posted_events));
136137
}
137138
}
138139

@@ -204,7 +205,7 @@ http_request_handler!(async_access_handler, |request: &mut http::Request| {
204205
event.data = Arc::into_raw(event_data.clone()) as _;
205206
event.log = (*ngx_cycle).log;
206207

207-
post_event(event, ngx_posted_events.borrow_mut());
208+
post_event(event, addr_of_mut!(ngx_posted_events));
208209
}
209210

210211
ngx_log_debug_http!(request, "async module enabled: {}", co.enable);

0 commit comments

Comments
 (0)