git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Fwd: git-remote-fd problem

From
JSJiri 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              
Previous: Ilari LiusvaaraNext: Ilari Liusvaara
Message 3 of 4 in “git-remote-fd problem”
  1. Jiri SevcikSep 10, 2014
  2. Ilari LiusvaaraSep 10, 2014
  3. Fwd: git-remote-fd problemJiri Sevcik, Dec 29, 2014
  4. Ilari LiusvaaraDec 29, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.