NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: kern/43199: read(2) returns bad size in multithreaded programs



On Apr 23, 2010, at 7:55 AM, Wolfgang.Stukenbrock%nagler-company.com@localhost 
wrote:

>       The problem seem to happen if multiple threads are reading from the 
> same fd at the
>       same time. This does not make much sence of cause, but if an 
> application decides
>       to such a thing, the kernel may not run wild.

That all depends on that sort of file descriptor it is and how you read from 
it.  If it is a regular file, the behavior is non-deterministic unless you use 
pread(2).  If it is a socket, correct behavior requires exclusive access to the 
socket for the duration of the read(2) call.

However, I do agree that it should not return a value larger than the requested 
size.

-- thorpej



Home | Main Index | Thread Index | Old Index