Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[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>
  • Loading branch information
mcb30 committed Aug 16, 2019
1 parent 6df2c6a commit 02b26de
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/net/peerblk.c
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -1201,20 +1209,14 @@ 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;
}

/* Attempt raw download */
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:
Expand Down

0 comments on commit 02b26de

Please sign in to comment.