From owner-freebsd-hackers Fri Oct 6 10:52:18 2000 Delivered-To: freebsd-hackers@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 706) id 9212837B502; Fri, 6 Oct 2000 10:52:16 -0700 (PDT) Date: Fri, 6 Oct 2000 10:52:16 -0700 From: Jonathan Lemon To: Marc Tardif Cc: freebsd-hackers@freebsd.org Subject: Re: aio_read timeout per request Message-ID: <20001006105216.C18697@hub.freebsd.org> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.95.4i In-Reply-To: ; from Marc Tardif on Fri, Oct 06, 2000 at 01:46:26PM -0400 Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Fri, Oct 06, 2000 at 01:46:26PM -0400, Marc Tardif wrote: > If I initiate multiple aio_read requests on sockets, how can > I set a timeout for each request? If I call aio_waitcomplete, > that sets a timeout for all. So, if I have 5 aio_reads, I > would call aio_waitcomplete as many times in a loop waiting > to process the first finished request. Problem with this > approach is that I can end up waiting a maximum of 5*timeout > for the last request to finish because aio_waitcomplete is > called again with the same timeout each time. I could imagine > a way this can be solved by keeping a timer and calling > aio_waitcomplete with the time remaining and then, when the > timer expires, call aio_return. But is there a simpler way? > Is there sample code or documentation I should read on the > subject? I think there's a bit of confusion here. The timeout value to aiowaitcomplete is similar to that of poll; basically you are telling the system how long you are willing to stall until any request comes ready. The value is not indicative of a maximum timeout on the I/O request; there is none. If you want to have a time limit on each request, you will need to implement your own timer mechanism, and call aio_cancel() to terminate those which haevn't completed. -- Jonathan To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message