Skip to content

Commit a538120

Browse files
committed
refactor!: remove macros for initializing empty ngx_*_variable_t
There are no nginx core APIs that take a list of variables, terminated by an empty entry. The variables are always added from the module code, where we should use Rust iterators.
1 parent 404b63e commit a538120

File tree

2 files changed

+2
-44
lines changed

2 files changed

+2
-44
lines changed

examples/httporigdst.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use ngx::ffi::{
88
sockaddr, sockaddr_storage, INET_ADDRSTRLEN, NGX_HTTP_MODULE,
99
};
1010
use ngx::http::{self, HTTPModule};
11-
use ngx::{http_variable_get, ngx_http_null_variable, ngx_log_debug_http, ngx_null_string, ngx_string};
11+
use ngx::{http_variable_get, ngx_log_debug_http, ngx_null_string, ngx_string};
1212

1313
const IPV4_STRLEN: usize = INET_ADDRSTRLEN as usize;
1414

@@ -102,7 +102,7 @@ pub static mut ngx_http_orig_dst_module: ngx_module_t = ngx_module_t {
102102
..ngx_module_t::default()
103103
};
104104

105-
static mut NGX_HTTP_ORIG_DST_VARS: [ngx_http_variable_t; 3] = [
105+
static mut NGX_HTTP_ORIG_DST_VARS: [ngx_http_variable_t; 2] = [
106106
// ngx_str_t name
107107
// ngx_http_set_variable_pt set_handler
108108
// ngx_http_get_variable_pt get_handler
@@ -125,7 +125,6 @@ static mut NGX_HTTP_ORIG_DST_VARS: [ngx_http_variable_t; 3] = [
125125
flags: 0,
126126
index: 0,
127127
},
128-
ngx_http_null_variable!(),
129128
];
130129

131130
unsafe fn ngx_get_origdst(request: &mut http::Request) -> Result<(String, in_port_t), core::Status> {
@@ -276,9 +275,6 @@ impl HTTPModule for Module {
276275
// static ngx_int_t ngx_http_orig_dst_add_variables(ngx_conf_t *cf)
277276
unsafe extern "C" fn preconfiguration(cf: *mut ngx_conf_t) -> ngx_int_t {
278277
for mut v in NGX_HTTP_ORIG_DST_VARS {
279-
if v.name.len == 0 {
280-
break;
281-
}
282278
let var = ngx_http_add_variable(cf, &mut v.name, v.flags);
283279
if var.is_null() {
284280
return core::Status::NGX_ERROR.into();

src/core/mod.rs

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -26,41 +26,3 @@ macro_rules! ngx_null_command {
2626
}
2727
};
2828
}
29-
30-
/// Static empty configuration variable initializer for [`ngx_http_variable_t`].
31-
///
32-
/// This is typically used to terminate an array of HTTP variable types.
33-
///
34-
/// [`ngx_http_variable_t`]: https://nginx.org/en/docs/dev/development_guide.html#http_variables
35-
#[macro_export]
36-
macro_rules! ngx_http_null_variable {
37-
() => {
38-
$crate::ffi::ngx_http_variable_t {
39-
name: $crate::ngx_null_string!(),
40-
set_handler: None,
41-
get_handler: None,
42-
data: 0,
43-
flags: 0,
44-
index: 0,
45-
}
46-
};
47-
}
48-
49-
/// Static empty configuration variable initializer for [`ngx_stream_variable_t`].
50-
///
51-
/// This is typically used to terminate an array of Stream variable types.
52-
///
53-
/// [`ngx_stream_variable_t`]: https://github.com/nginx/nginx/blob/1a8ef991d92d22eb8aded7f49595dd31a639e8a4/src/stream/ngx_stream_variables.h#L21
54-
#[macro_export]
55-
macro_rules! ngx_stream_null_variable {
56-
() => {
57-
$crate::ffi::ngx_stream_variable_t {
58-
name: $crate::ngx_null_string!(),
59-
set_handler: None,
60-
get_handler: None,
61-
data: 0,
62-
flags: 0,
63-
index: 0,
64-
}
65-
};
66-
}

0 commit comments

Comments
 (0)