<div dir="ltr"><div><div><div><div><div><div><div><div><div>(I answered my initial question, but I have another below)<br><br>... Well, I obviously did SOMETHING dumb in the above code:<br><br>Dec 15 03:00:17 devvcache4x00 varnish_key[32132]: Child (32134) Panic message: Assert error in http_GetHdr(), cache_http.c line 266:#012  <b>Condition(l == strlen(hdr + 1)) not true.</b>#012thread = (cache-worker)#012ident = Linux,3.4.66-55.43.amzn1.x86_64,x86_64,-smalloc,-smalloc,-hcritbit,epoll#012Backtrace:#012  0x431095: /usr/sbin/varnishd() <br>
</div><blah blah blah><br><br></div>Found several of my problems (and hopefully will save others grief).<br><br></div>If you're using VRT_GetHdr, the third parameter stars with \0<octal length of headername><your headername><br>
<br></div>so my:<br><br>char *digestdate = VRT_GetHdr(sp, HDR_REQ, "\015x-digestdate:");<br><br></div>has to start with \015 since 'x-digestdate' is 13 characters, and 13 in octal is 15.<br><br></div>Questions:<br>
<br></div>1) Do I need to free any of my temp variables here?  Or does varnish clean them up for me?  (in my case t, digestepoch, digestdate, and tm)<br></div>2) seriously: WTF with _XOpenSource needing to be set to use strptime??<br>
<br></div>--Jason<br><div><div><div><div><div><div><div><div><div><span class=""></span><span class=""></span></div></div></div></div></div></div></div></div></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">
On Sat, Dec 14, 2013 at 8:58 PM, Jason Price <span dir="ltr"><<a href="mailto:japrice@gmail.com" target="_blank">japrice@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
warning: implicit declaration of function ‘strptime’<br>
<br>
I'm trying to do some basic Date parsing in Varnish.  But I get this<br>
warning on compile.<br>
<br>
Here's the relevant bits of VCL:<br>
<br>
C{<br>
#include <time.h><br>
#include <sys/time.h><br>
#include <stdio.h><br>
#include <stdlib.h><br>
}C<br>
<br>
sub date_skew {<br>
        C{<br>
                time_t t = time(NULL);<br>
                time_t digestepoch;<br>
                struct tm tm;<br>
                char *digestdate = VRT_GetHdr(sp, HDR_REQ, "\021x-digestdate:");<br>
                if (!strptime(digestdate, "%a, %d %b %Y %H:%M:%S GMT", &tm)) {<br>
                        VRT_SetHdr(sp, HDR_REQ, "\010dateparsefail:",<br>
"1\0", vrt_magic_string_end);<br>
                } else {<br>
                        digestepoch = mktime(&tm);<br>
                        if (abs(digestepoch - t) > 7200) {<br>
                                VRT_SetHdr(sp, HDR_REQ,<br>
"\010dateskewfail:", "1\0", vrt_magic_string_end);<br>
                        }<br>
                }<br>
        }C<br>
}<br>
<br>
Note: Later on, I'll call error if either of the two headers above are set.<br>
<br>
I've discovered that if I add:<br>
<br>
#define _XOPEN_SOURCE 500<br>
<br>
to the first C{ }C block, it passes muster.  Any clue why? (may not be<br>
varnish related).<br>
<br>
Varnish related: will that impact anything else inside varnish?<br>
<span class="HOEnZb"><font color="#888888"><br>
--Jason<br>
</font></span></blockquote></div><br></div>