Fwd: git-remote-fd problem
- From
- Jiri Sevcik <jsevcik14@gmail.com>
- Date
- Dec 29, 2014, 09:47 UTC
- Message-ID
- <CAOP4-933YWoJ8QO0ZY2KG1cgtZ6jAR8oL4L9hw_0CcicDnepnQ@mail.gmail.com>
- In-Reply-To
- <CAOP4-92U+oFJJw38LWNmTqPtKMT=MDq0Ay9FiaGV5je77aUNpg@mail.gmail.com>
Show 10 quoted lines
> The remote-fd expects the transport to pass half-closes. So you can't > close all at once. > > Let there be pipes W and R and transport connection C. > > - W-read should be closed after being passed to remote-fd. > - R-write should be closed after being passed to remote-fd. > - Upon receiving "no more data" from C, close W-write. > - Upon receiving EOF from R-read, close it and signal "no more data" > to C.
Hi, I followed your advices, correctly close pipes but git clone still doesnt finish and hanging on. Code is in an attachement (its part of big system).
#create pipes
w_pipe = os.pipe()
r_pipe = os.pipe() client_process = subprocess.Popen("/usr/bin/git clone fd::{0},{1} /tmp/gittest".format(r_pipe[0], w_pipe[1]), shell=True)
#closing pipes
os.close(r_pipe[0])
os.close(w_pipe[1]) epoll = select.epoll()
epoll.register(w_pipe[0], select.EPOLLIN)
epoll.register(proc.fd, select.EPOLLIN) remoteGit = proc.runDaemon("git-upload-pack /tmp/testgit")
while True:
events = epoll.poll(1) for fd, event in events:
if fd == w_pipe[0]:
if event & select.EPOLLIN:
rd = os.read(w_pipe[0], 10000)
if rd:
#write data to remove git server
remoteGit.writeToChannel(rd)
else:
proc.writeError("Local socket write error")
return 1
else:
proc.writeError("Local socket error")
return 1 elif fd == proc.fd:
if event & select.EPOLLIN:
#read data from remote git server
data = remoteGit.getAll()
remoteGit.stderrWrite() if not data:
#remote server send EOF, close local pipe
#but git clone is still running
os.close(r_pipe[1])
return 0
want = len(data) writed = 0
offset = 0
while(writed != want):
#write data from remote git server to local pipe
wr = os.write(r_pipe[1], data[offset:]) if(wr < 0):
return 1 writed += wr
offset += wr else:
return -1