[axel-devel] [axel-Bugs][311469] May have starvation thread

axel-bugs at alioth.debian.org axel-bugs at alioth.debian.org
Mon Feb 16 11:36:51 UTC 2009


Bugs item #311469, was opened at 2009-02-16 11:36
Status: Open
Priority: 3
Submitted By: Yao Shi (shiyao-guest)
Assigned to: Nobody (None)
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.

----------------------------------------------------------------------

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