{"action":"created","comment":{"url":"https://api.github.com/repos/m-lab/ndt/pulls/comments/29892624","id":29892624,"diff_hunk":"@@ -256,89 +259,90 @@ int test_s2c(int ctlsockfd, tcp_stat_agent* agent, TestOptions* testOptions,\n \n       // If a valid connection request is received, client has connected.\n       // Proceed.\n-      // Note the new socket fd - xmitfd - used in the throughput test\n-ximfd: xmitsfd = accept(testOptions->s2csockfd,\n-                        (struct sockaddr *) &cli_addr, &clilen);\n-       if (xmitsfd > 0) {\n-         log_println(6, \"accept() for %d completed\",\n-                     testOptions->child0);\n-         procstatusenum = PROCESS_STARTED;\n-         proctypeenum = CONNECT_TYPE;\n-         protolog_procstatus(testOptions->child0, testids, proctypeenum,\n-                             procstatusenum, xmitsfd);\n-         if (testOptions->connection_flags & WEBSOCKET_SUPPORT) {\n-\t   // To preserve user privacy, make sure that the HTTP header\n-\t   // processing is done prior to the start of packet capture, as many\n-\t   // browsers have headers that uniquely identitfy a single user.\n-           if (initialize_websocket_connection(xmitsfd, 0, \"s2c\") != 0) {\n-             xmitsfd = 0;\n-           } \n-         } \n-         break;\n-       }\n-       // socket interrupted, wait some more\n-       if ((xmitsfd == -1) && (errno == EINTR)) {\n-         log_println(\n-             6,\n-             \"Child %d interrupted while waiting for accept() to complete\",\n-             testOptions->child0);\n-         goto ximfd;\n-       }\n-       log_println(\n-           6,\n-           \"-------     S2C connection setup for %d returned because (%d)\",\n-           testOptions->child0, errno);\n-       if (xmitsfd < 0)  // other socket errors, quit\n-         return -errno;\n-       if (++j == 4) {  // retry exceeded, quit\n-         log_println(\n-             6,\n-             \"s2c child %d, unable to open connection, return from test\",\n-             testOptions->child0);\n-         return -102;\n-       }\n+      // Note the new connection - s2c_conn - used in the throughput test\n+    ximfd:\n+      s2c_conn.socket = accept(testOptions->s2csockfd,\n+                               (struct sockaddr *)&cli_addr, &clilen);\n+      if (s2c_conn.socket > 0) {\n+        log_println(6, \"accept() for %d completed\", testOptions->child0);\n+        procstatusenum = PROCESS_STARTED;\n+        proctypeenum = CONNECT_TYPE;\n+        protolog_procstatus(testOptions->child0, testids, proctypeenum,\n+                            procstatusenum, s2c_conn.socket);\n+        if (testOptions->connection_flags & TLS_SUPPORT) {\n+          s2c_conn.ssl = SSL_new(ctx);\n+          if (s2c_conn.ssl == NULL) return ENOMEM;\n+          if (SSL_set_fd(s2c_conn.ssl, s2c_conn.socket) == 0) return EIO;\n+          if (SSL_accept(s2c_conn.ssl) != 1) return EIO;\n+        }\n+        if (testOptions->connection_flags & WEBSOCKET_SUPPORT) {\n+          // To preserve user privacy, make sure that the HTTP header\n+          // processing is done prior to the start of packet capture, as many\n+          // browsers have headers that uniquely identitfy a single user.\n+          if (initialize_websocket_connection(&s2c_conn, 0, \"s2c\") != 0) {\n+            s2c_conn.socket = 0;\n+          } \n+        } \n+        break;\n+      }\n+      // socket interrupted, wait some more\n+      if ((s2c_conn.socket == -1) && (errno == EINTR)) {\n+        log_println(\n+            6,\n+            \"Child %d interrupted while waiting for accept() to complete\",\n+            testOptions->child0);\n+        goto ximfd;\n+      }\n+      log_println(\n+          6,\n+          \"-------     S2C connection setup for %d returned because (%d)\",\n+          testOptions->child0, errno);\n+      if (s2c_conn.socket < 0)  // other socket errors, quit\n+        return -errno;\n+      if (++j == 4) {  // retry exceeded, quit\n+        log_println(\n+            6,\n+            \"s2c child %d, unable to open connection, return from test\",\n+            testOptions->child0);\n+        return -102;\n+      }\n     }\n-    src_addr = I2AddrByLocalSockFD(get_errhandle(), xmitsfd, 0);\n-    conn = tcp_stat_connection_from_socket(agent, xmitsfd);\n+    src_addr = I2AddrByLocalSockFD(get_errhandle(), s2c_conn.socket, 0);\n+    conn = tcp_stat_connection_from_socket(agent, s2c_conn.socket);\n \n     // set up packet capture. The data collected is used for bottleneck link\n     // calculations\n-    if (xmitsfd > 0) {\n+    if (s2c_conn.socket > 0) {\n       log_println(6, \"S2C child %d, ready to fork()\",\n                   testOptions->child0);\n       if (getuid() == 0) {\n         /*\n            pipe(mon_pipe2);\n-           start_packet_trace(xmitsfd, testOptions->s2csockfd,\n+           start_packet_trace(s2c_conn.socket, testOptions->s2csockfd,\n            &s2c_childpid, mon_pipe2, (struct sockaddr *) &cli_addr,\n            clilen, device, &pair, \"s2c\", options->compress,\n            meta.s2c_ndttrace);\n            */\n-        if (pipe(mon_pipe) != 0) {\n-          log_println(0, \"S2C test error: can't create pipe.\");\n-        } else {\n-          if ((s2c_childpid = fork()) == 0) {\n-            /* close(ctlsockfd); */\n-            close(testOptions->s2csockfd);\n-            close(xmitsfd);\n-            log_println(\n-                5,\n-                \"S2C test Child thinks pipe() returned fd0=%d, fd1=%d\",\n-                mon_pipe[0], mon_pipe[1]);\n-            // log_println(2, \"S2C test calling init_pkttrace() with pd=0x%x\",\n-            //             (int) &cli_addr);\n-            init_pkttrace(src_addr, (struct sockaddr *) &cli_addr,\n-                          clilen, mon_pipe, device, &pair, \"s2c\",\n-                          options->compress);\n-            log_println(6,\n-                        \"S2C test ended, why is timer still running?\");\n-            /* Close the pipe */\n-            close(mon_pipe[0]);\n-            close(mon_pipe[1]);\n-            exit(0); /* Packet trace finished, terminate gracefully */\n-          } else if (s2c_childpid < 0){\n-            log_println(0, \"S2C test error: can't create child process.\");\n-          }\n+        pipe(mon_pipe);","path":"src/test_s2c_srv.c","position":236,"original_position":236,"commit_id":"07c29aa5506a4eaaae5c6dcc097938456f438a26","original_commit_id":"07c29aa5506a4eaaae5c6dcc097938456f438a26","user":{"login":"pboothe","id":143798,"avatar_url":"https://avatars.githubusercontent.com/u/143798?v=3","gravatar_id":"","url":"https://api.github.com/users/pboothe","html_url":"https://github.com/pboothe","followers_url":"https://api.github.com/users/pboothe/followers","following_url":"https://api.github.com/users/pboothe/following{/other_user}","gists_url":"https://api.github.com/users/pboothe/gists{/gist_id}","starred_url":"https://api.github.com/users/pboothe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pboothe/subscriptions","organizations_url":"https://api.github.com/users/pboothe/orgs","repos_url":"https://api.github.com/users/pboothe/repos","events_url":"https://api.github.com/users/pboothe/events{/privacy}","received_events_url":"https://api.github.com/users/pboothe/received_events","type":"User","site_admin":false},"body":"Honestly, I don't remember.  Putting it back in.","created_at":"2015-05-07T20:29:37Z","updated_at":"2015-05-07T20:29:37Z","html_url":"https://github.com/m-lab/ndt/pull/5#discussion_r29892624","pull_request_url":"https://api.github.com/repos/m-lab/ndt/pulls/5","_links":{"self":{"href":"https://api.github.com/repos/m-lab/ndt/pulls/comments/29892624"},"html":{"href":"https://github.com/m-lab/ndt/pull/5#discussion_r29892624"},"pull_request":{"href":"https://api.github.com/repos/m-lab/ndt/pulls/5"}}},"pull_request":{"url":"https://api.github.com/repos/m-lab/ndt/pulls/5","id":34864626,"html_url":"https://github.com/m-lab/ndt/pull/5","diff_url":"https://github.com/m-lab/ndt/pull/5.diff","patch_url":"https://github.com/m-lab/ndt/pull/5.patch","issue_url":"https://api.github.com/repos/m-lab/ndt/issues/5","number":5,"state":"open","locked":false,"title":"Change 3 of N of adding SSL support to NDT.","user":{"login":"pboothe","id":143798,"avatar_url":"https://avatars.githubusercontent.com/u/143798?v=3","gravatar_id":"","url":"https://api.github.com/users/pboothe","html_url":"https://github.com/pboothe","followers_url":"https://api.github.com/users/pboothe/followers","following_url":"https://api.github.com/users/pboothe/following{/other_user}","gists_url":"https://api.github.com/users/pboothe/gists{/gist_id}","starred_url":"https://api.github.com/users/pboothe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pboothe/subscriptions","organizations_url":"https://api.github.com/users/pboothe/orgs","repos_url":"https://api.github.com/users/pboothe/repos","events_url":"https://api.github.com/users/pboothe/events{/privacy}","received_events_url":"https://api.github.com/users/pboothe/received_events","type":"User","site_admin":false},"body":"All the changes to the tests.","created_at":"2015-05-06T21:56:41Z","updated_at":"2015-05-07T20:29:37Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b42cba7c752c8314c4f55da2f9838f1f0c3a8dc3","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/m-lab/ndt/pulls/5/commits","review_comments_url":"https://api.github.com/repos/m-lab/ndt/pulls/5/comments","review_comment_url":"https://api.github.com/repos/m-lab/ndt/pulls/comments{/number}","comments_url":"https://api.github.com/repos/m-lab/ndt/issues/5/comments","statuses_url":"https://api.github.com/repos/m-lab/ndt/statuses/07c29aa5506a4eaaae5c6dcc097938456f438a26","head":{"label":"m-lab:tls","ref":"tls","sha":"07c29aa5506a4eaaae5c6dcc097938456f438a26","user":{"login":"m-lab","id":3496264,"avatar_url":"https://avatars.githubusercontent.com/u/3496264?v=3","gravatar_id":"","url":"https://api.github.com/users/m-lab","html_url":"https://github.com/m-lab","followers_url":"https://api.github.com/users/m-lab/followers","following_url":"https://api.github.com/users/m-lab/following{/other_user}","gists_url":"https://api.github.com/users/m-lab/gists{/gist_id}","starred_url":"https://api.github.com/users/m-lab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/m-lab/subscriptions","organizations_url":"https://api.github.com/users/m-lab/orgs","repos_url":"https://api.github.com/users/m-lab/repos","events_url":"https://api.github.com/users/m-lab/events{/privacy}","received_events_url":"https://api.github.com/users/m-lab/received_events","type":"Organization","site_admin":false},"repo":{"id":33625942,"name":"ndt","full_name":"m-lab/ndt","owner":{"login":"m-lab","id":3496264,"avatar_url":"https://avatars.githubusercontent.com/u/3496264?v=3","gravatar_id":"","url":"https://api.github.com/users/m-lab","html_url":"https://github.com/m-lab","followers_url":"https://api.github.com/users/m-lab/followers","following_url":"https://api.github.com/users/m-lab/following{/other_user}","gists_url":"https://api.github.com/users/m-lab/gists{/gist_id}","starred_url":"https://api.github.com/users/m-lab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/m-lab/subscriptions","organizations_url":"https://api.github.com/users/m-lab/orgs","repos_url":"https://api.github.com/users/m-lab/repos","events_url":"https://api.github.com/users/m-lab/events{/privacy}","received_events_url":"https://api.github.com/users/m-lab/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/m-lab/ndt","description":"Network Diagnostic Tool","fork":true,"url":"https://api.github.com/repos/m-lab/ndt","forks_url":"https://api.github.com/repos/m-lab/ndt/forks","keys_url":"https://api.github.com/repos/m-lab/ndt/keys{/key_id}","collaborators_url":"https://api.github.com/repos/m-lab/ndt/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/m-lab/ndt/teams","hooks_url":"https://api.github.com/repos/m-lab/ndt/hooks","issue_events_url":"https://api.github.com/repos/m-lab/ndt/issues/events{/number}","events_url":"https://api.github.com/repos/m-lab/ndt/events","assignees_url":"https://api.github.com/repos/m-lab/ndt/assignees{/user}","branches_url":"https://api.github.com/repos/m-lab/ndt/branches{/branch}","tags_url":"https://api.github.com/repos/m-lab/ndt/tags","blobs_url":"https://api.github.com/repos/m-lab/ndt/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/m-lab/ndt/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/m-lab/ndt/git/refs{/sha}","trees_url":"https://api.github.com/repos/m-lab/ndt/git/trees{/sha}","statuses_url":"https://api.github.com/repos/m-lab/ndt/statuses/{sha}","languages_url":"https://api.github.com/repos/m-lab/ndt/languages","stargazers_url":"https://api.github.com/repos/m-lab/ndt/stargazers","contributors_url":"https://api.github.com/repos/m-lab/ndt/contributors","subscribers_url":"https://api.github.com/repos/m-lab/ndt/subscribers","subscription_url":"https://api.github.com/repos/m-lab/ndt/subscription","commits_url":"https://api.github.com/repos/m-lab/ndt/commits{/sha}","git_commits_url":"https://api.github.com/repos/m-lab/ndt/git/commits{/sha}","comments_url":"https://api.github.com/repos/m-lab/ndt/comments{/number}","issue_comment_url":"https://api.github.com/repos/m-lab/ndt/issues/comments{/number}","contents_url":"https://api.github.com/repos/m-lab/ndt/contents/{+path}","compare_url":"https://api.github.com/repos/m-lab/ndt/compare/{base}...{head}","merges_url":"https://api.github.com/repos/m-lab/ndt/merges","archive_url":"https://api.github.com/repos/m-lab/ndt/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/m-lab/ndt/downloads","issues_url":"https://api.github.com/repos/m-lab/ndt/issues{/number}","pulls_url":"https://api.github.com/repos/m-lab/ndt/pulls{/number}","milestones_url":"https://api.github.com/repos/m-lab/ndt/milestones{/number}","notifications_url":"https://api.github.com/repos/m-lab/ndt/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/m-lab/ndt/labels{/name}","releases_url":"https://api.github.com/repos/m-lab/ndt/releases{/id}","created_at":"2015-04-08T18:54:07Z","updated_at":"2015-05-06T21:54:03Z","pushed_at":"2015-05-06T22:01:08Z","git_url":"git://github.com/m-lab/ndt.git","ssh_url":"git@github.com:m-lab/ndt.git","clone_url":"https://github.com/m-lab/ndt.git","svn_url":"https://github.com/m-lab/ndt","homepage":null,"size":4136,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"m-lab:master","ref":"master","sha":"8c8f6feed28c64dbb54552ac4b34d848716a7991","user":{"login":"m-lab","id":3496264,"avatar_url":"https://avatars.githubusercontent.com/u/3496264?v=3","gravatar_id":"","url":"https://api.github.com/users/m-lab","html_url":"https://github.com/m-lab","followers_url":"https://api.github.com/users/m-lab/followers","following_url":"https://api.github.com/users/m-lab/following{/other_user}","gists_url":"https://api.github.com/users/m-lab/gists{/gist_id}","starred_url":"https://api.github.com/users/m-lab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/m-lab/subscriptions","organizations_url":"https://api.github.com/users/m-lab/orgs","repos_url":"https://api.github.com/users/m-lab/repos","events_url":"https://api.github.com/users/m-lab/events{/privacy}","received_events_url":"https://api.github.com/users/m-lab/received_events","type":"Organization","site_admin":false},"repo":{"id":33625942,"name":"ndt","full_name":"m-lab/ndt","owner":{"login":"m-lab","id":3496264,"avatar_url":"https://avatars.githubusercontent.com/u/3496264?v=3","gravatar_id":"","url":"https://api.github.com/users/m-lab","html_url":"https://github.com/m-lab","followers_url":"https://api.github.com/users/m-lab/followers","following_url":"https://api.github.com/users/m-lab/following{/other_user}","gists_url":"https://api.github.com/users/m-lab/gists{/gist_id}","starred_url":"https://api.github.com/users/m-lab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/m-lab/subscriptions","organizations_url":"https://api.github.com/users/m-lab/orgs","repos_url":"https://api.github.com/users/m-lab/repos","events_url":"https://api.github.com/users/m-lab/events{/privacy}","received_events_url":"https://api.github.com/users/m-lab/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/m-lab/ndt","description":"Network Diagnostic Tool","fork":true,"url":"https://api.github.com/repos/m-lab/ndt","forks_url":"https://api.github.com/repos/m-lab/ndt/forks","keys_url":"https://api.github.com/repos/m-lab/ndt/keys{/key_id}","collaborators_url":"https://api.github.com/repos/m-lab/ndt/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/m-lab/ndt/teams","hooks_url":"https://api.github.com/repos/m-lab/ndt/hooks","issue_events_url":"https://api.github.com/repos/m-lab/ndt/issues/events{/number}","events_url":"https://api.github.com/repos/m-lab/ndt/events","assignees_url":"https://api.github.com/repos/m-lab/ndt/assignees{/user}","branches_url":"https://api.github.com/repos/m-lab/ndt/branches{/branch}","tags_url":"https://api.github.com/repos/m-lab/ndt/tags","blobs_url":"https://api.github.com/repos/m-lab/ndt/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/m-lab/ndt/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/m-lab/ndt/git/refs{/sha}","trees_url":"https://api.github.com/repos/m-lab/ndt/git/trees{/sha}","statuses_url":"https://api.github.com/repos/m-lab/ndt/statuses/{sha}","languages_url":"https://api.github.com/repos/m-lab/ndt/languages","stargazers_url":"https://api.github.com/repos/m-lab/ndt/stargazers","contributors_url":"https://api.github.com/repos/m-lab/ndt/contributors","subscribers_url":"https://api.github.com/repos/m-lab/ndt/subscribers","subscription_url":"https://api.github.com/repos/m-lab/ndt/subscription","commits_url":"https://api.github.com/repos/m-lab/ndt/commits{/sha}","git_commits_url":"https://api.github.com/repos/m-lab/ndt/git/commits{/sha}","comments_url":"https://api.github.com/repos/m-lab/ndt/comments{/number}","issue_comment_url":"https://api.github.com/repos/m-lab/ndt/issues/comments{/number}","contents_url":"https://api.github.com/repos/m-lab/ndt/contents/{+path}","compare_url":"https://api.github.com/repos/m-lab/ndt/compare/{base}...{head}","merges_url":"https://api.github.com/repos/m-lab/ndt/merges","archive_url":"https://api.github.com/repos/m-lab/ndt/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/m-lab/ndt/downloads","issues_url":"https://api.github.com/repos/m-lab/ndt/issues{/number}","pulls_url":"https://api.github.com/repos/m-lab/ndt/pulls{/number}","milestones_url":"https://api.github.com/repos/m-lab/ndt/milestones{/number}","notifications_url":"https://api.github.com/repos/m-lab/ndt/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/m-lab/ndt/labels{/name}","releases_url":"https://api.github.com/repos/m-lab/ndt/releases{/id}","created_at":"2015-04-08T18:54:07Z","updated_at":"2015-05-06T21:54:03Z","pushed_at":"2015-05-06T22:01:08Z","git_url":"git://github.com/m-lab/ndt.git","ssh_url":"git@github.com:m-lab/ndt.git","clone_url":"https://github.com/m-lab/ndt.git","svn_url":"https://github.com/m-lab/ndt","homepage":null,"size":4136,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/m-lab/ndt/pulls/5"},"html":{"href":"https://github.com/m-lab/ndt/pull/5"},"issue":{"href":"https://api.github.com/repos/m-lab/ndt/issues/5"},"comments":{"href":"https://api.github.com/repos/m-lab/ndt/issues/5/comments"},"review_comments":{"href":"https://api.github.com/repos/m-lab/ndt/pulls/5/comments"},"review_comment":{"href":"https://api.github.com/repos/m-lab/ndt/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/m-lab/ndt/pulls/5/commits"},"statuses":{"href":"https://api.github.com/repos/m-lab/ndt/statuses/07c29aa5506a4eaaae5c6dcc097938456f438a26"}}}}