ssh kitten: Send data without a roundtrip

Send data to the remote side without waiting for a data request. Avoids
an extra roundtrip during initialization.
This commit is contained in:
Kovid Goyal
2022-03-13 13:39:13 +05:30
parent 434ef97952
commit 2b06ca5e1a
4 changed files with 47 additions and 23 deletions

View File

@@ -27,6 +27,7 @@ with SharedMemory(
shm.flush()
with open(os.ctermid(), 'wb') as f:
f.write(f'\x1bP@kitty-ask|{shm.name}\x1b\\'.encode('ascii'))
f.flush()
while True:
# TODO: Replace sleep() with a mutex and condition variable created in the shared memory
time.sleep(0.05)

View File

@@ -73,8 +73,7 @@ login_cwd=""
request_data="REQUEST_DATA"
trap "cleanup_on_bootstrap_exit" EXIT
dcs_to_kitty "ssh" "id="REQUEST_ID":pwfile="PASSWORD_FILENAME":pw="DATA_PASSWORD""
record_separator=$(printf "\036")
[ "$request_data" = "1" ] && dcs_to_kitty "ssh" "id="REQUEST_ID":pwfile="PASSWORD_FILENAME":pw="DATA_PASSWORD""
mv_files_and_dirs() {
cwd="$PWD"
@@ -135,16 +134,6 @@ untar_and_read_env() {
tdir=""
}
read_record() {
record=""
while :; do
read_one_byte_from_tty || die "Reading a byte from the TTY failed"
[ "$n" = "$record_separator" ] && break
record="$record$n"
done
printf "%s" "$record"
}
get_data() {
started="n"
while IFS= read -r line; do