{"action":"created","comment":{"url":"https://api.github.com/repos/google/certificate-transparency/pulls/comments/30400141","id":30400141,"diff_hunk":"@@ -0,0 +1,346 @@\n+#ifndef CERT_TRANS_SERVER_SERVER_H_\n+#define CERT_TRANS_SERVER_SERVER_H_\n+\n+#include <chrono>\n+#include <csignal>\n+#include <cstring>\n+#include <functional>\n+#include <gflags/gflags.h>\n+#include <iostream>\n+#include <memory>\n+#include <mutex>\n+#include <openssl/crypto.h>\n+\n+#include \"config.h\"\n+#include \"log/cert_submission_handler.h\"\n+#include \"log/ct_extensions.h\"\n+#include \"log/file_db.h\"\n+#include \"log/file_storage.h\"\n+#include \"log/frontend.h\"\n+#include \"log/frontend_signer.h\"\n+#include \"log/leveldb_db.h\"\n+#include \"log/log_lookup.h\"\n+#include \"log/log_signer.h\"\n+#include \"log/sqlite_db.h\"\n+#include \"log/tree_signer.h\"\n+#include \"monitoring/latency.h\"\n+#include \"monitoring/monitoring.h\"\n+#include \"monitoring/registry.h\"\n+#include \"server/json_output.h\"\n+#include \"server/proxy.h\"\n+#include \"util/etcd.h\"\n+#include \"util/periodic_closure.h\"\n+#include \"util/read_key.h\"\n+#include \"util/status.h\"\n+#include \"util/thread_pool.h\"\n+#include \"util/uuid.h\"\n+\n+DEFINE_int32(node_state_refresh_seconds, 10,\n+             \"How often to refresh the ClusterNodeState entry for this node.\");\n+DEFINE_int32(watchdog_seconds, 120,\n+             \"How many seconds without successfully refreshing this node's \"\n+             \"before firing the watchdog timer.\");\n+DEFINE_bool(watchdog_timeout_is_fatal, true,\n+            \"Exit if the watchdog timer fires.\");\n+\n+namespace cert_trans {\n+\n+Gauge<>* latest_local_tree_size_gauge =\n+    Gauge<>::New(\"latest_local_tree_size\",\n+                 \"Size of latest locally generated STH.\");\n+\n+\n+template <class Logged>\n+class Server {\n+ public:\n+  struct Options {\n+    Options() : port(0), num_http_server_threads(16) {\n+    }\n+\n+    std::string server;\n+    uint16_t port;\n+\n+    std::string etcd_root;\n+\n+    int num_http_server_threads;\n+  };\n+\n+  static void StaticInit();\n+\n+  // Doesn't take ownership of anything.\n+  Server(const Options& opts, std::shared_ptr<libevent::Base> event_base,\n+         Database<Logged>* db, EtcdClient* etcd_client,\n+         UrlFetcher* url_fetcher, LogSigner* log_signer,\n+         CertChecker* cert_checker);\n+  ~Server();\n+\n+  bool IsMaster() const;\n+  MasterElection* election();\n+  ConsistentStore<Logged>* consistent_store();\n+  ClusterStateController<Logged>* cluster_state_controller();\n+  LogLookup<Logged>* log_lookup();\n+\n+  void Initialise();\n+  void Run();\n+\n+\n+ private:\n+  const Options& options_;","path":"cpp/server/server.h","position":88,"original_position":88,"commit_id":"fef966e6f9b16099c9ef07a94cdee748c22f9d6f","original_commit_id":"fef966e6f9b16099c9ef07a94cdee748c22f9d6f","user":{"login":"pphaneuf","id":40400,"avatar_url":"https://avatars.githubusercontent.com/u/40400?v=3","gravatar_id":"","url":"https://api.github.com/users/pphaneuf","html_url":"https://github.com/pphaneuf","followers_url":"https://api.github.com/users/pphaneuf/followers","following_url":"https://api.github.com/users/pphaneuf/following{/other_user}","gists_url":"https://api.github.com/users/pphaneuf/gists{/gist_id}","starred_url":"https://api.github.com/users/pphaneuf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pphaneuf/subscriptions","organizations_url":"https://api.github.com/users/pphaneuf/orgs","repos_url":"https://api.github.com/users/pphaneuf/repos","events_url":"https://api.github.com/users/pphaneuf/events{/privacy}","received_events_url":"https://api.github.com/users/pphaneuf/received_events","type":"User","site_admin":false},"body":"Ah, no, this is quite forbidden! Since the ctor takes a const ref, you might have a reference to a temporary object here, in other words, invalid memory. :wink: ","created_at":"2015-05-15T10:55:19Z","updated_at":"2015-05-15T10:55:19Z","html_url":"https://github.com/google/certificate-transparency/pull/744#discussion_r30400141","pull_request_url":"https://api.github.com/repos/google/certificate-transparency/pulls/744","_links":{"self":{"href":"https://api.github.com/repos/google/certificate-transparency/pulls/comments/30400141"},"html":{"href":"https://github.com/google/certificate-transparency/pull/744#discussion_r30400141"},"pull_request":{"href":"https://api.github.com/repos/google/certificate-transparency/pulls/744"}}},"pull_request":{"url":"https://api.github.com/repos/google/certificate-transparency/pulls/744","id":35336940,"html_url":"https://github.com/google/certificate-transparency/pull/744","diff_url":"https://github.com/google/certificate-transparency/pull/744.diff","patch_url":"https://github.com/google/certificate-transparency/pull/744.patch","issue_url":"https://api.github.com/repos/google/certificate-transparency/issues/744","number":744,"state":"open","locked":false,"title":"Hack out some common servery stuff from ct-server.cc","user":{"login":"AlCutter","id":7648032,"avatar_url":"https://avatars.githubusercontent.com/u/7648032?v=3","gravatar_id":"","url":"https://api.github.com/users/AlCutter","html_url":"https://github.com/AlCutter","followers_url":"https://api.github.com/users/AlCutter/followers","following_url":"https://api.github.com/users/AlCutter/following{/other_user}","gists_url":"https://api.github.com/users/AlCutter/gists{/gist_id}","starred_url":"https://api.github.com/users/AlCutter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AlCutter/subscriptions","organizations_url":"https://api.github.com/users/AlCutter/orgs","repos_url":"https://api.github.com/users/AlCutter/repos","events_url":"https://api.github.com/users/AlCutter/events{/privacy}","received_events_url":"https://api.github.com/users/AlCutter/received_events","type":"User","site_admin":false},"body":"Lots of room for improvement here; this is more of a stepping stone to be able to build a `ct-mirror.cc` without making `#ifdef` soup, but no doubt there'll be more shifting around required.","created_at":"2015-05-13T15:09:58Z","updated_at":"2015-05-15T10:55:20Z","closed_at":null,"merged_at":null,"merge_commit_sha":"90d1dc1e824e968965b8b8c08fce831e94979ed3","assignee":{"login":"pphaneuf","id":40400,"avatar_url":"https://avatars.githubusercontent.com/u/40400?v=3","gravatar_id":"","url":"https://api.github.com/users/pphaneuf","html_url":"https://github.com/pphaneuf","followers_url":"https://api.github.com/users/pphaneuf/followers","following_url":"https://api.github.com/users/pphaneuf/following{/other_user}","gists_url":"https://api.github.com/users/pphaneuf/gists{/gist_id}","starred_url":"https://api.github.com/users/pphaneuf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pphaneuf/subscriptions","organizations_url":"https://api.github.com/users/pphaneuf/orgs","repos_url":"https://api.github.com/users/pphaneuf/repos","events_url":"https://api.github.com/users/pphaneuf/events{/privacy}","received_events_url":"https://api.github.com/users/pphaneuf/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/google/certificate-transparency/pulls/744/commits","review_comments_url":"https://api.github.com/repos/google/certificate-transparency/pulls/744/comments","review_comment_url":"https://api.github.com/repos/google/certificate-transparency/pulls/comments{/number}","comments_url":"https://api.github.com/repos/google/certificate-transparency/issues/744/comments","statuses_url":"https://api.github.com/repos/google/certificate-transparency/statuses/fef966e6f9b16099c9ef07a94cdee748c22f9d6f","head":{"label":"AlCutter:extract_teeth","ref":"extract_teeth","sha":"fef966e6f9b16099c9ef07a94cdee748c22f9d6f","user":{"login":"AlCutter","id":7648032,"avatar_url":"https://avatars.githubusercontent.com/u/7648032?v=3","gravatar_id":"","url":"https://api.github.com/users/AlCutter","html_url":"https://github.com/AlCutter","followers_url":"https://api.github.com/users/AlCutter/followers","following_url":"https://api.github.com/users/AlCutter/following{/other_user}","gists_url":"https://api.github.com/users/AlCutter/gists{/gist_id}","starred_url":"https://api.github.com/users/AlCutter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AlCutter/subscriptions","organizations_url":"https://api.github.com/users/AlCutter/orgs","repos_url":"https://api.github.com/users/AlCutter/repos","events_url":"https://api.github.com/users/AlCutter/events{/privacy}","received_events_url":"https://api.github.com/users/AlCutter/received_events","type":"User","site_admin":false},"repo":{"id":23961092,"name":"certificate-transparency","full_name":"AlCutter/certificate-transparency","owner":{"login":"AlCutter","id":7648032,"avatar_url":"https://avatars.githubusercontent.com/u/7648032?v=3","gravatar_id":"","url":"https://api.github.com/users/AlCutter","html_url":"https://github.com/AlCutter","followers_url":"https://api.github.com/users/AlCutter/followers","following_url":"https://api.github.com/users/AlCutter/following{/other_user}","gists_url":"https://api.github.com/users/AlCutter/gists{/gist_id}","starred_url":"https://api.github.com/users/AlCutter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AlCutter/subscriptions","organizations_url":"https://api.github.com/users/AlCutter/orgs","repos_url":"https://api.github.com/users/AlCutter/repos","events_url":"https://api.github.com/users/AlCutter/events{/privacy}","received_events_url":"https://api.github.com/users/AlCutter/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/AlCutter/certificate-transparency","description":"Auditing for TLS certificates.","fork":true,"url":"https://api.github.com/repos/AlCutter/certificate-transparency","forks_url":"https://api.github.com/repos/AlCutter/certificate-transparency/forks","keys_url":"https://api.github.com/repos/AlCutter/certificate-transparency/keys{/key_id}","collaborators_url":"https://api.github.com/repos/AlCutter/certificate-transparency/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/AlCutter/certificate-transparency/teams","hooks_url":"https://api.github.com/repos/AlCutter/certificate-transparency/hooks","issue_events_url":"https://api.github.com/repos/AlCutter/certificate-transparency/issues/events{/number}","events_url":"https://api.github.com/repos/AlCutter/certificate-transparency/events","assignees_url":"https://api.github.com/repos/AlCutter/certificate-transparency/assignees{/user}","branches_url":"https://api.github.com/repos/AlCutter/certificate-transparency/branches{/branch}","tags_url":"https://api.github.com/repos/AlCutter/certificate-transparency/tags","blobs_url":"https://api.github.com/repos/AlCutter/certificate-transparency/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/AlCutter/certificate-transparency/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/AlCutter/certificate-transparency/git/refs{/sha}","trees_url":"https://api.github.com/repos/AlCutter/certificate-transparency/git/trees{/sha}","statuses_url":"https://api.github.com/repos/AlCutter/certificate-transparency/statuses/{sha}","languages_url":"https://api.github.com/repos/AlCutter/certificate-transparency/languages","stargazers_url":"https://api.github.com/repos/AlCutter/certificate-transparency/stargazers","contributors_url":"https://api.github.com/repos/AlCutter/certificate-transparency/contributors","subscribers_url":"https://api.github.com/repos/AlCutter/certificate-transparency/subscribers","subscription_url":"https://api.github.com/repos/AlCutter/certificate-transparency/subscription","commits_url":"https://api.github.com/repos/AlCutter/certificate-transparency/commits{/sha}","git_commits_url":"https://api.github.com/repos/AlCutter/certificate-transparency/git/commits{/sha}","comments_url":"https://api.github.com/repos/AlCutter/certificate-transparency/comments{/number}","issue_comment_url":"https://api.github.com/repos/AlCutter/certificate-transparency/issues/comments{/number}","contents_url":"https://api.github.com/repos/AlCutter/certificate-transparency/contents/{+path}","compare_url":"https://api.github.com/repos/AlCutter/certificate-transparency/compare/{base}...{head}","merges_url":"https://api.github.com/repos/AlCutter/certificate-transparency/merges","archive_url":"https://api.github.com/repos/AlCutter/certificate-transparency/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/AlCutter/certificate-transparency/downloads","issues_url":"https://api.github.com/repos/AlCutter/certificate-transparency/issues{/number}","pulls_url":"https://api.github.com/repos/AlCutter/certificate-transparency/pulls{/number}","milestones_url":"https://api.github.com/repos/AlCutter/certificate-transparency/milestones{/number}","notifications_url":"https://api.github.com/repos/AlCutter/certificate-transparency/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/AlCutter/certificate-transparency/labels{/name}","releases_url":"https://api.github.com/repos/AlCutter/certificate-transparency/releases{/id}","created_at":"2014-09-12T13:11:02Z","updated_at":"2015-05-07T15:41:29Z","pushed_at":"2015-05-15T10:44:50Z","git_url":"git://github.com/AlCutter/certificate-transparency.git","ssh_url":"git@github.com:AlCutter/certificate-transparency.git","clone_url":"https://github.com/AlCutter/certificate-transparency.git","svn_url":"https://github.com/AlCutter/certificate-transparency","homepage":"http://www.certificate-transparency.org/","size":20884,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"google:master","ref":"master","sha":"4ba5d89cacffd1dce3b0de401680bdb79b6794da","user":{"login":"google","id":1342004,"avatar_url":"https://avatars.githubusercontent.com/u/1342004?v=3","gravatar_id":"","url":"https://api.github.com/users/google","html_url":"https://github.com/google","followers_url":"https://api.github.com/users/google/followers","following_url":"https://api.github.com/users/google/following{/other_user}","gists_url":"https://api.github.com/users/google/gists{/gist_id}","starred_url":"https://api.github.com/users/google/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/google/subscriptions","organizations_url":"https://api.github.com/users/google/orgs","repos_url":"https://api.github.com/users/google/repos","events_url":"https://api.github.com/users/google/events{/privacy}","received_events_url":"https://api.github.com/users/google/received_events","type":"Organization","site_admin":false},"repo":{"id":19989605,"name":"certificate-transparency","full_name":"google/certificate-transparency","owner":{"login":"google","id":1342004,"avatar_url":"https://avatars.githubusercontent.com/u/1342004?v=3","gravatar_id":"","url":"https://api.github.com/users/google","html_url":"https://github.com/google","followers_url":"https://api.github.com/users/google/followers","following_url":"https://api.github.com/users/google/following{/other_user}","gists_url":"https://api.github.com/users/google/gists{/gist_id}","starred_url":"https://api.github.com/users/google/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/google/subscriptions","organizations_url":"https://api.github.com/users/google/orgs","repos_url":"https://api.github.com/users/google/repos","events_url":"https://api.github.com/users/google/events{/privacy}","received_events_url":"https://api.github.com/users/google/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/google/certificate-transparency","description":"Auditing for TLS certificates.","fork":false,"url":"https://api.github.com/repos/google/certificate-transparency","forks_url":"https://api.github.com/repos/google/certificate-transparency/forks","keys_url":"https://api.github.com/repos/google/certificate-transparency/keys{/key_id}","collaborators_url":"https://api.github.com/repos/google/certificate-transparency/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/google/certificate-transparency/teams","hooks_url":"https://api.github.com/repos/google/certificate-transparency/hooks","issue_events_url":"https://api.github.com/repos/google/certificate-transparency/issues/events{/number}","events_url":"https://api.github.com/repos/google/certificate-transparency/events","assignees_url":"https://api.github.com/repos/google/certificate-transparency/assignees{/user}","branches_url":"https://api.github.com/repos/google/certificate-transparency/branches{/branch}","tags_url":"https://api.github.com/repos/google/certificate-transparency/tags","blobs_url":"https://api.github.com/repos/google/certificate-transparency/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/google/certificate-transparency/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/google/certificate-transparency/git/refs{/sha}","trees_url":"https://api.github.com/repos/google/certificate-transparency/git/trees{/sha}","statuses_url":"https://api.github.com/repos/google/certificate-transparency/statuses/{sha}","languages_url":"https://api.github.com/repos/google/certificate-transparency/languages","stargazers_url":"https://api.github.com/repos/google/certificate-transparency/stargazers","contributors_url":"https://api.github.com/repos/google/certificate-transparency/contributors","subscribers_url":"https://api.github.com/repos/google/certificate-transparency/subscribers","subscription_url":"https://api.github.com/repos/google/certificate-transparency/subscription","commits_url":"https://api.github.com/repos/google/certificate-transparency/commits{/sha}","git_commits_url":"https://api.github.com/repos/google/certificate-transparency/git/commits{/sha}","comments_url":"https://api.github.com/repos/google/certificate-transparency/comments{/number}","issue_comment_url":"https://api.github.com/repos/google/certificate-transparency/issues/comments{/number}","contents_url":"https://api.github.com/repos/google/certificate-transparency/contents/{+path}","compare_url":"https://api.github.com/repos/google/certificate-transparency/compare/{base}...{head}","merges_url":"https://api.github.com/repos/google/certificate-transparency/merges","archive_url":"https://api.github.com/repos/google/certificate-transparency/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/google/certificate-transparency/downloads","issues_url":"https://api.github.com/repos/google/certificate-transparency/issues{/number}","pulls_url":"https://api.github.com/repos/google/certificate-transparency/pulls{/number}","milestones_url":"https://api.github.com/repos/google/certificate-transparency/milestones{/number}","notifications_url":"https://api.github.com/repos/google/certificate-transparency/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/google/certificate-transparency/labels{/name}","releases_url":"https://api.github.com/repos/google/certificate-transparency/releases{/id}","created_at":"2014-05-20T17:03:47Z","updated_at":"2015-05-13T18:30:48Z","pushed_at":"2015-05-15T10:44:51Z","git_url":"git://github.com/google/certificate-transparency.git","ssh_url":"git@github.com:google/certificate-transparency.git","clone_url":"https://github.com/google/certificate-transparency.git","svn_url":"https://github.com/google/certificate-transparency","homepage":"http://www.certificate-transparency.org/","size":26187,"stargazers_count":127,"watchers_count":127,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":39,"mirror_url":null,"open_issues_count":44,"forks":39,"open_issues":44,"watchers":127,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/google/certificate-transparency/pulls/744"},"html":{"href":"https://github.com/google/certificate-transparency/pull/744"},"issue":{"href":"https://api.github.com/repos/google/certificate-transparency/issues/744"},"comments":{"href":"https://api.github.com/repos/google/certificate-transparency/issues/744/comments"},"review_comments":{"href":"https://api.github.com/repos/google/certificate-transparency/pulls/744/comments"},"review_comment":{"href":"https://api.github.com/repos/google/certificate-transparency/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/google/certificate-transparency/pulls/744/commits"},"statuses":{"href":"https://api.github.com/repos/google/certificate-transparency/statuses/fef966e6f9b16099c9ef07a94cdee748c22f9d6f"}}}}