varnish/libvmod-curl — pull request #14 by valdemon (2014-08-22 15:19:12+00:00)
Title: Asynchronous calls (without waiting for a response)

Hi,

here's the additional functionality for those who need to make calls to services like eg. a log service, without blocking the Varnish request/response flow by waiting for the cUrl response.
Example use:
```
curl.set_async(1);
curl.post("http://myhost/logservice", "MY_LOG_ENTRY_AS_BODY");
curl.free();
```
If the flag is not set explicitly per thread, then the normal synchronous call is performed, as the flag is reset to default (0) after calling the curl.free() (actually also by cm_init method).

The functionality has been tested succesfully with over 200 TPS on a tiny CentOS 6.5 VM box with the Varnish 4.0.1, behaving as stable as the synchronous calls, improving the overall service response time dramatically in my case.

Additionaly, as the 'vmod_curl_list' was growing logarithmically during reallocation in 'cm_get', I've modified that, first introducing the constant:
```
#define VMOD_CURL_LIST_SZ_INC 215
```
and changing the 'vmod_curl_list' size by this value, instead of doubling it each time:
```
static struct vmod_curl* cm_get(const struct vrt_ctx *ctx) {
...
while (vmod_curl_list_sz <= ctx->req->sp->fd) {
int ns = vmod_curl_list_sz + VMOD_CURL_LIST_SZ_INC;
...
```
Best,

Waldek