GitHub PullRequestReviewCommentEvent at 2014-02-12 09:33:25
Repository: nix
Actor: edolstra
Payload: {"comment":{"url":"https://api.github.com/repos/NixOS/nix/pulls/comments/9660967","id":9660967,"diff_hunk":"@@ -0,0 +1,144 @@\n+#include \"shared.hh\"\n+#include \"util.hh\"\n+#include \"serialise.hh\"\n+#include \"archive.hh\"\n+#include \"affinity.hh\"\n+#include \"globals.hh\"\n+#include \"serve-protocol.hh\"\n+\n+#include <iostream>\n+#include <unistd.h>\n+\n+using namespace nix;\n+using std::pair;\n+using std::cout;\n+using std::endl;\n+\n+// !!! TODO:\n+// * Respect more than the first host\n+// * use a database\n+// * show progress\n+\n+static pair<FdSink, FdSource> connect(string conn) {\n+    Pipe to, from;\n+    to.create();\n+    from.create();\n+    pid_t child = fork();\n+    switch (child) {\n+        case -1:\n+            throw SysError(\"unable to fork\");\n+        case 0:\n+            try {\n+                restoreAffinity();\n+                if (dup2(to.readSide, STDIN_FILENO) == -1)\n+                    throw SysError(\"dupping stdin\");\n+                if (dup2(from.writeSide, STDOUT_FILENO) == -1)\n+                    throw SysError(\"dupping stdout\");\n+                execlp(\"ssh\"\n+                      , \"ssh\"\n+                      , \"-x\"\n+                      , \"-T\"\n+                      , conn.c_str()\n+                      , \"nix-store --serve\"\n+                      , NULL);\n+                throw SysError(\"executing ssh\");\n+            } catch (std::exception & e) {\n+                std::cerr << \"error: \" << e.what() << std::endl;\n+            }\n+            _exit(1);\n+    }\n+    // If child exits unexpectedly, we'll EPIPE or EOF early.\n+    // If we exit unexpectedly, child will EPIPE or EOF early.\n+    // So no need to keep track of it.\n+\n+    return pair<FdSink, FdSource>(to.writeSide.borrow(), from.readSide.borrow());\n+}\n+\n+static void substitute(pair<FdSink, FdSource> & pipes, Path storePath, Path destPath) {\n+    writeInt(cmdSubstitute, pipes.first);\n+    writeString(storePath, pipes.first);\n+    pipes.first.flush();\n+    restorePath(destPath, pipes.second);\n+    cout << endl;\n+}\n+\n+static void query(pair<FdSink, FdSource> & pipes) {\n+    using std::cin;\n+    writeInt(cmdQuery, pipes.first);\n+    for (string line; getline(cin, line);) {\n+        Strings tokenized = tokenizeString<Strings>(line);\n+        string cmd = tokenized.front();\n+        tokenized.pop_front();\n+        if (cmd == \"have\") {\n+            writeInt(qCmdHave, pipes.first);\n+            foreach (Strings::iterator, i, tokenized)\n+            writeStrings(tokenized, pipes.first);","path":"src/download-via-ssh/download-via-ssh.cc","position":75,"original_position":75,"commit_id":"c89d6b9b63b629ff936a56855be5689523910c58","original_commit_id":"c89d6b9b63b629ff936a56855be5689523910c58","user":{"login":"edolstra","id":1148549,"avatar_url":"https://gravatar.com/avatar/daba67a43ee4a6429b847945067107fe?d=https%3A%2F%2Fidenticons.github.com%2F48b217f37afb01a0b3cd035504d4204b.png&r=x","gravatar_id":"daba67a43ee4a6429b847945067107fe","url":"https://api.github.com/users/edolstra","html_url":"https://github.com/edolstra","followers_url":"https://api.github.com/users/edolstra/followers","following_url":"https://api.github.com/users/edolstra/following{/other_user}","gists_url":"https://api.github.com/users/edolstra/gists{/gist_id}","starred_url":"https://api.github.com/users/edolstra/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edolstra/subscriptions","organizations_url":"https://api.github.com/users/edolstra/orgs","repos_url":"https://api.github.com/users/edolstra/repos","events_url":"https://api.github.com/users/edolstra/events{/privacy}","received_events_url":"https://api.github.com/users/edolstra/received_events","type":"User","site_admin":false},"body":"Indentation seems wrong here.","created_at":"2014-02-12T09:33:25Z","updated_at":"2014-02-12T09:33:25Z","html_url":"https://github.com/NixOS/nix/pull/206#discussion_r9660967","pull_request_url":"https://api.github.com/repos/NixOS/nix/pulls/206","_links":{"self":{"href":"https://api.github.com/repos/NixOS/nix/pulls/comments/9660967"},"html":{"href":"https://github.com/NixOS/nix/pull/206#discussion_r9660967"},"pull_request":{"href":"https://api.github.com/repos/NixOS/nix/pulls/206"}}}}