{"thread":{"id":"41998","subject":"[PATCH] upload-pack: Exit when server finishes sending shallow-update in stateless RPC mode","startedAt":"2016-04-12T04:55:40Z","lastAt":"2016-04-12T05:39:14Z","messageCount":2,"participants":["Stan Hu","Torsten Bögershausen"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"283167","messageId":"1460436940-16165-1-git-send-email-stanhu@gmail.com","threadId":"41998","inReplyTo":null,"subject":"[PATCH] upload-pack: Exit when server finishes sending shallow-update in stateless RPC mode","fromName":"Stan Hu","fromEmail":"stanhu@gmail.com","sentAt":"2016-04-12T04:55:40Z","receivedAt":"2016-04-12T04:55:40Z","isPatch":true,"sender":{"key":"stanhu@gmail.com","avatar":"https://avatars.githubusercontent.com/u/963826?v=4"},"body":"In the stateless RPC case, the server should respond to the client's depth\nrequest with the set of commits which are no deeper than the desired\ndepth. Once this finishes, the server should terminate and receive the reply\nin another POST request.\n\nPreviously the server would sit idle and die when it detected the client\nclosed the connection.\n\nSigned-off-by: Stan Hu <stanhu@gmail.com>\n---\n upload-pack.c | 2 ++\n 1 file changed, 2 insertions(+)\n\ndiff --git a/upload-pack.c b/upload-pack.c\nindex b3f6653..4fb1e60 100644\n--- a/upload-pack.c\n+++ b/upload-pack.c\n@@ -676,6 +676,8 @@ static void receive_needs(void)\n \t\t\tregister_shallow(object->oid.hash);\n \t\t}\n \t\tpacket_flush(1);\n+\t\tif (stateless_rpc)\n+\t\t\texit(0);\n \t} else\n \t\tif (shallows.nr > 0) {\n \t\t\tint i;\n-- \n2.7.3\n"},{"id":"283168","messageId":"570C8A02.4050703@web.de","threadId":"41998","inReplyTo":"1460436940-16165-1-git-send-email-stanhu@gmail.com","subject":"Re: [PATCH] upload-pack: Exit when server finishes sending shallow-update in stateless RPC mode","fromName":"Torsten Bögershausen","fromEmail":"tboegi@web.de","sentAt":"2016-04-12T05:39:14Z","receivedAt":"2016-04-12T05:39:14Z","isPatch":true,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"On 04/12/2016 06:55 AM, Stan Hu wrote:\n> In the stateless RPC case, the server should respond to the client's depth\n> request with the set of commits which are no deeper than the desired\n> depth. Once this finishes, the server should terminate and receive the reply\n> in another POST request.\n>\n> Previously the server would sit idle and die when it detected the client\n> closed the connection.\nSome loose thoughts about the wording(s):\nthe server did not terminate (it's a machine, a hardware), a process \nterminated.\nAnd it did not \"die\" either, it terminates gracefully.\nHow about something like this:\n\nIn the stateless RPC case, the server responds to the client's depth\nrequest. Once this finishes, the server should terminate.\nThe reply is and received in another POST request.\n\nPreviously the server would sit idle and terminates when it detected the client\nclosed the connection.\n\n---------------\n\nBut, but,\nthere is may be more.\nWhat happens, when the server process calls exit(0) ?\nIs there a guarantee that the data is send out on the socket?\nOr is the exit(0) ripping out all the data in the TCP send buffers,\nand the client may, or not may, receive the complete packets.\n\nBeside that, a close() of a socket means that the socket is going into\ntime_wait() state.\nIs this desirable for a server to have many sockets in time_wait ?\n(This is out of my head, I may be wrong)\n\nCould it be that the client is broken ?\nCould you elaborate this a little bit more ?\n\n\n> Signed-off-by: Stan Hu <stanhu@gmail.com>\n> ---\n>   upload-pack.c | 2 ++\n>   1 file changed, 2 insertions(+)\n>\n> diff --git a/upload-pack.c b/upload-pack.c\n> index b3f6653..4fb1e60 100644\n> --- a/upload-pack.c\n> +++ b/upload-pack.c\n> @@ -676,6 +676,8 @@ static void receive_needs(void)\n>   \t\t\tregister_shallow(object->oid.hash);\n>   \t\t}\n>   \t\tpacket_flush(1);\n> +\t\tif (stateless_rpc)\n> +\t\t\texit(0);\n>   \t} else\n>   \t\tif (shallows.nr > 0) {\n>   \t\t\tint i;\n"}]}