Browse Source

Merge pull request #14 from LK4D4/fix_race_in_get

Fix racy code in Get
Kamil Kisiel 12 years ago
parent
commit
14f550f51a
1 changed files with 3 additions and 2 deletions
  1. +3
    -2
      context.go

+ 3
- 2
context.go View File

@ -30,9 +30,10 @@ func Set(r *http.Request, key, val interface{}) {
// Get returns a value stored for a given key in a given request.
func Get(r *http.Request, key interface{}) interface{} {
mutex.RLock()
if data[r] != nil {
if ctx := data[r]; ctx != nil {
value := ctx[key]
mutex.RUnlock()
return data[r][key]
return value
}
mutex.RUnlock()
return nil


Loading…
Cancel
Save