Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2017-11-21 19:10:47 +0300
committerWinnie Hellmann <winnie@gitlab.com>2017-11-21 22:59:41 +0300
commit86a2b38479b9942314dc698fb3b798a06bd31ed1 (patch)
treee2090398849eac799bff7127c94282f7710a1428 /lib
parenta96a0d707e1077f45f56b7adeb9b69eb01230a56 (diff)
Merge branch 'sh-optimize-read-only-check' into 'master'
Optimize read-only middleware so that it does not consume as much CPU Closes #40185 and gitlab-com/infrastructure#3240 See merge request gitlab-org/gitlab-ce!15504 (cherry picked from commit 6c3398165469de7890cd7881b175858f7c6be8e5) 3c52e2f0 Optimize read-only middleware so that it does not consume as much CPU cba68d33 use `Gitlab::Routing.url_helpers` instead of `Rails.application.routes.url_helpers` 91075c82 check for `read_only?` first before seeing if request is disallowed aeb2f49f Revert "check for `read_only?` first before seeing if request is disallowed"
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/middleware/read_only.rb8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/gitlab/middleware/read_only.rb b/lib/gitlab/middleware/read_only.rb
index 5e4932e4e57..c26656704d7 100644
--- a/lib/gitlab/middleware/read_only.rb
+++ b/lib/gitlab/middleware/read_only.rb
@@ -58,7 +58,7 @@ module Gitlab
end
def last_visited_url
- @env['HTTP_REFERER'] || rack_session['user_return_to'] || Rails.application.routes.url_helpers.root_url
+ @env['HTTP_REFERER'] || rack_session['user_return_to'] || Gitlab::Routing.url_helpers.root_url
end
def route_hash
@@ -74,10 +74,16 @@ module Gitlab
end
def grack_route
+ # Calling route_hash may be expensive. Only do it if we think there's a possible match
+ return false unless request.path.end_with?('.git/git-upload-pack')
+
route_hash[:controller] == 'projects/git_http' && route_hash[:action] == 'git_upload_pack'
end
def lfs_route
+ # Calling route_hash may be expensive. Only do it if we think there's a possible match
+ return false unless request.path.end_with?('/info/lfs/objects/batch')
+
route_hash[:controller] == 'projects/lfs_api' && route_hash[:action] == 'batch'
end
end