Welcome! Log In Create A New Profile

Advanced

Re: Implementing a non-blocking delay between request and response

January 15, 2010 09:43AM
Hi folks, thanks for your responses! As a quick note, I've been using ngxin 0.7.64

Marcus Clyne wrote:
>As a side-note here, this should have included returning a failure - you
>would have got a segfault on failure otherwise

For sure, I'm just experimenting for now, not too much error handling.

>You should use ngx_add_event () here instead of allocating the space for
>the event struct directly.

I spent some time looking at ngx_event.h, but can't figure out the semantics of that call. It doesn't look like it actually allocates space for the event that I can tell, so I still have to pcalloc. Even then, I tried ngx_add_event(wakeupFromSleep, NGX_ONESHOT_EVENT, 0) (and READ, WRITE events), but it still just seg faults.

>If you do nothing else here, then your request will return immediately.
>(Check out the code in ngx_http_finalize_request() to understand why.)
Adding

>r->count++;

>is one way that should prevent it from returning the first time.

Since I'm using 0.7.64 (sorry for not mentioning that sooner), my ngx_http_request doesn't have a count element. Is there something similar to prevent return in 0.7.64?

Also, I know ngx_http_finalize_request() never even gets called after I add the timer and the request returns. So I don't see how it could be causing it to return immediately.

>You should add a ngx_del_event() too here.

Yep, but I have to figure out how to use add event first.

>By the way, this question is probably better asked in the nginx-devel
>mailing list rather than the main one.

Sorry, it can be tricky to figure out where something should go, and I don't have the mailing list set up.
Thanks for the CC agentzh.

agentzh wrote:

>Heh, it reminds me of the echo_sleep and echo_blocking_sleep
>directives in the ngx_echo module:

I took a look at that module, and it does seem somewhat similar, except I want the sleep to be specifiable from the code, not the configuration file. I'm not sure what's being done differently to implement it that I'm not doing.

Thanks again.
Subject Author Posted

Implementing a non-blocking delay between request and response

Tronman January 14, 2010 02:26PM

Re: Implementing a non-blocking delay between request and response

Marcus Clyne January 14, 2010 08:02PM

Re: Implementing a non-blocking delay between request and response

agentzh January 14, 2010 08:52PM

Re: Implementing a non-blocking delay between request and response

agentzh January 14, 2010 09:38PM

Re: Implementing a non-blocking delay between request and response

Tronman January 15, 2010 09:43AM

Re: Implementing a non-blocking delay between request and response

Tronman January 15, 2010 10:02AM

Re: Implementing a non-blocking delay between request and response

Tronman January 15, 2010 12:28PM

Re: Implementing a non-blocking delay between request and response

Tronman January 15, 2010 01:25PM

Re: Implementing a non-blocking delay between request and response

Tronman January 15, 2010 02:11PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 65
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready