[248] in Pthreads mailing list archive

home help back first fref pref prev next nref lref last post

Re: read() and close()

daemon@ATHENA.MIT.EDU (sean levy)
Tue Jan 30 20:18:49 1996

Date: Tue, 30 Jan 1996 19:44:25 -0500
From: sean levy <snl@PANEER.NDIM.EDRC.CMU.EDU>
To: "John H. Aughey" <jha@cs.purdue.edu>
Cc: pthreads@MIT.EDU

John H. Aughey wrote:
> 
> There's a bug (feature?) in the pthreads implementation which causes
> close() to block when there is a read() which is blocked already.

i can't find any language in draft10 about what is supposed to happen
in this case. perhaps someone who knows the standard better could comment?

> Here's some simple code:
[snip snip]

without looking at the code, i suspect that close is attempting to aquire
the same lock that read has to frob the bits in fd_table[]. i haven't
been poking my head around inside that code for a while now, though,
so don't count this as definitive. if that's the case, i'm not sure what
a real fix would look like.

> which worked under Solaris threads) was to close the file handle.  If
> closing the descriptor isn't possible, then how could I signal the
> blocking thread to indicate that I need it to do something else?

if it doesn't upset any other aspects of your program, you could try
using read_timedwait() so that your reader thread wakes up periodically
when there's nothing to read.

good luck,
				-- sean
-- 
sean levy, sr. research programmer, n-dim group, edrc, carnegie mellon univ.
<snl+@cmu.edu> | http://paneer.ndim.edrc.cmu.edu/Home/snl | +1 412 268 5215

home help back first fref pref prev next nref lref last post