I'm trying to write module for nginx. My module needs to hold some arbitrary data while connection is alive (keep-alive connection). The memory for void *ctx is allocated from r->commection->pool. The problem is that I don't know where to store this pointer. I added void *ctx to struct ngx_connection_s and use it like this:
ctx = ngx_pcalloc(r->connection->pool, ... r->connection->ctx = ctx;
and everything works as I needed, but I tnink that this solution may be wrong.