hello,<div><br></div><div> I am trying to use the PRIV_CALL capability of the vmods in order to cache an expensive operation used later in the vcl itself. I am running into an issue where a PRIV_CALL is being re-used for each request acting more like PRIV_VCL. Not sure if i am missing a "free" call somewhere but the below snippet reproduces the issue from my vmod. When hitting varnish with multiple different URLs the very first call logs "str is NULL" but every other request logs "str is VALID" so priv->priv never gets unset for future calls.</div>
<div><br></div><div>vcc file:</div><div><div>Init init_function</div><div>Function STRING get_str1(PRIV_CALL)</div><div>Function STRING get_str2(PRIV_CALL)</div></div><div><br></div><div>source file: </div><div><div>int init_function(struct vmod_priv *priv, const struct VCL_conf *conf)</div>
<div>{</div><div> </div><div>}</div><div><br></div><div>char * str_init(struct sess *sp, struct vmod_priv *priv) {</div><div><br></div><div> char * str ; </div><div><br></div><div> str = priv->priv; </div><div><br>
</div><div> if (str == NULL) { </div><div> syslog(LOG_INFO, "str is NULL, setting value\n"); </div><div> priv->priv = str = malloc(256);</div><div> priv->priv = strdup("MY VALUE"); </div>
<div> priv->free = free ; </div><div> }</div><div> else {</div><div> syslog(LOG_INFO, "str is VALID, returning value\n"); </div><div> return str; </div><div> }</div><div><br></div><div>}</div><div>
<br></div><div>const char * vmod_get_str1(struct sess *sp, struct vmod_priv *priv) { </div><div> return str_init(sp,priv); </div><div>}</div><div><br></div><div>const char * vmod_get_str2(struct sess *sp, struct vmod_priv *priv) { </div>
<div> return str_init(sp,priv); </div><div>}</div></div>