From owner-freebsd-net@FreeBSD.ORG Fri Oct 22 20:25:37 2004 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C054716A4CE for ; Fri, 22 Oct 2004 20:25:37 +0000 (GMT) Received: from park.rambler.ru (park.rambler.ru [81.19.64.101]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1168943D3F for ; Fri, 22 Oct 2004 20:25:37 +0000 (GMT) (envelope-from is@rambler-co.ru) Received: from is.park.rambler.ru (is.park.rambler.ru [81.19.64.102]) by park.rambler.ru (8.12.6/8.12.6) with ESMTP id i9MKPUis040528; Sat, 23 Oct 2004 00:25:30 +0400 (MSD) (envelope-from is@rambler-co.ru) Date: Sat, 23 Oct 2004 00:25:30 +0400 (MSD) From: Igor Sysoev X-X-Sender: is@is.park.rambler.ru To: "Ronald F. Guilmette" In-Reply-To: <93418.1098386003@monkeys.com> Message-ID: <20041023002300.I91215@is.park.rambler.ru> References: <93418.1098386003@monkeys.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII cc: freebsd-net@freebsd.org Subject: Re: aio_connect ? X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Oct 2004 20:25:37 -0000 On Thu, 21 Oct 2004, Ronald F. Guilmette wrote: > >I believe if you want to build a more maintainable, more adaptable, > >more modularized program then you should avoid two things - the threads and > >the signals. If you like to use a callback behaviour of the signals you could > >easy implement it without any signal. > > OK. I'll bite. How? I'm sure you know it. Sorry, English is not my native language so I may tell you only shortly. You can use two notification models. First is the socket readiness for operations, second is the operation completeness. In the first model you use usual read()/write() operations and learn readiness using select()/poll()/kevent(). In the second model you use aio_read()/aio_write() operations and learn about their completeness using aio_suspend()/aio_waitcomplete()/kevent(). After you have got the notifications you would call your callback handlers as well as the kernel would call your signal handlers. The difference between your code and kernel is that your code always calls handlers in the well known places that allows to avoid the various race conditions. The kernel may call the signal handler any time if the signal is not blocked. Igor Sysoev http://sysoev.ru/en/