On Thu, 17 Jun 2010, Thomas Stover wrote:
2) Daniel mentions the busy loop problem needs to be addressed with
BLOCK_ADJUST(). Where is that macro defined?
See attachment for my suggested fix.
3) Thinking this through further down the line brings up a related
question for me. While in many cases the agent operations would be part of
a program's startup, and therefore blocking for them to complete might be
acceptable, what if it was not - say in a gui program without bringing
threads into the picture. If I had an event loop style program where I
check for input on sockets and then call libssh2_* and other functions in
response to stimulus, could the same be done with the agent socket? ie do
my own poll on agent->fd and on session->socket_fd, then call
libssh2_agent_userauth() until either error or success somehow?
Yes, you should be able to do exactly that.
--
/ daniel.haxx.se
diff --git a/src/agent.c b/src/agent.c
index d96ca0a..6ff0975 100644
--- a/src/agent.c
+++ b/src/agent.c
@@ -48,6 +48,7 @@
#undef PF_UNIX
#endif
#include "userauth.h"
+#include "session.h"
/* Requests from client to agent for protocol 1 key operations */
#define SSH_AGENTC_REQUEST_RSA_IDENTITIES 1
@@ -743,17 +744,21 @@ libssh2_agent_userauth(LIBSSH2_AGENT *agent,
struct libssh2_agent_publickey *identity)
{
void *abstract = agent;
+ int rc;
if (agent->session->userauth_pblc_state == libssh2_NB_state_idle) {
memset(&agent->transctx, 0, sizeof agent->transctx);
agent->identity = identity->node;
}
- return _libssh2_userauth_publickey(agent->session, username,
- strlen(username),
- identity->blob,
- identity->blob_len,
- agent_sign,
- &abstract);
+
+ BLOCK_ADJUST(rc, agent->session,
+ _libssh2_userauth_publickey(agent->session, username,
+ strlen(username),
+ identity->blob,
+ identity->blob_len,
+ agent_sign,
+ &abstract));
+ return rc;
}
/*
_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel