{"action":"created","comment":{"url":"https://api.github.com/repos/cfengine/core/pulls/comments/185757455","pull_request_review_id":117202627,"id":185757455,"diff_hunk":"@@ -609,16 +605,151 @@ int main(int argc, char *argv[])\n         Log(LOG_LEVEL_DEBUG, \"Got report file contents: %s\", config->report);\n     }\n \n-    Log(LOG_LEVEL_INFO, \"Starting server...\");\n+    Log(LOG_LEVEL_INFO, \"Starting server at %s...\", config->address);\n     fflush(stdout); // for debugging startup\n \n-    int r = CFTestD_StartServer(config);\n-    CFTestD_ConfigDestroy(config);\n+    config->ret = CFTestD_StartServer(config);\n \n     /* we don't really need to do this here because the process is about the\n      * terminate, but it's a good way the cleanup actually works and doesn't\n      * cause a segfault or something */\n     ServerTLSDeInitialize(&(config->priv_key), &(config->pub_key), &(config->ssl_ctx));\n \n-    return r;\n+    return NULL;\n+}\n+\n+static void HandleSignal(int signum)\n+{\n+    switch (signum)\n+    {\n+    case SIGTERM:\n+    case SIGINT:\n+        // flush all logging before process ends.\n+        fflush(stdout);\n+        exit(EXIT_FAILURE);\n+        break;\n+    default:\n+        break;\n+    }\n+}\n+\n+/**\n+ * @param ip_str string representation of an IPv4 address (the usual one, with\n+ *               4 numbers separated by dots)\n+ */\n+static char *IncrementIPaddress(const char *ip_str)\n+{\n+    struct in_addr ip;\n+    int ret = inet_aton(ip_str, &ip);\n+    if (ret == 0)\n+    {\n+        Log(LOG_LEVEL_ERR, \"Failed to parse address: '%s'\", ip_str);\n+        return NULL;\n+    }\n+\n+    int step = 1;\n+    char *last_dot = strrchr(ip_str, '.');\n+    if (strcmp(last_dot + 1, \"255\") == 0)\n+    {\n+        /* avoid the network address (ending with 0) */\n+        step = 2;\n+    }\n+    else if (strcmp(last_dot + 1, \"254\") == 0)\n+    {\n+        /* avoid the broadcast address and the network address */\n+        step = 3;\n+    }\n+\n+    uint32_t ip_num = ntohl(ip.s_addr);\n+    ip_num += step;\n+    ip.s_addr = htonl(ip_num);\n+\n+    return xstrdup(inet_ntoa(ip));\n+}\n+\n+int main(int argc, char *argv[])\n+{\n+    signal(SIGINT, HandleSignal);\n+    signal(SIGTERM, HandleSignal);\n+\n+    Log(LOG_LEVEL_VERBOSE, \"Starting cf-testd\");\n+    CryptoInitialize();         /* TODO: remove */\n+    cfnet_init(NULL, NULL);\n+    MakeSignalPipe();\n+\n+    long n_threads = 1;\n+    CFTestD_Config *config = CFTestD_CheckOpts(argc, argv, &n_threads);\n+    if (config->address == NULL)\n+    {\n+        /* default to localhost */\n+        config->address = xstrdup(\"127.0.0.1\");\n+    }\n+\n+    CFTestD_Config **thread_configs = (CFTestD_Config**) xcalloc(n_threads, sizeof(CFTestD_Config*));\n+    for (int i = 0; i < n_threads; i++)\n+    {\n+        thread_configs[i] = (CFTestD_Config*) xmalloc(sizeof(CFTestD_Config));\n+\n+        if (config->report_file != NULL && strstr(config->report_file, \"%d\") != NULL)\n+        {\n+            asprintf(&(thread_configs[i]->report_file), config->report_file, i);","path":"cf-testd/cf-testd.c","position":310,"original_position":224,"commit_id":"4b876ed14c7385a31c1e02001e3f79c1e457f7e0","original_commit_id":"18fa3b3e5b06157539b08548a53ba0ae1746de9c","user":{"login":"olehermanse","id":4048546,"avatar_url":"https://avatars1.githubusercontent.com/u/4048546?v=4","gravatar_id":"","url":"https://api.github.com/users/olehermanse","html_url":"https://github.com/olehermanse","followers_url":"https://api.github.com/users/olehermanse/followers","following_url":"https://api.github.com/users/olehermanse/following{/other_user}","gists_url":"https://api.github.com/users/olehermanse/gists{/gist_id}","starred_url":"https://api.github.com/users/olehermanse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/olehermanse/subscriptions","organizations_url":"https://api.github.com/users/olehermanse/orgs","repos_url":"https://api.github.com/users/olehermanse/repos","events_url":"https://api.github.com/users/olehermanse/events{/privacy}","received_events_url":"https://api.github.com/users/olehermanse/received_events","type":"User","site_admin":false},"body":"This replaces the `%d` in file name with thread number right? Would comment.","created_at":"2018-05-03T10:39:31Z","updated_at":"2018-05-03T10:59:39Z","html_url":"https://github.com/cfengine/core/pull/3103#discussion_r185757455","pull_request_url":"https://api.github.com/repos/cfengine/core/pulls/3103","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/cfengine/core/pulls/comments/185757455"},"html":{"href":"https://github.com/cfengine/core/pull/3103#discussion_r185757455"},"pull_request":{"href":"https://api.github.com/repos/cfengine/core/pulls/3103"}}},"pull_request":{"url":"https://api.github.com/repos/cfengine/core/pulls/3103","id":184620132,"html_url":"https://github.com/cfengine/core/pull/3103","diff_url":"https://github.com/cfengine/core/pull/3103.diff","patch_url":"https://github.com/cfengine/core/pull/3103.patch","issue_url":"https://api.github.com/repos/cfengine/core/issues/3103","number":3103,"state":"open","locked":false,"title":"Parallel cf-testd","user":{"login":"vpodzime","id":1044278,"avatar_url":"https://avatars1.githubusercontent.com/u/1044278?v=4","gravatar_id":"","url":"https://api.github.com/users/vpodzime","html_url":"https://github.com/vpodzime","followers_url":"https://api.github.com/users/vpodzime/followers","following_url":"https://api.github.com/users/vpodzime/following{/other_user}","gists_url":"https://api.github.com/users/vpodzime/gists{/gist_id}","starred_url":"https://api.github.com/users/vpodzime/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vpodzime/subscriptions","organizations_url":"https://api.github.com/users/vpodzime/orgs","repos_url":"https://api.github.com/users/vpodzime/repos","events_url":"https://api.github.com/users/vpodzime/events{/privacy}","received_events_url":"https://api.github.com/users/vpodzime/received_events","type":"User","site_admin":false},"body":"Tested this with 200 threads and everything seems to be working fine.","created_at":"2018-04-27T13:20:01Z","updated_at":"2018-05-03T10:59:40Z","closed_at":null,"merged_at":null,"merge_commit_sha":"37eab728102750ae4a86bf593057d019bd6149b8","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/cfengine/core/pulls/3103/commits","review_comments_url":"https://api.github.com/repos/cfengine/core/pulls/3103/comments","review_comment_url":"https://api.github.com/repos/cfengine/core/pulls/comments{/number}","comments_url":"https://api.github.com/repos/cfengine/core/issues/3103/comments","statuses_url":"https://api.github.com/repos/cfengine/core/statuses/4b876ed14c7385a31c1e02001e3f79c1e457f7e0","head":{"label":"vpodzime:master-cftestd_parallel","ref":"master-cftestd_parallel","sha":"4b876ed14c7385a31c1e02001e3f79c1e457f7e0","user":{"login":"vpodzime","id":1044278,"avatar_url":"https://avatars1.githubusercontent.com/u/1044278?v=4","gravatar_id":"","url":"https://api.github.com/users/vpodzime","html_url":"https://github.com/vpodzime","followers_url":"https://api.github.com/users/vpodzime/followers","following_url":"https://api.github.com/users/vpodzime/following{/other_user}","gists_url":"https://api.github.com/users/vpodzime/gists{/gist_id}","starred_url":"https://api.github.com/users/vpodzime/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vpodzime/subscriptions","organizations_url":"https://api.github.com/users/vpodzime/orgs","repos_url":"https://api.github.com/users/vpodzime/repos","events_url":"https://api.github.com/users/vpodzime/events{/privacy}","received_events_url":"https://api.github.com/users/vpodzime/received_events","type":"User","site_admin":false},"repo":{"id":104935232,"name":"cfengine-core","full_name":"vpodzime/cfengine-core","owner":{"login":"vpodzime","id":1044278,"avatar_url":"https://avatars1.githubusercontent.com/u/1044278?v=4","gravatar_id":"","url":"https://api.github.com/users/vpodzime","html_url":"https://github.com/vpodzime","followers_url":"https://api.github.com/users/vpodzime/followers","following_url":"https://api.github.com/users/vpodzime/following{/other_user}","gists_url":"https://api.github.com/users/vpodzime/gists{/gist_id}","starred_url":"https://api.github.com/users/vpodzime/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vpodzime/subscriptions","organizations_url":"https://api.github.com/users/vpodzime/orgs","repos_url":"https://api.github.com/users/vpodzime/repos","events_url":"https://api.github.com/users/vpodzime/events{/privacy}","received_events_url":"https://api.github.com/users/vpodzime/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/vpodzime/cfengine-core","description":"CFEngine Community","fork":true,"url":"https://api.github.com/repos/vpodzime/cfengine-core","forks_url":"https://api.github.com/repos/vpodzime/cfengine-core/forks","keys_url":"https://api.github.com/repos/vpodzime/cfengine-core/keys{/key_id}","collaborators_url":"https://api.github.com/repos/vpodzime/cfengine-core/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/vpodzime/cfengine-core/teams","hooks_url":"https://api.github.com/repos/vpodzime/cfengine-core/hooks","issue_events_url":"https://api.github.com/repos/vpodzime/cfengine-core/issues/events{/number}","events_url":"https://api.github.com/repos/vpodzime/cfengine-core/events","assignees_url":"https://api.github.com/repos/vpodzime/cfengine-core/assignees{/user}","branches_url":"https://api.github.com/repos/vpodzime/cfengine-core/branches{/branch}","tags_url":"https://api.github.com/repos/vpodzime/cfengine-core/tags","blobs_url":"https://api.github.com/repos/vpodzime/cfengine-core/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/vpodzime/cfengine-core/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/vpodzime/cfengine-core/git/refs{/sha}","trees_url":"https://api.github.com/repos/vpodzime/cfengine-core/git/trees{/sha}","statuses_url":"https://api.github.com/repos/vpodzime/cfengine-core/statuses/{sha}","languages_url":"https://api.github.com/repos/vpodzime/cfengine-core/languages","stargazers_url":"https://api.github.com/repos/vpodzime/cfengine-core/stargazers","contributors_url":"https://api.github.com/repos/vpodzime/cfengine-core/contributors","subscribers_url":"https://api.github.com/repos/vpodzime/cfengine-core/subscribers","subscription_url":"https://api.github.com/repos/vpodzime/cfengine-core/subscription","commits_url":"https://api.github.com/repos/vpodzime/cfengine-core/commits{/sha}","git_commits_url":"https://api.github.com/repos/vpodzime/cfengine-core/git/commits{/sha}","comments_url":"https://api.github.com/repos/vpodzime/cfengine-core/comments{/number}","issue_comment_url":"https://api.github.com/repos/vpodzime/cfengine-core/issues/comments{/number}","contents_url":"https://api.github.com/repos/vpodzime/cfengine-core/contents/{+path}","compare_url":"https://api.github.com/repos/vpodzime/cfengine-core/compare/{base}...{head}","merges_url":"https://api.github.com/repos/vpodzime/cfengine-core/merges","archive_url":"https://api.github.com/repos/vpodzime/cfengine-core/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/vpodzime/cfengine-core/downloads","issues_url":"https://api.github.com/repos/vpodzime/cfengine-core/issues{/number}","pulls_url":"https://api.github.com/repos/vpodzime/cfengine-core/pulls{/number}","milestones_url":"https://api.github.com/repos/vpodzime/cfengine-core/milestones{/number}","notifications_url":"https://api.github.com/repos/vpodzime/cfengine-core/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/vpodzime/cfengine-core/labels{/name}","releases_url":"https://api.github.com/repos/vpodzime/cfengine-core/releases{/id}","deployments_url":"https://api.github.com/repos/vpodzime/cfengine-core/deployments","created_at":"2017-09-26T20:37:17Z","updated_at":"2018-05-01T07:54:32Z","pushed_at":"2018-05-03T09:03:40Z","git_url":"git://github.com/vpodzime/cfengine-core.git","ssh_url":"git@github.com:vpodzime/cfengine-core.git","clone_url":"https://github.com/vpodzime/cfengine-core.git","svn_url":"https://github.com/vpodzime/cfengine-core","homepage":"https://cfengine.com/community/","size":55915,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"cfengine:master","ref":"master","sha":"a59ea0663b2dc64aef54d87c6f7b69ae0e66d12a","user":{"login":"cfengine","id":1239823,"avatar_url":"https://avatars0.githubusercontent.com/u/1239823?v=4","gravatar_id":"","url":"https://api.github.com/users/cfengine","html_url":"https://github.com/cfengine","followers_url":"https://api.github.com/users/cfengine/followers","following_url":"https://api.github.com/users/cfengine/following{/other_user}","gists_url":"https://api.github.com/users/cfengine/gists{/gist_id}","starred_url":"https://api.github.com/users/cfengine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cfengine/subscriptions","organizations_url":"https://api.github.com/users/cfengine/orgs","repos_url":"https://api.github.com/users/cfengine/repos","events_url":"https://api.github.com/users/cfengine/events{/privacy}","received_events_url":"https://api.github.com/users/cfengine/received_events","type":"Organization","site_admin":false},"repo":{"id":3543548,"name":"core","full_name":"cfengine/core","owner":{"login":"cfengine","id":1239823,"avatar_url":"https://avatars0.githubusercontent.com/u/1239823?v=4","gravatar_id":"","url":"https://api.github.com/users/cfengine","html_url":"https://github.com/cfengine","followers_url":"https://api.github.com/users/cfengine/followers","following_url":"https://api.github.com/users/cfengine/following{/other_user}","gists_url":"https://api.github.com/users/cfengine/gists{/gist_id}","starred_url":"https://api.github.com/users/cfengine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cfengine/subscriptions","organizations_url":"https://api.github.com/users/cfengine/orgs","repos_url":"https://api.github.com/users/cfengine/repos","events_url":"https://api.github.com/users/cfengine/events{/privacy}","received_events_url":"https://api.github.com/users/cfengine/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/cfengine/core","description":"CFEngine Community","fork":false,"url":"https://api.github.com/repos/cfengine/core","forks_url":"https://api.github.com/repos/cfengine/core/forks","keys_url":"https://api.github.com/repos/cfengine/core/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cfengine/core/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cfengine/core/teams","hooks_url":"https://api.github.com/repos/cfengine/core/hooks","issue_events_url":"https://api.github.com/repos/cfengine/core/issues/events{/number}","events_url":"https://api.github.com/repos/cfengine/core/events","assignees_url":"https://api.github.com/repos/cfengine/core/assignees{/user}","branches_url":"https://api.github.com/repos/cfengine/core/branches{/branch}","tags_url":"https://api.github.com/repos/cfengine/core/tags","blobs_url":"https://api.github.com/repos/cfengine/core/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cfengine/core/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cfengine/core/git/refs{/sha}","trees_url":"https://api.github.com/repos/cfengine/core/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cfengine/core/statuses/{sha}","languages_url":"https://api.github.com/repos/cfengine/core/languages","stargazers_url":"https://api.github.com/repos/cfengine/core/stargazers","contributors_url":"https://api.github.com/repos/cfengine/core/contributors","subscribers_url":"https://api.github.com/repos/cfengine/core/subscribers","subscription_url":"https://api.github.com/repos/cfengine/core/subscription","commits_url":"https://api.github.com/repos/cfengine/core/commits{/sha}","git_commits_url":"https://api.github.com/repos/cfengine/core/git/commits{/sha}","comments_url":"https://api.github.com/repos/cfengine/core/comments{/number}","issue_comment_url":"https://api.github.com/repos/cfengine/core/issues/comments{/number}","contents_url":"https://api.github.com/repos/cfengine/core/contents/{+path}","compare_url":"https://api.github.com/repos/cfengine/core/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cfengine/core/merges","archive_url":"https://api.github.com/repos/cfengine/core/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cfengine/core/downloads","issues_url":"https://api.github.com/repos/cfengine/core/issues{/number}","pulls_url":"https://api.github.com/repos/cfengine/core/pulls{/number}","milestones_url":"https://api.github.com/repos/cfengine/core/milestones{/number}","notifications_url":"https://api.github.com/repos/cfengine/core/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cfengine/core/labels{/name}","releases_url":"https://api.github.com/repos/cfengine/core/releases{/id}","deployments_url":"https://api.github.com/repos/cfengine/core/deployments","created_at":"2012-02-25T09:19:05Z","updated_at":"2018-05-02T12:27:10Z","pushed_at":"2018-05-03T10:01:23Z","git_url":"git://github.com/cfengine/core.git","ssh_url":"git@github.com:cfengine/core.git","clone_url":"https://github.com/cfengine/core.git","svn_url":"https://github.com/cfengine/core","homepage":"https://cfengine.com/community/","size":55944,"stargazers_count":288,"watchers_count":288,"language":"C","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":170,"mirror_url":null,"archived":false,"open_issues_count":6,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":170,"open_issues":6,"watchers":288,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/cfengine/core/pulls/3103"},"html":{"href":"https://github.com/cfengine/core/pull/3103"},"issue":{"href":"https://api.github.com/repos/cfengine/core/issues/3103"},"comments":{"href":"https://api.github.com/repos/cfengine/core/issues/3103/comments"},"review_comments":{"href":"https://api.github.com/repos/cfengine/core/pulls/3103/comments"},"review_comment":{"href":"https://api.github.com/repos/cfengine/core/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/cfengine/core/pulls/3103/commits"},"statuses":{"href":"https://api.github.com/repos/cfengine/core/statuses/4b876ed14c7385a31c1e02001e3f79c1e457f7e0"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"olehermanse"}}