From owner-freebsd-current@FreeBSD.ORG Wed Oct 3 23:20:00 2007 Return-Path: Delivered-To: current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7ED7416A419 for ; Wed, 3 Oct 2007 23:20:00 +0000 (UTC) (envelope-from rrs@cisco.com) Received: from sj-iport-6.cisco.com (sj-iport-6.cisco.com [171.71.176.117]) by mx1.freebsd.org (Postfix) with ESMTP id 353DD13C4B6 for ; Wed, 3 Oct 2007 23:20:00 +0000 (UTC) (envelope-from rrs@cisco.com) X-IronPort-AV: E=Sophos;i="4.21,226,1188802800"; d="scan'208";a="230023501" Received: from sj-dkim-1.cisco.com ([171.71.179.21]) by sj-iport-6.cisco.com with ESMTP; 03 Oct 2007 15:51:56 -0700 Received: from sj-core-5.cisco.com (sj-core-5.cisco.com [171.71.177.238]) by sj-dkim-1.cisco.com (8.12.11/8.12.11) with ESMTP id l93Mpuia021951; Wed, 3 Oct 2007 15:51:56 -0700 Received: from xbh-sjc-211.amer.cisco.com (xbh-sjc-211.cisco.com [171.70.151.144]) by sj-core-5.cisco.com (8.12.10/8.12.6) with ESMTP id l93MpuPG003255; Wed, 3 Oct 2007 22:51:56 GMT Received: from xfe-sjc-211.amer.cisco.com ([171.70.151.174]) by xbh-sjc-211.amer.cisco.com with Microsoft SMTPSVC(6.0.3790.1830); Wed, 3 Oct 2007 15:51:55 -0700 Received: from [128.107.159.252] ([128.107.159.252]) by xfe-sjc-211.amer.cisco.com with Microsoft SMTPSVC(6.0.3790.1830); Wed, 3 Oct 2007 15:51:55 -0700 Message-ID: <47041CE2.60603@cisco.com> Date: Wed, 03 Oct 2007 18:51:14 -0400 From: Randall Stewart User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.7.13) Gecko/20070601 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Martin Kulas References: <20071003141412.GA1311@thunderbird.tld> In-Reply-To: <20071003141412.GA1311@thunderbird.tld> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 03 Oct 2007 22:51:55.0369 (UTC) FILETIME=[FF11C590:01C8060F] DKIM-Signature: v=0.5; a=rsa-sha256; q=dns/txt; l=1650; t=1191451916; x=1192315916; c=relaxed/simple; s=sjdkim1004; h=Content-Type:From:Subject:Content-Transfer-Encoding:MIME-Version; d=cisco.com; i=rrs@cisco.com; z=From:=20Randall=20Stewart=20 |Subject:=20Re=3A=20[SCTP][patch]=20socket=20does=20not=20wake=20up |Sender:=20; bh=SFnKvwuGLEDHphaJcDe3ZtWmImPi1IlnH9R8/2sUs0Q=; b=oJPP0GFlVU7N81AKoIDYTQ9jP+XFs09ppXDpVO+nHgmkWOug63OF+fIfV8Srj99RG1mR7sut qDjv5nKbyayXz3Wx0w5aOvbynJ70r6t34w+Mbbyc19L+/jL2wZ7zRo6is7c8Bl7rCVZK1u9Y3O 1XnsRwMIdXoMkpnmgue7aIZy8=; Authentication-Results: sj-dkim-1; header.From=rrs@cisco.com; dkim=pass (sig from cisco.com/sjdkim1004 verified; ); Cc: current@freebsd.org Subject: Re: [SCTP][patch] socket does not wake up X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Oct 2007 23:20:00 -0000 Martin: Thanks for the patch.. note that I will submit it to re for approval after a minor fix. socantrcvmore(so); assumes you do NOT hold a lock. This code holds the socket lock.. which is the recv sockbuf lock.. So if you turn witness on your kernel and run with this you will have a double lock.. panic. Note to fix this right you should have it be: SOCK_UNLOCK(so); + socantrcvmore(so); Which is what I will submit to release ops.. you may want to change this in what you are working with so you don;t have some other side-effect issue from the double lock.. like leaking sockets. R Martin Kulas wrote: > Hello! > > I patched netcat to support 1to1-SCTP sockets. > Netcat uses the poll() system call to wait for new data > in the socket buffer. The problem is that poll() does not > return when the kernel has closed the SCTP association. > Select() has the same problem. > > I digged around in the SCTP sources and created a patched to remove > that bug. The patch is a one-liner: > > > --- sctp_pcb.c.orig 2007-10-03 13:27:12.000000000 +0200 > +++ sctp_pcb.c 2007-10-03 15:51:55.286987000 +0200 > @@ -4234,6 +4234,7 @@ > SS_ISCONFIRMING | > SS_ISCONNECTED); > } > + socantrcvmore(so); > SOCK_UNLOCK(so); > sctp_sowwakeup(inp, so); > sctp_sorwakeup(inp, so); > > > Now I have no problems with the system calls select()/poll() anymore. > Is this patch OK or have I missed anything? > > > Regards, > Martin > -- Randall Stewart NSSTG - Cisco Systems Inc. 803-345-0369 803-317-4952 (cell)