Subject: Re: bug#22789: 25.1.50; In last master build https connections stop working

From: Alain Schneble <[email-masked]>
Date: Sun, 28 Feb 2016 00:49:25 +0100

Alain Schneble <[email-masked]> writes:

> In w32.c (emacs_gnutls_push) I see that sys_write returns with 0.  But
> the buffer to write contains sz=255 bytes.  And here errno is 0 after
> the write.  This is strange.  I guess that here errno should be set to
> EAGAIN... I mean in sys_write...
>
> After this broken emacs_gnutls_push call, gnutls_handshake returns:
>
> -53 GNUTLS_E_PUSH_ERROR
> And later...
> -10 GNUTLS_E_INVALID_SESSION.

Here we go.  I think we are getting closer to the root cause of the
problem.  In w32.c (sys_write), it runs into the following error:

      if (nchars == SOCKET_ERROR)
        {
	  DebPrint (("sys_write.send failed with error %d on socket %ld\n",
		     pfn_WSAGetLastError (), SOCK_HANDLE (fd)));
	  set_errno ();
	}

Strange thing: set_errno returns with errno == 0.  This because
pfn_WSAGetLastError returns 0 as well.

Now, if I do...

	  if (errno == 0)
	    errno = EAGAIN;

...just after the call to set_errno above, guess what: It seems to work!

At least for me, it will be an exercise for tomorrow to find the reason
why pfn_WSAGetLastError returns 0 in this case.  *snore*

Do you agree it shouldn't return 0?