chiark / gitweb /
fishdescriptor: bugfixes
authorIan Jackson <ian.jackson@eu.citrix.com>
Thu, 19 Oct 2017 00:23:18 +0000 (01:23 +0100)
committerIan Jackson <ian.jackson@eu.citrix.com>
Thu, 19 Oct 2017 00:23:18 +0000 (01:23 +0100)
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
fishdescriptor/py/fishdescriptor/fish.py
fishdescriptor/py/fishdescriptor/indonor.py

index 78bb2d8..718456a 100644 (file)
@@ -53,11 +53,11 @@ class Donor():
             args = ['perl','-we',perl_script] + [str(x) for x in fds]
         )
         (output, dummy) = ap.communicate()
-        return output
+        return output.decode('utf-8')
 
     def donate(d, path, fds):
         ancil = d._ancilmsg(fds)
-        d._eval_success('di.donate(%s, %s)'
+        d._eval_success('di.donate(%s, [ %s ])'
                         % (repr(path), ancil))
         return len(ancil.split(','))
 
@@ -116,7 +116,7 @@ class Donor():
             s.listen(1)
 
             ancil_len = d.donate(our_sockname, fds)
-            s2 = s.accept()
+            (s2, dummy) = s.accept()
             (msg, ancil, flags, sender) = s2.recvmsg(1, ancil_len)
 
             got_fds = [ ]
index fe0b78d..51b5a3d 100644 (file)
@@ -37,11 +37,11 @@ def _lit_string_uncasted(s):
 def _lit_array(elemtype, val_lit_strs):
     return (
         '((%s[%d])%s)' %
-        (elem_type, len(val_lit_strs), _lit_aggregate_uncasted(val_lit_strs))
+        (elemtype, len(val_lit_strs), _lit_aggregate_uncasted(val_lit_strs))
     )
 
 def _lit_addressof(v):
-    return '&(%s)' % v
+    return '&(char[])(%s)' % v
 
 def _make_lit(v):
     if isinstance(v, int):
@@ -115,10 +115,10 @@ class DonorImplementation():
     # wrappers for the syscalls that do what we want
 
     def _sendmsg(di, carrier, control_msg):
-        iov_base = _lit_array('int', [str(x) for x in fds])
+        iov_base = _lit_array('char', [1])
         iov = di._make('struct iovec', {
             'iov_base': iov_base,
-            'iov_len' : len(fds),
+            'iov_len' : 1,
         })
 
         msg = di._make('struct msghdr', {
@@ -129,7 +129,7 @@ class DonorImplementation():
         })
 
         di._must_func(
-            'ssize_t (*)(int, const struct msghdr*, int flags)',
+            'ssize_t (*)(int, const struct msghdr*, int)',
             'sendmsg',
             '(%s, %s, 0)' % (carrier, _lit_addressof(msg))
         )
@@ -227,7 +227,9 @@ class DonorImplementation():
         di._result('%d\n' % val)
 
     def _protocol_read(di):
-        input = sys.stdin.readline().rstrip('\n')
+        input = sys.stdin.readline()
+        if input == '': return None
+        input.rstrip('\n')
         sys.stderr.write("#< %s\n" % input)
         return input
 
@@ -235,4 +237,5 @@ class DonorImplementation():
         while True:
             di._result('!\n')
             cmd = di._protocol_read()
+            if cmd is None: break
             eval(cmd)