Guys,
While I was brooding over the mysterious ssh-add/ssh-agent hang, I
suddenly came across these fairly old lines in fhandler_socket::accept():
if ((SOCKET) res == INVALID_SOCKET && WSAGetLastError () == WSAEWOULDBLOCK)
in_progress = true;
Then, in case of unix stream sockets, the secret event stuff and the
new eid credential transaction is called.
Fine...
Looks good...
Well...
Hang on...
Erm...
What the heck is an accept in progress?!? I mean, I understand a
non-blocking connect in progress which returns EWOULDBLOCK, but an
accept in progress? What would be returned in the sockaddr parameter
if the return code is -1? That doesn't make sense.
After months of asceticism I had another look into the SUSv3 and MSDN
man pages of accept
http://www.opengroup.org/onlinepubs/009695399/functions/accept.html
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winsock/winsock/accept_2.asp (*)
and it turns out that returning -1 and an error of (WSA)EWOULDBLOCK
indicate that a non-blocking accept has simply nothing to accept!
So there is nobody knocking on the door (==connecting), which means,
calling any secret event or eip credential transaction is rightout
wrong. Right?
I was going to apply the below patch. I can confirm that ssh and (sigh)
ssh-agent/ssh-add still work for me (all are using non-blocking sockets),
but somehow I need a bit of shoulder patting before doing this.
Does anybody have problems or can imagine problems with this patch?
It just removes all in_progress handling from unix stream sockets, so
that the secret event and eid credential transactions only take place if
actually a socket connection has been accepted.
Anybody?