I don't know which thread model Varnish 3 use, however Varnish 4 create simultaneous thread for each request. Regarding this, when use md5_hash inside vcl_recv then race condition will happen inside md5_hash and incorrect MD5 will be returned.
In my code i solve this issue creating
char* hex_output = malloc(16*2 + 1);
and in vcl file
char* md5DigestString = VRT_GetHdr(ctx, &VGC_HDR_REQ_VARNISH_X_DIGEST);
const char* calculatedMD5 = (*md5_hash)(md5DigestString);
VRT_SetHdr(ctx, &VGC_HDR_REQ_VARNISH_X_MD5, calculatedMD5, vrt_magic_string_end);
free((void*)calculatedMD5);
I don't know which thread model Varnish 3 use, however Varnish 4 create simultaneous thread for each request. Regarding this, when use
md5_hashinsidevcl_recvthen race condition will happen insidemd5_hashand incorrect MD5 will be returned.In my code i solve this issue creating
and in vcl file