[peerdist] Start block download timers from within opener methods

Move the responsibility for starting the block download timers from
peerblk_expired() to peerblk_raw_open() and peerblk_retrieval_open(),
in preparation for adding the ability to defer calls to
peerblk_raw_open() via a block download queue.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
pull/94/head
Michael Brown 2019-08-16 21:23:55 +01:00
parent 6df2c6ab76
commit 02b26de963
1 changed files with 9 additions and 7 deletions

View File

@ -358,6 +358,10 @@ static int peerblk_raw_open ( struct peerdist_block *peerblk ) {
if ( inject_fault ( PEERBLK_ANNUL_RATE ) )
intf_restart ( &peerblk->raw, 0 );
/* Start download attempt timer */
peerblk->rc = -ETIMEDOUT;
start_timer_fixed ( &peerblk->timer, PEERBLK_RAW_OPEN_TIMEOUT );
return 0;
}
@ -522,6 +526,10 @@ static int peerblk_retrieval_open ( struct peerdist_block *peerblk,
if ( inject_fault ( PEERBLK_ANNUL_RATE ) )
intf_restart ( &peerblk->retrieval, 0 );
/* Start download attempt timer */
peerblk->rc = -ETIMEDOUT;
start_timer_fixed ( &peerblk->timer, PEERBLK_RETRIEVAL_OPEN_TIMEOUT );
err_open:
uri_put ( uri );
err_uri:
@ -1201,10 +1209,7 @@ static void peerblk_expired ( struct retry_timer *timer, int over __unused ) {
continue;
}
/* Start download attempt timer */
peerblk->rc = -ETIMEDOUT;
start_timer_fixed ( &peerblk->timer,
PEERBLK_RETRIEVAL_OPEN_TIMEOUT );
/* Peer download started */
return;
}
@ -1212,9 +1217,6 @@ static void peerblk_expired ( struct retry_timer *timer, int over __unused ) {
if ( ( rc = peerblk_raw_open ( peerblk ) ) != 0 )
goto err;
/* Start download attempt timer */
peerblk->rc = -ETIMEDOUT;
start_timer_fixed ( &peerblk->timer, PEERBLK_RAW_OPEN_TIMEOUT );
return;
err: