busywaiting without blocking event loop OR timers

fin fin at xbhd.org
Fri Aug 26 11:40:09 UTC 2011


hello devel,

i'm working on a module that uses ngx_event_connect to connect to a
3rdparty service and parses its request.
the answer depends on the request hostname, so now i'm implementing a
cache in shared memory to cache the responses on a hostname basis.

i'm protecting access to every cache entry using a ngx_atomic_t.

now i'd like to prevent multiple concurrent connections from requests
to the same hostname to the 3rd party service.

i see two ways to solve that:
* busy-wait on ngx_atomic_t as long as a request to the service is open
* create an event and wait for it

now, how can i busy-wait on a ngx_atomic_t without blocking the
handling of other requests in the same process?
(these requests can last up to 10 seconds in worst-case)
-> can i yield to the event loop while busy-waiting?

can i create events independent of I/O, like timer events?

thanks in advance
-fin

PS:
our howto on doing what we're doing in our module:
http://blog.efficientcloud.com/2011/08/24/nginx-upstream/



More information about the nginx-devel mailing list