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

From: Eli Zaretskii <[email-masked]>
Date: Mon, 07 Mar 2016 18:07:54 +0200

> From: Alain Schneble <[email-masked]>
> CC: <[email-masked]>, <[email-masked]>, <[email-masked]>
> Date: Mon, 7 Mar 2016 00:24:35 +0100
> 
> > I'll send a patch for further discussions shortly.
> 
> And here it is.  The fix is quite simple.  It ensures that sys_write
> exits before touching the socket if it is not connected yet.
> Unfortunately I didn't find any documentation on winsock ioctlsocket
> that would prove that this is indeed required.  But it seems not wrong
> to me anyway.  (I'll try to search the wisock documentation tomorrow to
> find some hints that lead in this direction, or maybe you know?)

I think this change should be installed regardless, as it fixes an
oversight.  However, I think it needs to be augmented, because the
fact that FILE_CONNECT flag is set doesn't necessarily mean the
connection is in progress: it could have failed already.  We need to
look at the status as well.

The possible states of the FILE_CONNECT flag and the cp->status values
are:

  flag    status                      description
  ----------------------------------------------------------------------------
  ON      STATUS_READ_READY           reader thread is about to try connect
  ON      STATUS_READ_FAILED          reader thread waits in _sys_wait_connect
  ON      STATUS_READ_SUCCEEDED       reader thread successfully connected
  ON      STATUS_CONNECT_FAILED       reader thread failed to connect
  OFF     STATUS_READ_ACKNOWLEDGED    sys_select acknowledged successful connect
  OFF     STATUS_READ_READY           reader thread is about to read
  OFF     STATUS_READ_IN_PROGRESS     reader thread waits in _sys_read_ahead
  OFF     STATUS_READ_SUCCEEDED       reader thread succeeded in reading
  OFF     STATUS_READ_FAILED          reader thread failed to read

So we should only return EWOULDBLOCK when FILE_CONNECT is set _and_
the status is not STATUS_CONNECT_FAILED.  If FILE_CONNECT is set, but
the status is STATUS_CONNECT_FAILED, we should instead return the
value computed from cp->errcode (if it is non-zero).  There's an
example of that in sys_read.

Other than that, what specific problem does your change try or is
known to solve?  IOW, what didn't work before the change, and works
after it?

Thanks.