Browse Source

[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>
tags/v1.20.1
Michael Brown 5 years ago
parent
commit
02b26de963
1 changed files with 9 additions and 7 deletions
  1. 9
    7
      src/net/peerblk.c

+ 9
- 7
src/net/peerblk.c View File

358
 	if ( inject_fault ( PEERBLK_ANNUL_RATE ) )
358
 	if ( inject_fault ( PEERBLK_ANNUL_RATE ) )
359
 		intf_restart ( &peerblk->raw, 0 );
359
 		intf_restart ( &peerblk->raw, 0 );
360
 
360
 
361
+	/* Start download attempt timer */
362
+	peerblk->rc = -ETIMEDOUT;
363
+	start_timer_fixed ( &peerblk->timer, PEERBLK_RAW_OPEN_TIMEOUT );
364
+
361
 	return 0;
365
 	return 0;
362
 }
366
 }
363
 
367
 
522
 	if ( inject_fault ( PEERBLK_ANNUL_RATE ) )
526
 	if ( inject_fault ( PEERBLK_ANNUL_RATE ) )
523
 		intf_restart ( &peerblk->retrieval, 0 );
527
 		intf_restart ( &peerblk->retrieval, 0 );
524
 
528
 
529
+	/* Start download attempt timer */
530
+	peerblk->rc = -ETIMEDOUT;
531
+	start_timer_fixed ( &peerblk->timer, PEERBLK_RETRIEVAL_OPEN_TIMEOUT );
532
+
525
  err_open:
533
  err_open:
526
 	uri_put ( uri );
534
 	uri_put ( uri );
527
  err_uri:
535
  err_uri:
1201
 			continue;
1209
 			continue;
1202
 		}
1210
 		}
1203
 
1211
 
1204
-		/* Start download attempt timer */
1205
-		peerblk->rc = -ETIMEDOUT;
1206
-		start_timer_fixed ( &peerblk->timer,
1207
-				    PEERBLK_RETRIEVAL_OPEN_TIMEOUT );
1212
+		/* Peer download started */
1208
 		return;
1213
 		return;
1209
 	}
1214
 	}
1210
 
1215
 
1212
 	if ( ( rc = peerblk_raw_open ( peerblk ) ) != 0 )
1217
 	if ( ( rc = peerblk_raw_open ( peerblk ) ) != 0 )
1213
 		goto err;
1218
 		goto err;
1214
 
1219
 
1215
-	/* Start download attempt timer */
1216
-	peerblk->rc = -ETIMEDOUT;
1217
-	start_timer_fixed ( &peerblk->timer, PEERBLK_RAW_OPEN_TIMEOUT );
1218
 	return;
1220
 	return;
1219
 
1221
 
1220
  err:
1222
  err:

Loading…
Cancel
Save