diff --git a/primary.py b/primary.py
index bbf7314bd5e366bc97ca646d50e4c23d4ffcf6f4..6ab686fdf509d465d23bcbb5d98c883eca8c8631 100644
--- a/primary.py
+++ b/primary.py
@@ -121,6 +121,7 @@ class Server:
                                   stderr=self.log.makefile(encoding='utf-8'))
             self.log.DEBUG('OK run_star', cmd, cwd)
         finally:
+            self.log.MESSAGE('shutting down star_socket')
             star_socket.shutdown(socket.SHUT_RDWR)
         self.log.DEBUG('DONE run_star', cmd, cwd)
 
diff --git a/secondary.py b/secondary.py
index 9b30d400a05b73b44b808908c75784cc9302597e..6265ef9af62a545f97e4df3412f677c47cadf9df 100644
--- a/secondary.py
+++ b/secondary.py
@@ -131,6 +131,7 @@ class Backup:
             self.primary_in.write(parent + b'\0')
             parent = os.path.dirname(parent)
         self.primary_in.write(src.name + b'\0')
+        self.primary_in.flush()
 
     def delete(self, dst):
         self.log.DEBUG('Delete:', dst.name)