From owner-freebsd-threads@FreeBSD.ORG Fri Mar 31 20:54:54 2006 Return-Path: X-Original-To: freebsd-threads@freebsd.org Delivered-To: freebsd-threads@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 8A98B16A400 for ; Fri, 31 Mar 2006 20:54:54 +0000 (UTC) (envelope-from s_sourceforge@nedprod.com) Received: from aramis.st-andrews.ac.uk (aramis.st-and.ac.uk [138.251.66.7]) by mx1.FreeBSD.org (Postfix) with ESMTP id D52EB43D48 for ; Fri, 31 Mar 2006 20:54:53 +0000 (GMT) (envelope-from s_sourceforge@nedprod.com) Received: from [169.254.226.23] (albatross-15 [138.251.96.15]) by aramis.st-andrews.ac.uk (8.12.9/8.12.9) with SMTP id k2VKsVSW025032 for ; Fri, 31 Mar 2006 21:54:32 +0100 (BST) From: "Niall Douglas" To: freebsd-threads@freebsd.org Date: Fri, 31 Mar 2006 21:54:26 +0100 MIME-Version: 1.0 Message-ID: <442DA512.7000.1E3815@s_sourceforge.nedprod.com> Priority: normal In-reply-to: References: <442D9E8C.7186.4BAD0@s_sourceforge.nedprod.com> X-mailer: Pegasus Mail for Windows (4.31) Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Content-description: Mail message body X-StAndrews-MailScanner-Information: Please contact the ISP for more information X-StAndrews-MailScanner: No virus detected X-StAndrews-MailScanner-SpamCheck: not spam, SpamAssassin (score=-4.9, required 5, autolearn=not spam, BAYES_00 -4.90) X-StAndrews-MailScanner-From: s_sourceforge@nedprod.com Subject: Re: recvfrom() not a thread cancellation point X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 31 Mar 2006 20:54:54 -0000 On 31 Mar 2006 at 15:40, Daniel Eischen wrote: > > How do I receive UDP packets using recvfrom() when it would seem that > > recvfrom() is not a thread cancellation point on FreeBSD 6.0? > > 1) select() or poll() instead, then recvfrom(). UDP packets > are never partial IIRC. Ah, that's a good idea. > 2) Unmask a signal in the thread doing the recvfrom(), then > use pthread_kill() to interrupt it (don't use SA_RESTART > for sa_flags in the signal action). Not practical unfortunately as who knows how many threads are concurrently doing recvfrom()'s. Thanks for the hint. I hadn't thought of using poll. Cheers, Niall