Commit d9899658 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent d47b0f9c
Pipeline #136 failed with stage
...@@ -60,6 +60,9 @@ type AuthCache struct { ...@@ -60,6 +60,9 @@ type AuthCache struct {
var authCache = AuthCache{cached: make(map[string]*AuthCacheEntry)} var authCache = AuthCache{cached: make(map[string]*AuthCacheEntry)}
// Verify that download access is ok or not.
// first we try to use the cache; if information is not there -> ask auth backend
// download is ok if AuthReply.RepoPath != ""
// XXX u should not be in args? // XXX u should not be in args?
func (c *AuthCache) VerifyDownloadAccess(u *upstream, project string) AuthReply { func (c *AuthCache) VerifyDownloadAccess(u *upstream, project string) AuthReply {
var authReply AuthReply var authReply AuthReply
...@@ -119,7 +122,7 @@ have_entry: ...@@ -119,7 +122,7 @@ have_entry:
// Time period for refreshing / removing unused entires in authCache // Time period for refreshing / removing unused entires in authCache
const authCacheRefresh = 5 * time.Second // XXX 30 const authCacheRefresh = 30 * time.Second
// Goroutine to refresh auth cache entry periodically while it is used. // Goroutine to refresh auth cache entry periodically while it is used.
// if the entry is detected to be not used - remove it from cache and stop refreshing. // if the entry is detected to be not used - remove it from cache and stop refreshing.
...@@ -191,33 +194,6 @@ func askAuthBackend(u *upstream, project string) AuthReply { ...@@ -191,33 +194,6 @@ func askAuthBackend(u *upstream, project string) AuthReply {
return authReply return authReply
} }
/*
// Verify that download access is ok or not.
// first we try to see authCache; if information is not there -> ask auth backend
// download is ok if AuthReply.RepoPath != ""
// XXX return -> *AuthReply ?
func verifyDownloadAccess(u *upstream, project string) AuthReply {
// XXX lock authCache
auth, ok := authCache[project]
if ok {
auth.Nhit++
//log.Printf("authReply for %v cached ago: %v (hits: %v)",
// project,
// time.Since(time.Unix(auth.Tauth, 0)),
// auth.Nhit)
return auth.AuthReply
}
authReply := askAuthBackend(u, project)
// XXX lock
// store in cache and start cache entry refresher
authCache[project] = &AuthCacheEntry{authReply, time.Now().Unix(), 0}
go authRefreshEntry(u, project)
return authReply
}
*/
func verifyDownloadAccess(u *upstream, project string) AuthReply { func verifyDownloadAccess(u *upstream, project string) AuthReply {
return authCache.VerifyDownloadAccess(u, project) return authCache.VerifyDownloadAccess(u, project)
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment