File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -163,6 +163,26 @@ pub fn ngx_random() -> core::ffi::c_long {
163
163
}
164
164
}
165
165
166
+ /// Returns cached timestamp in seconds, updated at the start of the event loop iteration.
167
+ ///
168
+ /// Can be stale when accessing from threads, see [ngx_time_update].
169
+ #[ inline]
170
+ pub fn ngx_time ( ) -> time_t {
171
+ // SAFETY: ngx_cached_time is initialized before any module code can run
172
+ unsafe { ( * ngx_cached_time) . sec }
173
+ }
174
+
175
+ /// Returns cached time, updated at the start of the event loop iteration.
176
+ ///
177
+ /// Can be stale when accessing from threads, see [ngx_time_update].
178
+ /// A cached reference to the ngx_timeofday() result is guaranteed to remain unmodified for the next
179
+ /// NGX_TIME_SLOTS seconds.
180
+ #[ inline]
181
+ pub fn ngx_timeofday ( ) -> & ' static ngx_time_t {
182
+ // SAFETY: ngx_cached_time is initialized before any module code can run
183
+ unsafe { & * ngx_cached_time }
184
+ }
185
+
166
186
/// Add a key-value pair to an nginx table entry (`ngx_table_elt_t`) in the given nginx memory pool.
167
187
///
168
188
/// # Arguments
You can’t perform that action at this time.
0 commit comments