{"thread":{"id":"655","subject":"[PATCH] Make rsh protocol extensible","startedAt":"2005-05-19T05:11:46Z","lastAt":"2005-06-03T21:38:49Z","messageCount":3,"participants":["Daniel Barkalow","Petr Baudis"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"3532","messageId":"Pine.LNX.4.21.0505190108490.30848-100000@iabervon.org","threadId":"655","inReplyTo":null,"subject":"[PATCH] Make rsh protocol extensible","fromName":"Daniel Barkalow","fromEmail":"barkalow@iabervon.org","sentAt":"2005-05-19T05:11:46Z","receivedAt":"2005-05-19T05:11:46Z","isPatch":true,"sender":{"key":"barkalow@iabervon.org","avatar":"https://avatars.githubusercontent.com/u/55364219?v=4"},"body":"This changes the rsh protocol to allow reporting failure in getting an\nobject without breaking the connection, and to allow other types of\nrequest than for objects to be made. It is a preliminary to any more\nextensive pull operation.\n\nSigned-off-by: Daniel Barkalow <barkalow@iabervon.org>\nIndex: rpull.c\n===================================================================\n--- 75b95bec390d6728b9b1b4572056af8cee34ea7d/rpull.c  (mode:100644 sha1:b48e63157c66c160b9751603a92831f77106044c)\n+++ c70baff05489356575384857c7cc4d4c641c39e3/rpull.c  (mode:100644 sha1:7f5b390d8ed653bfb67363db2c61c576a4d3134d)\n@@ -15,7 +15,16 @@\n int fetch(unsigned char *sha1)\n {\n \tint ret;\n-\twrite(fd_out, sha1, 20);\n+\tsigned char remote;\n+\tchar type = 'o';\n+\tif (has_sha1_file(sha1))\n+\t\treturn 0;\n+\twrite(fd_out, &type, 1);\n+        write(fd_out, sha1, 20);\n+\tif (read(fd_in, &remote, 1) < 1)\n+\t\treturn -1;\n+\tif (remote < 0)\n+\t\treturn remote;\n \tret = write_sha1_from_fd(sha1, fd_in);\n \tif (!ret)\n \t\tpull_say(\"got %s\\n\", sha1_to_hex(sha1));\nIndex: rpush.c\n===================================================================\n--- 75b95bec390d6728b9b1b4572056af8cee34ea7d/rpush.c  (mode:100644 sha1:3f2c898c8f5cf5ba62d689a13c646936b8372ee7)\n+++ c70baff05489356575384857c7cc4d4c641c39e3/rpush.c  (mode:100644 sha1:07a8461878ad7b1d8cea27e44003b2ed44632834)\n@@ -3,46 +3,68 @@\n #include <sys/socket.h>\n #include <errno.h>\n \n-void service(int fd_in, int fd_out) {\n+int serve_object(int fd_in, int fd_out) {\n \tssize_t size;\n-\tint posn;\n+\tint posn = 0;\n \tchar unsigned sha1[20];\n \tunsigned long objsize;\n \tvoid *buf;\n+\tsigned char remote;\n \tdo {\n-\t\tposn = 0;\n-\t\tdo {\n-\t\t\tsize = read(fd_in, sha1 + posn, 20 - posn);\n-\t\t\tif (size < 0) {\n-\t\t\t\tperror(\"rpush: read \");\n-\t\t\t\treturn;\n+\t\tsize = read(fd_in, sha1 + posn, 20 - posn);\n+\t\tif (size < 0) {\n+\t\t\tperror(\"rpush: read \");\n+\t\t\treturn -1;\n+\t\t}\n+\t\tif (!size)\n+\t\t\treturn -1;\n+\t\tposn += size;\n+\t} while (posn < 20);\n+\t\n+\t/* fprintf(stderr, \"Serving %s\\n\", sha1_to_hex(sha1)); */\n+\tremote = 0;\n+\t\n+\tbuf = map_sha1_file(sha1, &objsize);\n+\t\n+\tif (!buf) {\n+\t\tfprintf(stderr, \"rpush: could not find %s\\n\", \n+\t\t\tsha1_to_hex(sha1));\n+\t\tremote = -1;\n+\t}\n+\t\n+\twrite(fd_out, &remote, 1);\n+\t\n+\tif (remote < 0)\n+\t\treturn 0;\n+\t\n+\tposn = 0;\n+\tdo {\n+\t\tsize = write(fd_out, buf + posn, objsize - posn);\n+\t\tif (size <= 0) {\n+\t\t\tif (!size) {\n+\t\t\t\tfprintf(stderr, \"rpush: write closed\");\n+\t\t\t} else {\n+\t\t\t\tperror(\"rpush: write \");\n \t\t\t}\n-\t\t\tif (!size)\n-\t\t\t\treturn;\n-\t\t\tposn += size;\n-\t\t} while (posn < 20);\n-\n-\t\t/* fprintf(stderr, \"Serving %s\\n\", sha1_to_hex(sha1)); */\n+\t\t\treturn -1;\n+\t\t}\n+\t\tposn += size;\n+\t} while (posn < objsize);\n+\treturn 0;\n+}\n \n-\t\tbuf = map_sha1_file(sha1, &objsize);\n-\t\tif (!buf) {\n-\t\t\tfprintf(stderr, \"rpush: could not find %s\\n\", \n-\t\t\t\tsha1_to_hex(sha1));\n+void service(int fd_in, int fd_out) {\n+\tchar type;\n+\tint retval;\n+\tdo {\n+\t\tretval = read(fd_in, &type, 1);\n+\t\tif (retval < 1) {\n+\t\t\tif (retval < 0)\n+\t\t\t\tperror(\"rpush: read \");\n \t\t\treturn;\n \t\t}\n-\t\tposn = 0;\n-\t\tdo {\n-\t\t\tsize = write(fd_out, buf + posn, objsize - posn);\n-\t\t\tif (size <= 0) {\n-\t\t\t\tif (!size) {\n-\t\t\t\t\tfprintf(stderr, \"rpush: write closed\");\n-\t\t\t\t} else {\n-\t\t\t\t\tperror(\"rpush: write \");\n-\t\t\t\t}\n-\t\t\t\treturn;\n-\t\t\t}\n-\t\t\tposn += size;\n-\t\t} while (posn < objsize);\n+\t\tif (type == 'o' && serve_object(fd_in, fd_out))\n+\t\t\treturn;\n \t} while (1);\n }\n \n@@ -53,6 +75,8 @@\n         char *url;\n \tint fd_in, fd_out;\n \twhile (arg < argc && argv[arg][0] == '-') {\n+\t\tif (argv[arg][1] == 'w')\n+\t\t\targ++;\n                 arg++;\n         }\n         if (argc < arg + 2) {\nIndex: rsh.c\n===================================================================\n--- 75b95bec390d6728b9b1b4572056af8cee34ea7d/rsh.c  (mode:100644 sha1:5d1cb9d578a8e679fc190a9d7d2c842ad811223f)\n+++ c70baff05489356575384857c7cc4d4c641c39e3/rsh.c  (mode:100644 sha1:71afc1aa5c9fb3cfe8d49e73471c30e92df9e327)\n@@ -36,8 +36,8 @@\n \t*(path++) = '\\0';\n \t/* ssh <host> 'cd /<path>; stdio-pull <arg...> <commit-id>' */\n \tsnprintf(command, COMMAND_SIZE, \n-\t\t \"cd /%s; %s=objects %s\",\n-\t\t path, DB_ENVIRONMENT, remote_prog);\n+\t\t \"GIT_DIR='%s' %s\",\n+\t\t path, remote_prog);\n \tposn = command + strlen(command);\n \tfor (i = 0; i < rmt_argc; i++) {\n \t\t*(posn++) = ' ';\n\n"},{"id":"4447","messageId":"20050602205912.GD32189@pasky.ji.cz","threadId":"655","inReplyTo":"Pine.LNX.4.21.0505190108490.30848-100000@iabervon.org","subject":"Re: [PATCH] Make rsh protocol extensible","fromName":"Petr Baudis","fromEmail":"pasky@ucw.cz","sentAt":"2005-06-02T20:59:12Z","receivedAt":"2005-06-02T20:59:12Z","isPatch":true,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"Dear diary, on Thu, May 19, 2005 at 07:11:46AM CEST, I got a letter\nwhere Daniel Barkalow <barkalow@iabervon.org> told me that...\n> This changes the rsh protocol to allow reporting failure in getting an\n> object without breaking the connection, and to allow other types of\n> request than for objects to be made. It is a preliminary to any more\n> extensive pull operation.\n> \n> Signed-off-by: Daniel Barkalow <barkalow@iabervon.org>\n\nI wanted to apply it but then I figured out that I will better hold it\nand ask you what do you think about it now after few weeks. ;-) Should I\nstill go on and apply it to Cogito?\n\n-- \n\t\t\t\tPetr \"Pasky\" Baudis\nStuff: http://pasky.or.cz/\nC++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor\n"},{"id":"4510","messageId":"Pine.LNX.4.21.0506031737090.30848-100000@iabervon.org","threadId":"655","inReplyTo":"20050602205912.GD32189@pasky.ji.cz","subject":"Re: [PATCH] Make rsh protocol extensible","fromName":"Daniel Barkalow","fromEmail":"barkalow@iabervon.org","sentAt":"2005-06-03T21:38:49Z","receivedAt":"2005-06-03T21:38:49Z","isPatch":true,"sender":{"key":"barkalow@iabervon.org","avatar":"https://avatars.githubusercontent.com/u/55364219?v=4"},"body":"On Thu, 2 Jun 2005, Petr Baudis wrote:\n\n> Dear diary, on Thu, May 19, 2005 at 07:11:46AM CEST, I got a letter\n> where Daniel Barkalow <barkalow@iabervon.org> told me that...\n> > This changes the rsh protocol to allow reporting failure in getting an\n> > object without breaking the connection, and to allow other types of\n> > request than for objects to be made. It is a preliminary to any more\n> > extensive pull operation.\n> > \n> > Signed-off-by: Daniel Barkalow <barkalow@iabervon.org>\n> \n> I wanted to apply it but then I figured out that I will better hold it\n> and ask you what do you think about it now after few weeks. ;-) Should I\n> still go on and apply it to Cogito?\n\nAt this point, I want to also put in a protocol version number. I'll send\na replacement patch in a bit.\n\n\t-Daniel\n*This .sig left intentionally blank*\n\n"}]}