[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Is errno handling correct for Windows?


Never mind, I see you are using libssh on Windows. In my case libssh was on
Linux.

On Wed 2 May 2018, 21:01 Eric Curtin, <ericcurtin17@xxxxxxxxx> wrote:

> Recently I had quite a bit of trouble with libssh as the client and
> freesshd as the server. I was tunneling RDC through that. But it worked
> fine with cygwin openssh 7.7 as the server in place of freesshd for me at
> least 😊
>
> Putty also had this issue with freesshd and RDC.
>
> On Wed 2 May 2018, 20:53 Jan Krause, <voltamund@xxxxxxxxx> wrote:
>
>> Hello
>>
>> Is libssh really supported on Windows (without using cygwin or MinGW)?
>> From the cmake files and the source code it looks like Windows is a
>> supported Platform. I could build recent sources from master for Windows 7
>> and Windows CE 6. For Windows CE 6 there was a bit of additional work
>> required. With both versions I could successfully run the sftp example.
>>
>> But when I look at the source code in libssh I am not sure if the errno
>> handling is correctly done for Windows.
>>
>> For example in ssh_connect_host_nonblocking there is:
>>     errno = 0;
>>     rc = connect(s, itr->ai_addr, itr->ai_addrlen);
>>     if (rc == -1 && (errno != 0) && (errno != EINPROGRESS)) {
>>       ssh_set_error(session, SSH_FATAL,
>>           "Failed to connect: %s", strerror(errno));
>>       ssh_connect_socket_close(s);
>>       s = -1;
>>       continue;
>>     }
>>
>> The if condition will never be true on Windows, even if connect returns
>> -1 and WSAGetLastError would return something different from WSAEWOULDBLOCK.
>> Is it supposed to work like this?
>>
>> or in bsd_poll
>>     #ifdef _WIN32
>>             if ((ret == -1) &&
>>                 (errno == WSAESHUTDOWN || errno == WSAECONNRESET ||
>>                  errno == WSAECONNABORTED || errno == WSAENETRESET)) {
>>     #else
>>
>>
>> The Windows Sockets API does not set errno.
>>
>> https://msdn.microsoft.com/en-us/library/windows/desktop/ms737828(v=vs.85).aspx
>>
>>
>> Other code uses WSAGetLastError (socket.c) as I would expect.
>>
>>
>>
>> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail> Virus-free.
>> www.avast.com
>> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
>> <#m_-1968731077989095417_m_3949928534408164957_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>>
>

References:
Is errno handling correct for Windows?Jan Krause <voltamund@xxxxxxxxx>
Re: Is errno handling correct for Windows?Eric Curtin <ericcurtin17@xxxxxxxxx>
Archive administrator: postmaster@lists.cynapses.org