From: Daniel Stenberg <[email protected]>
On Fri, 16 Mar 2012, Elli? Computing Open Source Program wrote:
lib/url.c:ConnectionExists() is the function that checks if a new
request
can re-use an existing connection.
I have a problem, when I try to access check->data members it seems that
I
get default values, and not those provided when the original SFTP request
happened. Am I right?
No, you're not. The connectdata struct is associated with a physical
connection. Each such connectdata is either independent (like when put in
the
connection pool within a multi handle) or associated with a SessionHandle
(->data points to that). There is never any SessionHandle struct kept
around
with just default values.
OK, I understand my scenario better now, here is what happens:
- start a connection to a "site" 1 (some kind of "server+auth info"
structure)
- finish the job, and keep the CURL* easy handle in a list for reuse, reset
it
- start a connection to a site 2 very similar to previous one, only auth
info changes
- ConnectionExists reuses connection to site 1, because server + user/pwd
match (but not AUTH_TYPES)
should I use another SessionHandle / "data"?
You compare connections, that means fields of two connectdata structs. The
SessionHandle is basically where values are copied from to the connectdata
struct at the time that struct is allocated and most likely the connections
you compare point to the same SessionHandle struct.
I understand now why I cannot use check->data member as it can be modified
by the user, and the reason why it was all defaults was because of my own
code.
Part of the authentication information is indeed provided inside
"data->set"
with the combination of being "statefully authenticated" on the contrary
to
most other protocols.
If that is true that it is a bug. The values in 'data->set' are what was
set
by the user with setopt() and they must remain like that. If libcurl needs
to
update anything, that anything needs to be somewhere else. If a connection
needs to remember any value from data->set, then that data needs to be
stored
in the connectdata struct so that you can compare..
for connection reuse of SFTP/SCP we need to copy during connection the
authentication
related options, else we cannot know if those options changed since last
request.
It includes almost all CURLSSH_OPT_?? excluding the KEYFUNCTION/KEYDATA.
where should I copy them? inside ssh_conn structure?
may other protocols be touched by that remark? (i.e. stateful authentication
=> authentication info copied in connectdata)
Regards
Armel
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html