cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Weird cookie files (Daniel Stenberg)

From: MigueL DíaZ <tiomiguel_at_gmail.com>
Date: Fri, 11 Feb 2011 18:20:24 -0430

On Fri, 11 Feb 2011, MigueL D?aZ wrote:

Try "ls --full-time" to get the full timestamp of the files, and perhaps you
> can spot which run or action each file is associated with.
>
> No luck with this one, but it happens exactly when the apps start the
shutdown process.

> Otherwise I suggest you use strace or similar to track exactly when the
> files are created and then try to figure out during what phase in your code
> it is.
>
> This was a neat shot! With strace I can spot the call just when they are
happening:

open("0.43.channel.facebook.com:80", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE,
0666) = 15
fstat64(15, {st_mode=S_IFREG|0664, st_size=0, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
0xb7f3a000
write(15, "# Netscape HTTP Cookie File\n# ht"..., 857) = 857
close(15) = 0

This blocks are interleaved with simmilar ones with valid cookie files, so I
guess a corruption issue somewhere.

> My app setups an easy handle for each user with a COOKIEFILE and a
> > COOKIEJAR, and they are created correctly, I also add a share handle with
> > its own mutex.
>
> The cookiejar file is only written to disk when you call
> curl_easy_cleanup()
> on the handle...
>

This is a key point... The pointers I pass to CURLOPT_COOKIEJAR and
CURLOPT_COOKIEFILE must be available the entire lifespan of the curl
handler?

Documentation states:
-- start quote --

Strings passed to libcurl as 'char *' arguments, are copied by the library;
thus the string storage associated to the pointer argument may be
overwritten after curl_easy_setopt() returns. Exceptions to this rule are
described in the option details below.

Before version 7.17.0, strings were not copied. Instead the user was forced
keep them available until libcurl no longer needed them.
-- end quote --

So once I pass the string I shouldn't care anymore about it, right?

Ha! I hand't sent this when I decided to add a curl_version() call...

The Fedora installation compiles and links like this:
Using libcurl: libcurl/7.21.3 OpenSSL/0.9.8n zlib/1.2.3 libidn/1.16

The CentOS installation compiles and links like this:
Using libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5

So I guess this explains it all... Except why CentOS behaves that way when I
just installed a fresh 7.21.3 this morning... sigh...

Thanks Daniel!

-- 
"Think" is not a four-letter word.
        -- Anonymous

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2011-02-11