Fixed issue:key based auth ocassionally fails (https://github.com/PowerShell/Win32-OpenSSH/issues/481)

This commit is contained in:
Manoj Ampalam 2017-01-18 22:09:47 -08:00 committed by GitHub
parent 282e45472a
commit ceed50e8b1
1 changed files with 11 additions and 3 deletions

View File

@ -108,10 +108,18 @@ ssh_get_authentication_socket(int *fdp)
RegCloseKey(agent_root);
}
do {
h = CreateFileW(SSH_AGENT_PIPE_NAME, GENERIC_READ | GENERIC_WRITE, 0,
NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL);
if (h == INVALID_HANDLE_VALUE)
if (h != INVALID_HANDLE_VALUE || GetLastError() != ERROR_PIPE_BUSY)
break;
Sleep(100);
} while(1);
if (h == INVALID_HANDLE_VALUE) {
debug("ssh_get_authentication_socket - CreateFileW failed error %d", GetLastError());
return SSH_ERR_AGENT_NOT_PRESENT;
}
/*
* ensure that connected server pid matches published pid. this provides service side