Skip to content

Add Event timers and supporting utilities (+ lint and fmt) #31

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
implement post_to_queue
Signed-off-by: Ava Hahn <a.hahn@f5.com>
  • Loading branch information
avahahn authored and Matthew Yacobucci committed Jun 16, 2023
commit ff337b9287719a6a359b988158c0bba1dc712830
14 changes: 14 additions & 0 deletions src/core/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,20 @@ impl Event {
self.0.set_timer_set(0);
}

/// translated from ngx_post_event macro
pub fn post_to_queue(&mut self, queue: *mut ngx_queue_t) {
if self.0.posted() == 0{
self.0.set_posted(1);
unsafe {
// translated from ngx_queue_insert_tail macro
self.0.queue.prev = (*queue).prev;
(*self.0.queue.prev).next = &self.0.queue as *const _ as *mut _;
self.0.queue.next = queue;
(*queue).prev = &self.0.queue as *const _ as *mut _;
}
}
}

pub unsafe fn new_for_request(req: &crate::http::Request) -> &mut Event {
&mut *(req.pool().alloc(std::mem::size_of::<ngx_event_t>()) as *mut Event)
}
Expand Down