]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[peerdist] Start block download timers from within opener methods
authorMichael Brown <mcb30@ipxe.org>
Fri, 16 Aug 2019 20:23:55 +0000 (21:23 +0100)
committerMichael Brown <mcb30@ipxe.org>
Fri, 16 Aug 2019 21:19:50 +0000 (22:19 +0100)
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>
src/net/peerblk.c

index 78888d2dbb778e991c8143d2834e959f25bf8850..27184e2d6eec936dbd0ced573d88b6465f4b06c0 100644 (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: