Sfoglia il codice sorgente

[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 anni fa
parent
commit
02b26de963
1 ha cambiato i file con 9 aggiunte e 7 eliminazioni
  1. 9
    7
      src/net/peerblk.c

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

@@ -358,6 +358,10 @@ static int peerblk_raw_open ( struct peerdist_block *peerblk ) {
358 358
 	if ( inject_fault ( PEERBLK_ANNUL_RATE ) )
359 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 365
 	return 0;
362 366
 }
363 367
 
@@ -522,6 +526,10 @@ static int peerblk_retrieval_open ( struct peerdist_block *peerblk,
522 526
 	if ( inject_fault ( PEERBLK_ANNUL_RATE ) )
523 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 533
  err_open:
526 534
 	uri_put ( uri );
527 535
  err_uri:
@@ -1201,10 +1209,7 @@ static void peerblk_expired ( struct retry_timer *timer, int over __unused ) {
1201 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 1213
 		return;
1209 1214
 	}
1210 1215
 
@@ -1212,9 +1217,6 @@ static void peerblk_expired ( struct retry_timer *timer, int over __unused ) {
1212 1217
 	if ( ( rc = peerblk_raw_open ( peerblk ) ) != 0 )
1213 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 1220
 	return;
1219 1221
 
1220 1222
  err:

Loading…
Annulla
Salva