Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 9 Sep 1999 14:32:33 -0400
From:      "Kelly Yancey" <kbyanc@alcnet.com>
To:        <current@FreeBSD.ORG>
Cc:        <luigi@labinfo.iet.unipi.it>
Subject:   Re: An FS question perhaps... non blocking I/O.
Message-ID:  <000101befaf1$af3c9cc0$291c453f@kbyanc.alcnet.com>
In-Reply-To: <bulk.60595.19990909105948@hub.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
> Date: Thu, 9 Sep 1999 16:18:57 +0200 (MET DST)
> From: Luigi Rizzo <luigi@labinfo.iet.unipi.it>
> Subject: An FS question perhaps... non blocking I/O.
>
[ ... snip ... ]
>
> The app i have in mind is squid-like, which, if i understand
> well, is a
> single process looping around a select. If i get things
> right, select()
> on a file descriptor will return the read bit set if i am not at the
> end of file, yet the block might not be in memory yet even if the UFS
> seems to do readahead. Maybe i can turn NONBLOCK on for these
> descriptors, but still would have select returning essentially useless
> info as I'd need to try the read() to be sure...
>
[ ... snip ... ]

  Since you are talking about files, I presume when you say "select() on a
file descriptor will return the read bit set if I am not at the end of file"
you are implying the file descriptor is for a file, not a socket.
Admittingly, this has nothing to do with your question directly, but I
wanted to clarify something (if nothing else then for my sake):
	select() will not block on file descriptors referring to files. The logic
being that select is only supposed to wait until the operation can occur
without blocking (namely a read operation). But reads on files never block,
they just return a short count, hence select() always indicates success for
file descriptors for open files (and won't block on them).
	And, we mentioned the the last sentence, select() will always return
success for reading file descriptors for open files, EOF or not, since the
read would just return a short count.

  So again, it has nothing to do with the question of finding out whether
the data for the read in already in memory, but how can you tell if you are
already at EOF for a file using select(), as you describe. I was basing the
above statements off of various books I have read, and have never tried
select()ing a file's file descriptor for reading as I have always been told
it is pointless. If there is a way to do it, I would love to hear it (I have
a project that requires tail -f like functionality and I would much prefer
to use select() than just checking the file size every so often like tail
does).

  Thanks,

  Kelly
 ~kbyanc@posi.net~
  FreeBSD - The Power To Serve - http://www.freebsd.org/
  Join Team FreeBSD - http://www.posi.net/freebsd/Team-FreeBSD/

 "The ultimate result of shielding men from the effects of
  folly is to fill the world with fools." - Herbert Spencer




To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?000101befaf1$af3c9cc0$291c453f>