Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-workhorse
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-workhorse
Commits
f06f6858
Commit
f06f6858
authored
Dec 04, 2015
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
X works with go -race under wrk load
parent
caaf8192
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
4 deletions
+11
-4
blob.go
blob.go
+11
-4
No files found.
blob.go
View file @
f06f6858
...
...
@@ -36,6 +36,9 @@ type AuthCacheEntry struct {
// FIXME we need to lock the entry only to "correctly" update Nhit on
// read side but we can tolerate some looses in Nhit and update it
// without mutex or atomic. Only -race complains...
// (we could use atomic.Value for atomic cache entry updates from
// refresher withot need for locks on readers side, but the need to do
// .Nhit++ on readers side ruins that)
sync
.
Mutex
AuthReply
...
...
@@ -55,10 +58,12 @@ type AuthCache struct {
cached
map
[
string
]
*
AuthCacheEntry
}
var
authCache
=
AuthCache
{
}
// XXX make map ?
var
authCache
=
AuthCache
{
cached
:
make
(
map
[
string
]
*
AuthCacheEntry
)}
// XXX u should not be in args?
func
(
c
*
AuthCache
)
VerifyDownloadAccess
(
u
*
upstream
,
project
string
)
AuthReply
{
var
authReply
AuthReply
// first try to read from cache in parallel with other readers
c
.
mu
.
RLock
()
auth
:=
c
.
cached
[
project
]
...
...
@@ -67,7 +72,6 @@ func (c *AuthCache) VerifyDownloadAccess(u *upstream, project string) AuthReply
have_entry
:
// entry in cache - use it
if
auth
!=
nil
{
//have_entry:
<-
auth
.
ready
// make sure it is ready
auth
.
Lock
()
...
...
@@ -76,6 +80,7 @@ have_entry:
// project,
// time.Since(time.Unix(auth.Tauth, 0)),
// auth.Nhit)
authReply
=
auth
.
AuthReply
auth
.
Unlock
()
// no entry - relock the cache in exclusive mode, create empty entry,
...
...
@@ -100,6 +105,8 @@ have_entry:
auth
.
Tauth
=
time
.
Now
()
.
Unix
()
auth
.
Nhit
=
0
authReply
=
auth
.
AuthReply
// broadcast to other goroutines this entry is ready
close
(
auth
.
ready
)
...
...
@@ -107,12 +114,12 @@ have_entry:
go
c
.
refreshEntry
(
auth
,
u
,
project
)
}
return
auth
.
Auth
Reply
return
authReply
}
// Time period for refreshing / removing unused entires in authCache
const
authCacheRefresh
=
10
*
time
.
Second
// XXX 30
const
authCacheRefresh
=
5
*
time
.
Second
// XXX 30
// 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.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment