From mboxrd@z Thu Jan 1 00:00:00 1970 From: Petr Malat Date: Thu, 12 Jul 2018 10:27:54 +0000 Subject: Re: [PATCH net] sctp: Free connecting association if there is a pending signal Message-Id: <20180712102733.i7p6sigw7yqojrq3@ntb.petris.klfree.czf> List-Id: References: <20180709101142.GA1820@bordel.klfree.net> In-Reply-To: <20180709101142.GA1820@bordel.klfree.net> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: linux-sctp@vger.kernel.org On Wed, Jul 11, 2018 at 07:43:39PM -0400, Neil Horman wrote: > > > > $ ./a.out | ts "%H:%M:%S" # Empty lines added for readability > > > > 10:45:46 Testing IPPROTO_SCTP on a blocking socket > > > > 10:45:49 1st connect - rtn: -1 errno: 114 (Operation already in progress) > > > > 10:45:49 2nd connect - rtn: -1 errno: 114 (Operation already in progress) > > > > 10:45:49 Testing IPPROTO_TCP on a blocking socket > > > > 10:46:52 1st connect - rtn: -1 errno: 110 (Connection timed out) > > > > 10:47:55 2nd connect - rtn: -1 errno: 110 (Connection timed out) > > > > > > > This is the origional case, and I agree that it seems like SCTP is acting as a > > > non-blocking socket here (I presume it returns EINPROGRESS immediately, rather > > > than after some timeout value)? > > It returns after a signal is handled - in my test the signal is > > generated by alarm, but it doesn't matter what is the source of > > the signal. > > The blocking socket can be easilly identified by the return value > > from sock_intr_errno, which is ERESTARTSYS for a blocking operation > > and EINTR for a non-blocking one. > > I can change my patch to free the association only if ERESTARTSYS > > is returned. What do you think about it? > No, I don't think we should be freeing the association without taking direction > from user space here, as I noted before. How else it could be fixed then? I think freeing the association is the only possible option on blocking sockets, as applications using blocking sockets do not expect the connection attempt to continue on the background. Theoretically, it could be optimized to free the association only if SA_RESTART is not enabled on that socket and try to pick it and restore waiting in the other case. Petr