]> git.proxmox.com Git - libgit2.git/commitdiff
smart: send a flush when we disconnect
authorCarlos Martín Nieto <cmn@dwim.me>
Mon, 19 May 2014 14:54:19 +0000 (16:54 +0200)
committerCarlos Martín Nieto <cmn@dwim.me>
Tue, 20 May 2014 00:41:45 +0000 (02:41 +0200)
The git server wants to hear a flush from us when we disconnect,
particularly when we want to perform a fetch but are up to date.

src/transports/smart.c

index 69eaf9b782fce487129e736e3cad1d6ce10d6f74..7fb41f788f8336d3abaef420ce260b8eddbc6c67 100644 (file)
@@ -272,6 +272,18 @@ static int git_smart__close(git_transport *transport)
        unsigned int i;
        git_pkt *p;
        int ret;
+       git_smart_subtransport_stream *stream;
+       const char flush[] = "0000";
+
+       /*
+        * If we're still connected at this point and not using RPC,
+        * we should say goodbye by sending a flush, or git-daemon
+        * will complain that we disconnected unexpectedly.
+        */
+       if (t->connected && !t->rpc &&
+           !t->wrapped->action(&stream, t->wrapped, t->url, GIT_SERVICE_UPLOADPACK)) {
+               t->current_stream->write(t->current_stream, flush, 4);
+       }
 
        ret = git_smart__reset_stream(t, true);