[Newbie] Need help with Inline C code.

Roberto Moutinho robertomoutinho at gmail.com
Mon Jul 25 15:36:18 CEST 2011

Ken Brownfield,

Using the command you mentioned (with the "-C" option on varnish
daemon) I was able to find my mistake.

I was initializing a variable with a "Varnish Run Time" value. Since
this value is only accessible when a request is made, varnishd was not
able to compile my code.

The wrong code:

*        char xqbkey[32] = VRT_GetHdr(sp, HDR_REQ, "\012X-API-Key:");*

And what I did after seeing my mistake:

*        char apikey[32];
        sprintf(apikey, VRT_GetHdr(sp, HDR_REQ, "\012X-API-Key:"))*

Thanks for the tip.

Best Regards

Roberto Moutinho

Actually, more useful would be the output of "varnishd -C -f
/path/to/your/VCL/file.vcl", in whole or primarily the area around line
602...  Not sure how to get away without actually looking at the cause of
the error.  If it just said "syntax error", Google wouldn't be too helpful
for that, either... :-/

On Fri, Jul 22, 2011 at 16:24, Roberto Moutinho
<robertomoutinho at gmail.com

>* My mistake... I've posted the wrong link.*>**>* this is the one I was referring to:*>**>* http://drcarter.info/2010/04/how-fighting-against-scraping-using-varnish-vcl-inline-c-memcached/*>**>**>**>* 2011/7/22  Ken Brownfield <kbrownfield at google.com <https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc>>*>* Hard to tell without seeing any code at all, and I "C" no code at that*>* link.*>* :)*>**>* OT: I think scaling 100 million requests a month is a... dubious*>* accomplishment -- 38 hits per second?  Really?*>* --*>* kb*>**>* 2011/7/22 Jonathan Hursey <jonathan.hursey at adrevolution.com <https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc>>*>**>>* wish I could help with this... if you get an answer please forward it this*>>* way. I'm super curious.*>>**>>**>>* On Fri, Jul 22, 2011 at 4:58 PM, Roberto Moutinho <*>>* robertomoutinho at gmail.com <https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc>> wrote:*>>**>>>* Hello to everyone,*>>>**>>>* I've extended the C code on the*>>>* http://blog.dansingerman.com/post/4604532761/how-to-block-rate-limited-traffic-with-varnishpage...*>>>* But I have different needs from the original post since I'm serving a*>>>* protected content all the time (Restfull API).*>>>**>>>* Basically I have to authenticate a api key (received within a special*>>>* header) on my database and store the key and theirs request limit value in*>>>* memached.*>>>**>>>* My main problem is that my C code works perfect when using gcc (ubuntu)*>>>* to compile it but it does not compile together with Varnish.*>>>**>>>* output from running varnishd*>>>* **>>>* storage_malloc: max size 256 MB.*>>>* Message from C-compiler:*>>>* ./vcl.1P9zoqAU.c: In function ‘API’:*>>>* ./vcl.1P9zoqAU.c:602: error: invalid initializer*>>>* Running C-compiler failed, exit 1*>>>* VCL compilation failed**>>>**>>>* Searching for this "invalid initializer" on Google have not helped me at*>>>* all :(*>>>**>>>* Best Regards*>>>* Roberto Moutinho*>>>**>>>* _______________________________________________*>>>* varnish-misc mailing list*>>>* varnish-misc at varnish-cache.org <https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc>*>>>* https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc*>>>**>>**>>**>**>* _______________________________________________*>* varnish-misc mailing list*>* varnish-misc at varnish-cache.org <https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc>*>* https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc*>**-------------- next part --------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20110725/335e0942/attachment-0003.html>

More information about the varnish-misc mailing list