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

Is errno handling correct for Windows?


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>
<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

Follow-Ups:
Re: Is errno handling correct for Windows?Eric Curtin <ericcurtin17@xxxxxxxxx>
Re: Is errno handling correct for Windows?Andreas Schneider <asn@xxxxxxxxxxxxxx>
Archive administrator: postmaster@lists.cynapses.org