[peerdist] Limit number of concurrent raw block downloads

Raw block downloads are expensive if the origin server uses HTTPS,
since each concurrent download will require local TLS resources
(including potentially large received encrypted data buffers).

Raw block downloads may also be prohibitively slow to initiate when
the origin server is using HTTPS and client certificates.  Origin
servers for PeerDist downloads are likely to be running IIS, which has
a bug that breaks session resumption and requires each connection to
go through the full client certificate verification.

Limit the total number of concurrent raw block downloads to ameliorate
these problems.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown
2019-08-16 21:42:49 +01:00
parent 02b26de963
commit d8a1958ba5
2 changed files with 155 additions and 3 deletions

View File

@@ -111,6 +111,10 @@ struct peerdist_block {
struct peerdisc_client discovery;
/** Current position in discovered peer list */
struct peerdisc_peer *peer;
/** Block download queue */
struct peerdist_block_queue *queue;
/** List of queued block downloads */
struct list_head queued;
/** Retry timer */
struct retry_timer timer;
/** Number of full attempt cycles completed */
@@ -124,6 +128,26 @@ struct peerdist_block {
unsigned long attempted;
};
/** PeerDist block download queue */
struct peerdist_block_queue {
/** Download opening process */
struct process process;
/** List of queued downloads */
struct list_head list;
/** Number of open downloads */
unsigned int count;
/** Maximum number of open downloads */
unsigned int max;
/** Open block download
*
* @v peerblk PeerDist block download
* @ret rc Return status code
*/
int ( * open ) ( struct peerdist_block *peerblk );
};
/** Retrieval protocol block fetch response (including transport header)
*
* @v digestsize Digest size