[axel-devel] [axel-Bugs][311469] May have starvation thread
axel-bugs at alioth.debian.org
axel-bugs at alioth.debian.org
Mon Feb 23 19:44:07 UTC 2009
Bugs item #311469, was opened at 2009-02-16 11:36
>Status: Closed
Priority: 3
Submitted By: Yao Shi (shiyao-guest)
>Assigned to: Philipp Hagemeister (phihag-guest)
Summary: May have starvation thread
Initial Comment:
I found that conn.state is always set to 1 after invoking pthread_create for setup_thread. Then conn.state is set back to 0 in the end of setup_thread. The codes are following in axel.c
(1)
if( pthread_create( axel->conn[i].setup_thread, NULL, setup_thread, &axel->conn[i] ) != 0 )
{
axel_message( axel, _("pthread error!!!") );
axel->ready = -1;
}
else
{
axel->conn[i].last_transfer = gettime();
axel->conn[i].state = 1;
}
(2)
if( pthread_create( axel->conn[i].setup_thread, NULL, setup_thread, &axel->conn[i] ) == 0 )
{
axel->conn[i].state = 1;
axel->conn[i].last_transfer = gettime();
}
else
{
axel_message( axel, _("pthread error!!!") );
axel->ready = -1;
}
I think the programmer's intention is that conn.state=1 is executed just after thread creation and this statement must run before conn.state=0 in setup_thread.
However, the order between conn.state=1 and conn.state=0 is unfixed. If the connection is very fast and the local system is slower because of OS scheduling, conn.state=1 may happen after conn.state=0.
If conn.state=1 runs after conn.state=0 and the connection is broken, the connection is hung up and cannot be reused until timeout (20 sec. by default). I think that is really a performance issue.
----------------------------------------------------------------------
>Comment By: Philipp Hagemeister (phihag-guest)
Date: 2009-02-23 19:44
Message:
Sorry for answering that late. I'm currently busy and trying to focus on another project, and I assume this is the case for Giridhar, too. Anyway, you are dead right. Thanks for reporting this bug!
Fixed in rev94 in trunk. Because the problem is not that serious, we'll incorporate it in the next maintenance release, 2.4.
----------------------------------------------------------------------
Comment By: Yao Shi (shiyao-guest)
Date: 2009-02-16 11:40
Message:
I think this problem is easy to solve. The solution is that conn.state=1 can be put at the beginning of setup_thread or before pthread_create.
----------------------------------------------------------------------
You can respond by visiting:
http://alioth.debian.org/tracker/?func=detail&atid=413085&aid=311469&group_id=100070
More information about the axel-devel
mailing list