Date: Fri, 17 May 2002 15:36:23 -0500 From: Dave Baukus <dbaukus@chiaro.com> To: freebsd-bugs@freebsd.org Subject: ptheread hang Message-ID: <3CE569C7.5010104@chiaro.com>
next in thread | raw e-mail | index | archive | help
[-- Attachment #1 --]
In bsd4.0 it is possible to hang a pthread indefinitely due to what I
think is an incorrect interpretation of EAGAIN from the connect() system
call. A TCP, and probably a UDP, connect() will return EAGAIN if
all the ephemeral ports are allocated.
EAGAIN is bubbled up from in_pcbbind() when the connecting socket
requires an implicit bind() and the specified ephemeral port range is
100% allocated.
When EAGAIN is returned to the pthread _connect() implementation it
puts the thread to sleep and waits for poll()/select() to indicate
that the connect is complete:
from bsd4.0/src/lib/libc_r/uthread/uthread_connect.c:
int
_connect(int fd, const struct sockaddr * name, socklen_t namelen)
{
struct sockaddr tmpname;
int errnolen, ret, tmpnamelen;
if ((ret = _FD_LOCK(fd, FD_RDWR, NULL)) == 0) {
if ((ret = _thread_sys_connect(fd, name, namelen)) < 0)
{
if (!(_thread_fd_table[fd]->flags & O_NONBLOCK)
&&
((errno == EWOULDBLOCK) || (errno == EINPROGRESS) ||
(errno == EALREADY) || (errno == EAGAIN)))
{
_thread_run->data.fd.fd = fd;
/* Set the timeout: */
_thread_kern_set_timeout(NULL);
_thread_kern_sched_state(PS_FDW_WAIT,
__FILE__,_LINE__);
...
...
...
The connect will never complete because it was never started; the
TCP never sent a SYN; it is in the closed state; it will remain like
this forever. EAGAIN is not the same as EINPROGRESS.
--
dave baukus@chiaro.com
Chiaro Networks
Richardson Texas
USA
[-- Attachment #2 --]
----------------------------------------- (on rchss001)
This e-mail and any files transmitted with it are the property
of Chiaro Networks, Ltd., and may contain confidential and
privileged material for the sole use of the intended recipient(s)
to whom this e-mail is addressed. If you are not one of the named
recipient(s), or otherwise have reason to believe that you have
received this message in error, please notify the sender and
delete all copies from your system. Any other use, retention,
dissemination, forwarding, printing or copying of this e-mail is
strictly prohibited.
---------------------------------------------------------
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3CE569C7.5010104>
