[PATCH 1/3] mux: write multiple chunks direclty via writev

0 views
Skip to first unread message

Rob Browning

unread,
May 25, 2024, 3:28:45 PMMay 25
to bup-...@googlegroups.com
Signed-off-by: Rob Browning <r...@defaultvalue.org>
---

Pushed to main.

lib/bup/helpers.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/bup/helpers.py b/lib/bup/helpers.py
index d4da1756b..1260750f9 100644
--- a/lib/bup/helpers.py
+++ b/lib/bup/helpers.py
@@ -580,11 +580,11 @@ def mux(p, outfd, outr, errr):
if fd == outr:
buf = os.read(outr, MAX_PACKET)
if not buf: break
- os.write(outfd, struct.pack('!IB', len(buf), 1) + buf)
+ os.writev(outfd, (struct.pack('!IB', len(buf), 1), buf))
elif fd == errr:
buf = os.read(errr, 1024)
if not buf: break
- os.write(outfd, struct.pack('!IB', len(buf), 2) + buf)
+ os.writev(outfd, (struct.pack('!IB', len(buf), 2), buf))
finally:
os.write(outfd, struct.pack('!IB', 0, 3))

--
2.43.0

Rob Browning

unread,
May 25, 2024, 3:28:45 PMMay 25
to bup-...@googlegroups.com
Signed-off-by: Rob Browning <r...@defaultvalue.org>
Tested-by: Rob Browning <r...@defaultvalue.org>
---

Pushed to main.

lib/bup/cmd/on.py | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/lib/bup/cmd/on.py b/lib/bup/cmd/on.py
index 983283ceb..9627120d0 100644
--- a/lib/bup/cmd/on.py
+++ b/lib/bup/cmd/on.py
@@ -1,4 +1,4 @@
-from __future__ import absolute_import
+
from subprocess import PIPE
import getopt, os, signal, struct, subprocess, sys

@@ -9,17 +9,14 @@ from bup.io import byte_stream


optspec = """
-bup on <hostname> index ...
-bup on <hostname> save ...
-bup on <hostname> split ...
-bup on <hostname> get ...
+bup on <hostname> <index|save|split|get> ...
"""

def main(argv):
o = options.Options(optspec, optfunc=getopt.getopt)
opt, flags, extra = o.parse_bytes(argv[1:])
if len(extra) < 2:
- o.fatal('arguments expected')
+ o.fatal('must specify index, save, split, or get command')

class SigException(Exception):
def __init__(self, signum):
--
2.43.0

Rob Browning

unread,
May 25, 2024, 3:28:46 PMMay 25
to bup-...@googlegroups.com
Signed-off-by: Rob Browning <r...@defaultvalue.org>
Tested-by: Rob Browning <r...@defaultvalue.org>
---

Pushed to main.

lib/bup/cmd/on.py | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/lib/bup/cmd/on.py b/lib/bup/cmd/on.py
index 9627120d0..1d52eda76 100644
--- a/lib/bup/cmd/on.py
+++ b/lib/bup/cmd/on.py
@@ -25,6 +25,14 @@ def main(argv):
def handler(signum, frame):
raise SigException(signum)

+ remote = argv_bytes(extra[0]).split(b':')
+ argv = [argv_bytes(x) for x in extra[1:]]
+
+ if len(remote) == 1:
+ hostname, port = (remote[0], None)
+ else:
+ hostname, port = remote
+
signal.signal(signal.SIGTERM, handler)
signal.signal(signal.SIGINT, handler)

@@ -35,15 +43,7 @@ def main(argv):
sp = None
p = None
ret = 99
-
- hp = argv_bytes(extra[0]).split(b':')
- if len(hp) == 1:
- (hostname, port) = (hp[0], None)
- else:
- (hostname, port) = hp
- argv = [argv_bytes(x) for x in extra[1:]]
p = ssh.connect(hostname, port, b'on--server', stderr=PIPE)
-
try:
argvs = b'\0'.join([b'bup'] + argv)
p.stdin.write(struct.pack('!I', len(argvs)) + argvs)
--
2.43.0

Reply all
Reply to author
Forward
0 new messages