Skip to content
Snippets Groups Projects
Commit 2760bfe1 authored by Deucе's avatar Deucе :ok_hand_tone4:
Browse files

Fix syncterm_cache.js

It was badly broken, especially with large files... we now don't
try console.write() unless there's enough space in
console.output_buffer_space.

On my system (debug build of Synchronet), the most I can push through
console.write() over telnet is about 1.9MB/s.  My release build of
SyncTERM can consume about 4MB/s of string data, so Synchronet is the
choke point in my setup here. (SSH is much worse)

My super-cool demo thing ends up needing about 90 seconds to preload
all the cache stuff, so it's simply not useable, even locally. :(

If I use client.socket.send(), I can unlock the Synchronet throughput,
but I can't remember if client.socket is the passthru socket with SSH
or not... and there's no way to synchronize the socket with the console
at the end of the send (console has flush(), Socket doesn't, and even if
it did, it wouldn't flush through to the output buffer).
parent 2132c3f3
Branches
Tags
No related merge requests found
function SyncTERMCache = {
function SyncTERMCache() {
this.supported = this.supports_syncterm_cache();
};
......@@ -63,7 +63,11 @@ SyncTERMCache.prototype.upload = function (fname, cache_fname)
{
if (cache_fname === undefined)
cache_fname = fname;
var path = js.exec_dir + '/' + fname;
var path;
if (fname[0] != '/' && fname[1] != ':')
path = js.exec_dir + '/' + fname;
else
path = fname;
if (this.supported === undefined)
this.supported = this.supports_syncterm_cache();
if (!this.supported)
......@@ -71,27 +75,48 @@ SyncTERMCache.prototype.upload = function (fname, cache_fname)
// Read file MD5
var f = new File(path);
if (!f.open("rb", true))
return false;
var hash = f.md5_hex;
if (typeof hash !== 'string')
if (typeof hash !== 'string') {
f.close();
return false;
if (hash.length != 32)
}
if (hash.length != 32) {
f.close();
return false;
}
// Check for the file in the cache...
console.write('\x1b_SyncTERM:C;L;cache_fname\x1b\\');
console.write('\x1b_SyncTERM:C;L;'+cache_fname+'\x1b\\');
var lst = read_apc();
var idx = lst.indexOf('\n' + cache_fname + '\t');
if (idx !== -1) {
idx += 2;
idx += cache_fname.length;
if (hash == lst.substr(idx, idx + 32))
if (hash == lst.substr(idx, idx + 32)) {
f.close();
return true;
}
}
if (!f.open("rb", true))
return false;
f.base64 = true;
var buf = "\x1b_SyncTERM:C;S;"+cache_fname+";"+f.read()+"\x1b\\";
console.write("\x1b_SyncTERM:C;S;"+cache_fname+";");
var buf;
while((!js.terminated) && bbs.online) {
var rdlen = console.output_buffer_space;
if (rdlen < 4) {
mswait(1);
continue;
}
rdlen = parseInt(rdlen / 4, 10);
rdlen *= 3;
buf = f.read(rdlen);
if (buf.length === 0)
break;
console.write(buf);
}
console.write("\x1b\\");
f.close();
return true;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment