Implicit Declaration of function?
Jason Price
japrice at gmail.com
Sun Dec 15 04:58:53 CET 2013
(I answered my initial question, but I have another below)
... Well, I obviously did SOMETHING dumb in the above code:
Dec 15 03:00:17 devvcache4x00 varnish_key[32132]: Child (32134) Panic
message: Assert error in http_GetHdr(), cache_http.c line 266:#012
*Condition(l
== strlen(hdr + 1)) not true.*#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()
<blah blah blah>
Found several of my problems (and hopefully will save others grief).
If you're using VRT_GetHdr, the third parameter stars with \0<octal length
of headername><your headername>
so my:
char *digestdate = VRT_GetHdr(sp, HDR_REQ, "\015x-digestdate:");
has to start with \015 since 'x-digestdate' is 13 characters, and 13 in
octal is 15.
Questions:
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)
2) seriously: WTF with _XOpenSource needing to be set to use strptime??
--Jason
On Sat, Dec 14, 2013 at 8:58 PM, Jason Price <japrice at gmail.com> wrote:
> warning: implicit declaration of function ‘strptime’
>
> I'm trying to do some basic Date parsing in Varnish. But I get this
> warning on compile.
>
> Here's the relevant bits of VCL:
>
> C{
> #include <time.h>
> #include <sys/time.h>
> #include <stdio.h>
> #include <stdlib.h>
> }C
>
> sub date_skew {
> C{
> time_t t = time(NULL);
> time_t digestepoch;
> struct tm tm;
> char *digestdate = VRT_GetHdr(sp, HDR_REQ,
> "\021x-digestdate:");
> if (!strptime(digestdate, "%a, %d %b %Y %H:%M:%S GMT",
> &tm)) {
> VRT_SetHdr(sp, HDR_REQ, "\010dateparsefail:",
> "1\0", vrt_magic_string_end);
> } else {
> digestepoch = mktime(&tm);
> if (abs(digestepoch - t) > 7200) {
> VRT_SetHdr(sp, HDR_REQ,
> "\010dateskewfail:", "1\0", vrt_magic_string_end);
> }
> }
> }C
> }
>
> Note: Later on, I'll call error if either of the two headers above are set.
>
> I've discovered that if I add:
>
> #define _XOPEN_SOURCE 500
>
> to the first C{ }C block, it passes muster. Any clue why? (may not be
> varnish related).
>
> Varnish related: will that impact anything else inside varnish?
>
> --Jason
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20131214/ae2ae4fc/attachment.html>
More information about the varnish-misc
mailing list