13399: Adjust locking strategy to avoid starvation.
[arvados.git] / services / arv-git-httpd / git_handler.go
index f8e38e9516902c679b0ebd54327e011579ac3e76..d9b08a995b3ab1baee6b3a5b33a3f3f9d084e2b6 100644 (file)
@@ -1,3 +1,7 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
 package main
 
 import (
@@ -17,13 +21,18 @@ type gitHandler struct {
 }
 
 func newGitHandler() http.Handler {
+       const glBypass = "GL_BYPASS_ACCESS_CHECKS"
+       const glHome = "GITOLITE_HTTP_HOME"
        var env []string
        path := os.Getenv("PATH")
        if theConfig.GitoliteHome != "" {
                env = append(env,
-                       "GITOLITE_HTTP_HOME="+theConfig.GitoliteHome,
-                       "GL_BYPASS_ACCESS_CHECKS=1")
+                       glHome+"="+theConfig.GitoliteHome,
+                       glBypass+"=1")
                path = path + ":" + theConfig.GitoliteHome + "/bin"
+       } else if home, bypass := os.Getenv(glHome), os.Getenv(glBypass); home != "" || bypass != "" {
+               env = append(env, glHome+"="+home, glBypass+"="+bypass)
+               log.Printf("DEPRECATED: Passing through %s and %s environment variables. Use GitoliteHome configuration instead.", glHome, glBypass)
        }
        env = append(env,
                "GIT_PROJECT_ROOT="+theConfig.RepoRoot,