fix a client crash when uploading from glitchy net

prevent reattempting chunks / handshakes after an upload has completed
since that is both pointless and crashy

bugreport ocr'ed from deepfried pic (thx kipu):
stack: exec_handshake -> xhr.onload -> tasked -> exec_upload -> do_send

529226 crash: t.fobj is null; firefox 117, win64
529083 zombie handshake onerror, some.flac
529081 chunkpit onerror,, 1, another.flac
528933 retrying stuck handshake
498842 ^
464213 zombie handshake onload, some.flac
464208 ^
462858 ignoring dupe-segment error, some.flac
462766 ^
462751 ^
462667 ^
462403 ^
462316 ^
461321 zombie handshake onload, some.flac
461302 ^
461152 ^
461114 ^
461110 ^
460769 ^
459954 ^
459492 ignoring dupe-segment error, some.flac
This commit is contained in:
ed 2023-09-20 21:25:59 +00:00
parent aa96a1acdc
commit 3b8f66c0d5

View file

@ -2160,6 +2160,9 @@ function up2k_init(subtle) {
function exec_head() {
var t = st.todo.head.shift();
if (t.done)
return console.log('done; skip head1', t.name, t);
st.busy.head.push(t);
var xhr = new XMLHttpRequest();
@ -2172,6 +2175,9 @@ function up2k_init(subtle) {
st.todo.head.unshift(t);
};
function orz(e) {
if (t.done)
return console.log('done; skip head2', t.name, t);
var ok = false;
if (xhr.status == 200) {
var srv_sz = xhr.getResponseHeader('Content-Length'),
@ -2218,6 +2224,9 @@ function up2k_init(subtle) {
keepalive = t.keepalive,
me = Date.now();
if (t.done)
return console.log('done; skip hs', t.name, t);
st.busy.handshake.push(t);
t.keepalive = undefined;
t.t_busied = me;
@ -2227,10 +2236,9 @@ function up2k_init(subtle) {
var xhr = new XMLHttpRequest();
xhr.onerror = function () {
if (t.t_busied != me) {
console.log('zombie handshake onerror,', t.name, t);
return;
}
if (t.t_busied != me) // t.done ok
return console.log('zombie handshake onerror', t.name, t);
if (!toast.visible)
toast.warn(9.98, L.u_eneths + "\n\nfile: " + t.name, t);
@ -2240,10 +2248,9 @@ function up2k_init(subtle) {
t.keepalive = keepalive;
};
var orz = function (e) {
if (t.t_busied != me) {
console.log('zombie handshake onload,', t.name, t);
return;
}
if (t.t_busied != me || t.done)
return console.log('zombie handshake onload', t.name, t);
if (xhr.status == 200) {
t.t_handshake = Date.now();
if (keepalive) {
@ -2503,14 +2510,17 @@ function up2k_init(subtle) {
}
function exec_upload() {
var upt = st.todo.upload.shift();
var upt = st.todo.upload.shift(),
t = st.files[upt.nfile],
npart = upt.npart,
tries = 0;
if (t.done)
return console.log('done; skip chunk', t.name, t);
st.busy.upload.push(upt);
st.nfile.upload = upt.nfile;
var npart = upt.npart,
t = st.files[upt.nfile],
tries = 0;
if (!t.t_uploading)
t.t_uploading = Date.now();