{"action":"created","comment":{"url":"https://api.github.com/repos/mholt/caddy/pulls/comments/77608243","id":77608243,"diff_hunk":"@@ -73,9 +82,30 @@ func (h Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error)\n \n \t\t\t// Connect to FastCGI gateway\n \t\t\tnetwork, address := rule.parseAddress()\n-\t\t\tfcgiBackend, err := Dial(network, address)\n-\t\t\tif err != nil {\n-\t\t\t\treturn http.StatusBadGateway, err\n+\n+\t\t\tvar fcgiBackend *FCGIClient\n+\t\t\treuse := false\n+\t\t\tif usePersistentFcgiConnections {\n+\t\t\t\tmetaMutex.Lock()\n+\t\t\t\t// re use connection, if possible\n+\t\t\t\tif _, ok := poorMansSerialisation[network+address]; !ok {\n+\t\t\t\t\tpoorMansSerialisation[network+address] = new(sync.Mutex)\n+\t\t\t\t}\n+\t\t\t\tmetaMutex.Unlock()\n+\n+\t\t\t\tpoorMansSerialisation[network+address].Lock()\n+\t\t\t\tdefer poorMansSerialisation[network+address].Unlock()","path":"caddyhttp/fastcgi/fastcgi.go","position":46,"original_position":46,"commit_id":"3adbe5184ea0ad6946b9c3e22dfb5a24af289143","original_commit_id":"3adbe5184ea0ad6946b9c3e22dfb5a24af289143","user":{"login":"Echsecutor","id":5765579,"avatar_url":"https://avatars.githubusercontent.com/u/5765579?v=3","gravatar_id":"","url":"https://api.github.com/users/Echsecutor","html_url":"https://github.com/Echsecutor","followers_url":"https://api.github.com/users/Echsecutor/followers","following_url":"https://api.github.com/users/Echsecutor/following{/other_user}","gists_url":"https://api.github.com/users/Echsecutor/gists{/gist_id}","starred_url":"https://api.github.com/users/Echsecutor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Echsecutor/subscriptions","organizations_url":"https://api.github.com/users/Echsecutor/orgs","repos_url":"https://api.github.com/users/Echsecutor/repos","events_url":"https://api.github.com/users/Echsecutor/events{/privacy}","received_events_url":"https://api.github.com/users/Echsecutor/received_events","type":"User","site_admin":false},"body":"You are saying that I need to protect locking/unlocking the mutex because it's stored in a map?\r\nIf that's the case my map construction is pretty useless. I will change it.","created_at":"2016-09-06T10:14:07Z","updated_at":"2016-09-06T10:14:07Z","html_url":"https://github.com/mholt/caddy/pull/1087#discussion_r77608243","pull_request_url":"https://api.github.com/repos/mholt/caddy/pulls/1087","_links":{"self":{"href":"https://api.github.com/repos/mholt/caddy/pulls/comments/77608243"},"html":{"href":"https://github.com/mholt/caddy/pull/1087#discussion_r77608243"},"pull_request":{"href":"https://api.github.com/repos/mholt/caddy/pulls/1087"}}},"pull_request":{"url":"https://api.github.com/repos/mholt/caddy/pulls/1087","id":83617381,"html_url":"https://github.com/mholt/caddy/pull/1087","diff_url":"https://github.com/mholt/caddy/pull/1087.diff","patch_url":"https://github.com/mholt/caddy/pull/1087.patch","issue_url":"https://api.github.com/repos/mholt/caddy/issues/1087","number":1087,"state":"open","locked":false,"title":"persistent fastcgi connections","user":{"login":"Echsecutor","id":5765579,"avatar_url":"https://avatars.githubusercontent.com/u/5765579?v=3","gravatar_id":"","url":"https://api.github.com/users/Echsecutor","html_url":"https://github.com/Echsecutor","followers_url":"https://api.github.com/users/Echsecutor/followers","following_url":"https://api.github.com/users/Echsecutor/following{/other_user}","gists_url":"https://api.github.com/users/Echsecutor/gists{/gist_id}","starred_url":"https://api.github.com/users/Echsecutor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Echsecutor/subscriptions","organizations_url":"https://api.github.com/users/Echsecutor/orgs","repos_url":"https://api.github.com/users/Echsecutor/repos","events_url":"https://api.github.com/users/Echsecutor/events{/privacy}","received_events_url":"https://api.github.com/users/Echsecutor/received_events","type":"User","site_admin":false},"body":"This fixes issue https://github.com/mholt/caddy/issues/1082#issuecomment-243919623 .\r\n\r\nfastcgi connections are kept open, but, since the fcgiclient seems to be incapable of demuxing answers, I need to serialize the communication 'by hand'. If someone manages to include fastcgi demuxing, the serialization should be removed.\r\nOn linux, opening new connections didn't take noticeable time, hence here the new system could actually lead to a slowdown, due to serialization.\r\n\r\nIt would hence be nice to have a switch in the Caddy file to switch the persistent but serial fastcgi version provided here on and off. I have included a bool for this switch but did not work my way through the code to find the right spots to implement it. I guess someone familiar with the Caddyfile system can add this in no time.","created_at":"2016-09-01T11:42:43Z","updated_at":"2016-09-06T10:14:07Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f19d3503848e1c42ce128e49dbcfbc658ff0fed9","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/mholt/caddy/pulls/1087/commits","review_comments_url":"https://api.github.com/repos/mholt/caddy/pulls/1087/comments","review_comment_url":"https://api.github.com/repos/mholt/caddy/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mholt/caddy/issues/1087/comments","statuses_url":"https://api.github.com/repos/mholt/caddy/statuses/3adbe5184ea0ad6946b9c3e22dfb5a24af289143","head":{"label":"Echsecutor:pullreq","ref":"pullreq","sha":"3adbe5184ea0ad6946b9c3e22dfb5a24af289143","user":{"login":"Echsecutor","id":5765579,"avatar_url":"https://avatars.githubusercontent.com/u/5765579?v=3","gravatar_id":"","url":"https://api.github.com/users/Echsecutor","html_url":"https://github.com/Echsecutor","followers_url":"https://api.github.com/users/Echsecutor/followers","following_url":"https://api.github.com/users/Echsecutor/following{/other_user}","gists_url":"https://api.github.com/users/Echsecutor/gists{/gist_id}","starred_url":"https://api.github.com/users/Echsecutor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Echsecutor/subscriptions","organizations_url":"https://api.github.com/users/Echsecutor/orgs","repos_url":"https://api.github.com/users/Echsecutor/repos","events_url":"https://api.github.com/users/Echsecutor/events{/privacy}","received_events_url":"https://api.github.com/users/Echsecutor/received_events","type":"User","site_admin":false},"repo":{"id":67014251,"name":"caddy","full_name":"Echsecutor/caddy","owner":{"login":"Echsecutor","id":5765579,"avatar_url":"https://avatars.githubusercontent.com/u/5765579?v=3","gravatar_id":"","url":"https://api.github.com/users/Echsecutor","html_url":"https://github.com/Echsecutor","followers_url":"https://api.github.com/users/Echsecutor/followers","following_url":"https://api.github.com/users/Echsecutor/following{/other_user}","gists_url":"https://api.github.com/users/Echsecutor/gists{/gist_id}","starred_url":"https://api.github.com/users/Echsecutor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Echsecutor/subscriptions","organizations_url":"https://api.github.com/users/Echsecutor/orgs","repos_url":"https://api.github.com/users/Echsecutor/repos","events_url":"https://api.github.com/users/Echsecutor/events{/privacy}","received_events_url":"https://api.github.com/users/Echsecutor/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Echsecutor/caddy","description":"Fast, cross-platform HTTP/2 web server with automatic HTTPS","fork":true,"url":"https://api.github.com/repos/Echsecutor/caddy","forks_url":"https://api.github.com/repos/Echsecutor/caddy/forks","keys_url":"https://api.github.com/repos/Echsecutor/caddy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Echsecutor/caddy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Echsecutor/caddy/teams","hooks_url":"https://api.github.com/repos/Echsecutor/caddy/hooks","issue_events_url":"https://api.github.com/repos/Echsecutor/caddy/issues/events{/number}","events_url":"https://api.github.com/repos/Echsecutor/caddy/events","assignees_url":"https://api.github.com/repos/Echsecutor/caddy/assignees{/user}","branches_url":"https://api.github.com/repos/Echsecutor/caddy/branches{/branch}","tags_url":"https://api.github.com/repos/Echsecutor/caddy/tags","blobs_url":"https://api.github.com/repos/Echsecutor/caddy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Echsecutor/caddy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Echsecutor/caddy/git/refs{/sha}","trees_url":"https://api.github.com/repos/Echsecutor/caddy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Echsecutor/caddy/statuses/{sha}","languages_url":"https://api.github.com/repos/Echsecutor/caddy/languages","stargazers_url":"https://api.github.com/repos/Echsecutor/caddy/stargazers","contributors_url":"https://api.github.com/repos/Echsecutor/caddy/contributors","subscribers_url":"https://api.github.com/repos/Echsecutor/caddy/subscribers","subscription_url":"https://api.github.com/repos/Echsecutor/caddy/subscription","commits_url":"https://api.github.com/repos/Echsecutor/caddy/commits{/sha}","git_commits_url":"https://api.github.com/repos/Echsecutor/caddy/git/commits{/sha}","comments_url":"https://api.github.com/repos/Echsecutor/caddy/comments{/number}","issue_comment_url":"https://api.github.com/repos/Echsecutor/caddy/issues/comments{/number}","contents_url":"https://api.github.com/repos/Echsecutor/caddy/contents/{+path}","compare_url":"https://api.github.com/repos/Echsecutor/caddy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Echsecutor/caddy/merges","archive_url":"https://api.github.com/repos/Echsecutor/caddy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Echsecutor/caddy/downloads","issues_url":"https://api.github.com/repos/Echsecutor/caddy/issues{/number}","pulls_url":"https://api.github.com/repos/Echsecutor/caddy/pulls{/number}","milestones_url":"https://api.github.com/repos/Echsecutor/caddy/milestones{/number}","notifications_url":"https://api.github.com/repos/Echsecutor/caddy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Echsecutor/caddy/labels{/name}","releases_url":"https://api.github.com/repos/Echsecutor/caddy/releases{/id}","deployments_url":"https://api.github.com/repos/Echsecutor/caddy/deployments","created_at":"2016-08-31T07:29:02Z","updated_at":"2016-08-31T07:29:07Z","pushed_at":"2016-09-05T20:37:14Z","git_url":"git://github.com/Echsecutor/caddy.git","ssh_url":"git@github.com:Echsecutor/caddy.git","clone_url":"https://github.com/Echsecutor/caddy.git","svn_url":"https://github.com/Echsecutor/caddy","homepage":"https://caddyserver.com","size":2152,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":true,"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":"mholt:master","ref":"master","sha":"1ea96def314d13fadf78b49bc9a48608105f1791","user":{"login":"mholt","id":1128849,"avatar_url":"https://avatars.githubusercontent.com/u/1128849?v=3","gravatar_id":"","url":"https://api.github.com/users/mholt","html_url":"https://github.com/mholt","followers_url":"https://api.github.com/users/mholt/followers","following_url":"https://api.github.com/users/mholt/following{/other_user}","gists_url":"https://api.github.com/users/mholt/gists{/gist_id}","starred_url":"https://api.github.com/users/mholt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mholt/subscriptions","organizations_url":"https://api.github.com/users/mholt/orgs","repos_url":"https://api.github.com/users/mholt/repos","events_url":"https://api.github.com/users/mholt/events{/privacy}","received_events_url":"https://api.github.com/users/mholt/received_events","type":"User","site_admin":false},"repo":{"id":29207621,"name":"caddy","full_name":"mholt/caddy","owner":{"login":"mholt","id":1128849,"avatar_url":"https://avatars.githubusercontent.com/u/1128849?v=3","gravatar_id":"","url":"https://api.github.com/users/mholt","html_url":"https://github.com/mholt","followers_url":"https://api.github.com/users/mholt/followers","following_url":"https://api.github.com/users/mholt/following{/other_user}","gists_url":"https://api.github.com/users/mholt/gists{/gist_id}","starred_url":"https://api.github.com/users/mholt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mholt/subscriptions","organizations_url":"https://api.github.com/users/mholt/orgs","repos_url":"https://api.github.com/users/mholt/repos","events_url":"https://api.github.com/users/mholt/events{/privacy}","received_events_url":"https://api.github.com/users/mholt/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mholt/caddy","description":"Fast, cross-platform HTTP/2 web server with automatic HTTPS","fork":false,"url":"https://api.github.com/repos/mholt/caddy","forks_url":"https://api.github.com/repos/mholt/caddy/forks","keys_url":"https://api.github.com/repos/mholt/caddy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mholt/caddy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mholt/caddy/teams","hooks_url":"https://api.github.com/repos/mholt/caddy/hooks","issue_events_url":"https://api.github.com/repos/mholt/caddy/issues/events{/number}","events_url":"https://api.github.com/repos/mholt/caddy/events","assignees_url":"https://api.github.com/repos/mholt/caddy/assignees{/user}","branches_url":"https://api.github.com/repos/mholt/caddy/branches{/branch}","tags_url":"https://api.github.com/repos/mholt/caddy/tags","blobs_url":"https://api.github.com/repos/mholt/caddy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mholt/caddy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mholt/caddy/git/refs{/sha}","trees_url":"https://api.github.com/repos/mholt/caddy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mholt/caddy/statuses/{sha}","languages_url":"https://api.github.com/repos/mholt/caddy/languages","stargazers_url":"https://api.github.com/repos/mholt/caddy/stargazers","contributors_url":"https://api.github.com/repos/mholt/caddy/contributors","subscribers_url":"https://api.github.com/repos/mholt/caddy/subscribers","subscription_url":"https://api.github.com/repos/mholt/caddy/subscription","commits_url":"https://api.github.com/repos/mholt/caddy/commits{/sha}","git_commits_url":"https://api.github.com/repos/mholt/caddy/git/commits{/sha}","comments_url":"https://api.github.com/repos/mholt/caddy/comments{/number}","issue_comment_url":"https://api.github.com/repos/mholt/caddy/issues/comments{/number}","contents_url":"https://api.github.com/repos/mholt/caddy/contents/{+path}","compare_url":"https://api.github.com/repos/mholt/caddy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mholt/caddy/merges","archive_url":"https://api.github.com/repos/mholt/caddy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mholt/caddy/downloads","issues_url":"https://api.github.com/repos/mholt/caddy/issues{/number}","pulls_url":"https://api.github.com/repos/mholt/caddy/pulls{/number}","milestones_url":"https://api.github.com/repos/mholt/caddy/milestones{/number}","notifications_url":"https://api.github.com/repos/mholt/caddy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mholt/caddy/labels{/name}","releases_url":"https://api.github.com/repos/mholt/caddy/releases{/id}","deployments_url":"https://api.github.com/repos/mholt/caddy/deployments","created_at":"2015-01-13T19:45:03Z","updated_at":"2016-09-06T07:14:15Z","pushed_at":"2016-09-05T20:37:15Z","git_url":"git://github.com/mholt/caddy.git","ssh_url":"git@github.com:mholt/caddy.git","clone_url":"https://github.com/mholt/caddy.git","svn_url":"https://github.com/mholt/caddy","homepage":"https://caddyserver.com","size":3481,"stargazers_count":7869,"watchers_count":7869,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":501,"mirror_url":null,"open_issues_count":49,"forks":501,"open_issues":49,"watchers":7869,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mholt/caddy/pulls/1087"},"html":{"href":"https://github.com/mholt/caddy/pull/1087"},"issue":{"href":"https://api.github.com/repos/mholt/caddy/issues/1087"},"comments":{"href":"https://api.github.com/repos/mholt/caddy/issues/1087/comments"},"review_comments":{"href":"https://api.github.com/repos/mholt/caddy/pulls/1087/comments"},"review_comment":{"href":"https://api.github.com/repos/mholt/caddy/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mholt/caddy/pulls/1087/commits"},"statuses":{"href":"https://api.github.com/repos/mholt/caddy/statuses/3adbe5184ea0ad6946b9c3e22dfb5a24af289143"}}}}
{"actor":{"display_login":"Echsecutor"}}