@torrent-tv/proxy 2.98.6 → 2.98.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -273,7 +273,15 @@ export class EncodeInputs {
|
|
|
273
273
|
bytesChanged(arrived = null) {
|
|
274
274
|
this.#revision++;
|
|
275
275
|
for (const request of this.#requests.values()) {
|
|
276
|
-
if (request.pending
|
|
276
|
+
if (request.pending) {
|
|
277
|
+
// The try in flight may have read before these bytes came. What it
|
|
278
|
+
// waits for is known only when it answers, so they are kept for that
|
|
279
|
+
// answer; bytes not named make it try again whatever it answers.
|
|
280
|
+
if (!arrived) request.unnamedArrival = true;
|
|
281
|
+
else (request.arrivedMeanwhile ??= []).push(arrived);
|
|
282
|
+
continue;
|
|
283
|
+
}
|
|
284
|
+
if (request.result?.kind === "result" || request.result?.kind === "terminal") continue;
|
|
277
285
|
if (arrived && request.result?.kind === "needs-bytes" && !awaitedIn(request.result, arrived)) {
|
|
278
286
|
// Nothing it waits for has come: it stands as tried at this revision.
|
|
279
287
|
request.revision = this.#revision;
|
|
@@ -341,6 +349,8 @@ export class EncodeInputs {
|
|
|
341
349
|
request.pending = true;
|
|
342
350
|
request.revision = this.#revision;
|
|
343
351
|
request.memoryRevision = this.#memoryRevision;
|
|
352
|
+
request.arrivedMeanwhile = null;
|
|
353
|
+
request.unnamedArrival = false;
|
|
344
354
|
// Where the time from the request to its input goes, across every attempt:
|
|
345
355
|
// field 2026-10-10, a picture's request took 38 s before its copy began and
|
|
346
356
|
// nothing said on what (torrent-tv/meta#166).
|
|
@@ -382,12 +392,29 @@ export class EncodeInputs {
|
|
|
382
392
|
request.pending = false;
|
|
383
393
|
if (request.result?.kind !== "needs-memory") this.#wanted.delete(request.key);
|
|
384
394
|
const changed = request.result?.kind === "needs-memory"
|
|
385
|
-
? request.memoryRevision !== this.#memoryRevision :
|
|
395
|
+
? request.memoryRevision !== this.#memoryRevision : this.#arrivedFor(request);
|
|
386
396
|
if (this.#requests.get(request.key) === request && changed &&
|
|
387
397
|
request.result?.kind !== "result" && request.result?.kind !== "terminal") this.#prepare(request);
|
|
388
398
|
});
|
|
389
399
|
}
|
|
390
400
|
|
|
401
|
+
/**
|
|
402
|
+
* Whether bytes came during a try that the try may have missed. A try that
|
|
403
|
+
* waits for named bytes is repeated only when some of them came, or when an
|
|
404
|
+
* event named nothing; the others stand it as tried at this revision. In r36
|
|
405
|
+
* a held-range check took 344 ms, and a piece of the file arriving during it
|
|
406
|
+
* started another (torrent-tv/meta#178).
|
|
407
|
+
*/
|
|
408
|
+
#arrivedFor(request) {
|
|
409
|
+
if (request.revision === this.#revision) return false;
|
|
410
|
+
const arrivals = request.arrivedMeanwhile ?? [];
|
|
411
|
+
request.arrivedMeanwhile = null;
|
|
412
|
+
if (request.unnamedArrival || request.result?.kind !== "needs-bytes" ||
|
|
413
|
+
arrivals.some(arrived => awaitedIn(request.result, arrived))) return true;
|
|
414
|
+
request.revision = this.#revision;
|
|
415
|
+
return false;
|
|
416
|
+
}
|
|
417
|
+
|
|
391
418
|
/** The reservation a packet input makes: all of it, or nothing. */
|
|
392
419
|
#reserveFor(request) {
|
|
393
420
|
return async bytes => {
|