<div dir="ltr">Hi All.<div><br></div><div>I've created a function for adding my custom ngx_timer , but after 1st time loop my r->pool is setting to NULL , also it sets NULL my r->connection->log, and after second loop it throws exception on  <i>ngx_palloc </i>because my r->pool is NULL.</div><div>I can't find out why, here is my function</div><div><br></div><div><div><i>void add_aling_event(ngx_event_t *e, ngx_http_request_t *r, void (*handler), int timer)</i></div><div><i>{</i></div><div><i>    if(e)</i></div><div><i>    {</i></div><div><i>        ngx_add_timer(e, timer);</i></div><div><i>        return;</i></div><div><i>    }</i></div><div><i>    ngx_event_t *event=ngx_palloc(r->pool,sizeof(ngx_event_t));</i></div><div><i>    memset(event,0,sizeof(ngx_event_t));</i></div><div><i>    event->data=r;</i></div><div><i>    event->handler=handler;</i></div><div><i>    event->log=r->connection->log;</i></div><div><i>    ngx_add_timer(event, timer);</i></div><div><i>}</i></div></div><div><i><br></i></div><div>And I'm calling this function like this.</div><div><i><br></i></div><div><div style="font-style:italic">static ngx_int_t ngx_http_aling_handler(ngx_http_request_t *r)</div><div style="font-style:italic">{</div><div style="font-style:italic">    ........</div><div style="font-style:italic">    ........</div><div style="font-style:italic">    add_aling_event(NULL, r, hack_func, 50);</div><div style="font-style:italic">    return NGX_AGAIN;</div><div style="font-style:italic">}</div><div style="font-style:italic"><br></div><div style="font-style:italic"><div>void hack_func(ngx_event_t *e)</div><div>{</div><div>    ngx_http_request_t *r = e->data;</div><div>    ........</div><div>    ........</div><div>   </div><div>    switch(shmLen[1])</div><div>    {</div><div>        case 1: // adding chain</div><div>        {</div><div>            ..........................</div><div><i>            ..........................</i></div><div>        };break;</div><div>        case 2: // adding last chain</div><div>        {</div><div>            ..........................</div><div><i>            ..........................</i></div><div>        };break;</div><div>        default:</div><div>        {</div><div>            add_aling_event(e, r, hack_func, 50);</div><div>        };break;</div><div>    }</div><div>}</div></div><div style="font-style:italic"><br></div><div>After 1 or 2 calls r->pool is sets to NULL ..... </div></div><div><br></div><div>Please help me figure out this issue.</div><div>Maybe I'm doing something wrong.</div><div>I've did this code using example here <a href="https://github.com/tommywatson/nginx-hello-world-module/blob/master/ngx_http_hello_world_module.c#L104" target="_blank" style="font-size:12.8000001907349px">https://github.com/tommywatson/nginx-hello-world-module/blob/master/ngx_http_hello_world_module.c#L104</a> </div><div><br></div><div>Thanks.</div></div>