<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<div tabindex="-1" class="XbIp4 jmmB7 GNqVo yxtKT allowTextSelection">
<div>
<div class="rps_e8fa">
<div dir="ltr"><span class="x_elementToProof ContentPasted0" style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">Hello All,</span></div>
<div dir="ltr">
<div class="x_elementToProof ContentPasted0" style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
I am currently implementing a response header filter that triggers one or more subrequests conditionally based on the status of the parent response.<br class="ContentPasted0">
<br class="ContentPasted0">
I want to introduce some delay between the checking of the response and the triggering of the subrequest, but I do not want to block the worker thread.<br class="ContentPasted0">
<br class="ContentPasted0">
So far I have allocated an event within the main request's pool, added a timer with my desired delay, and attached a callback that does two things.<br class="ContentPasted0">
</div>
<div class="x_elementToProof" style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<ol data-listchain="__List_Chain_79">
<li class="x_elementToProof"><span class="x_elementToProof ContentPasted0">triggers a subrequest as desired</span></li><li class="x_elementToProof"><span class="x_elementToProof ContentPasted0">proceeds to call the next response header filter</span></li></ol>
<div class="x_elementToProof ContentPasted0">In the meantime, after posting the event my handler returns NGX_OK.<br class="ContentPasted0">
<br class="ContentPasted0">
This is not working at all. Shortly after my filter returns NGX_OK the response is finalized, and the pool is deallocated. When the timer wakes up a segfault occurs in the worker process (in ngx_event_del_timer). Even if I allocate the event in a separate pool
that outlives the request it is still not defined what happens when I try to trigger a subrequest on a request that has been finalized.<br class="ContentPasted0">
<br class="ContentPasted0">
My question is how can I make the finalization of the request contingent on the associated/posted event being handled first?<br class="ContentPasted0">
<br class="ContentPasted0">
OR, is there another facility for implementing non blocking delay that I can use?<br class="ContentPasted0">
<br class="ContentPasted0">
Thanks,<br class="ContentPasted0">
Ava</div>
</div>
</div>
</div>
</div>
</div>
<br>
</div>
</body>
</html>