Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 27 Mar 2001 19:46:17 -0800
From:      Brian Matthews <blm@actzero.com>
To:        FreeBSD Questions <freebsd-questions@FreeBSD.ORG>
Subject:   Threads vs. blocking sockets (was FreeBSD 4.x localhost socket pr oblem with big writes)
Message-ID:  <F0D64494733BD411BB9A00D0B74A0264021C97@cpe-24-221-167-196.ca.sprintbbd.net>

next in thread | raw e-mail | index | archive | help
I was encountering some problems using sockets on FreeBSD. After some
exploration I've found that threading doesn't seem (at least in my opinion)
to handle blocking sockets correctly. Specifically, calls to send (and
presumably recv, although I'm only doing recvs on nonblocking sockets) on a
blocking socket may return having only transferred part of the data.

As the standard FreeBSD threads are user space, they obviously can't let the
socket call really block, so all sockets are created as nonblocking.
However, I would then expect the threaded versions of the data transfer
calls (send*, etc.) to loop over the actual system calls. They actually do
so to catch EWOULDBLOCK/EAGAIN (see
/usr/src/lib/libc_r/uthread/uthreads_sendto.c for example), but don't to
make sure all the requested data is transferred. This seems to me like a bug
(and only half the reason you want blocking sockets is handled.)

Thoughts, comments?

Brian

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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?F0D64494733BD411BB9A00D0B74A0264021C97>