Przeglądaj źródła

fixing race issues

Jonathan Turner 7 lat temu
rodzic
commit
2a241e931e
1 zmienionych plików z 2 dodań i 16 usunięć
  1. 2 16
      client/session.go

+ 2 - 16
client/session.go

@@ -36,7 +36,9 @@ func (s *sessions) update(sess *session) {
 		if i != sess {
 			// Session in the sessions cache is not the same as one provided.
 			// Cancel the one in the cache and add this one.
+			i.mux.Lock()
 			i.cancel <- true
+			i.mux.Unlock()
 			s.Entries[sess.realm] = sess
 			return
 		}
@@ -125,22 +127,6 @@ func (s *session) tgtDetails() (string, messages.Ticket, types.EncryptionKey) {
 	return s.realm, s.tgt, s.sessionKey
 }
 
-// copy returns a copy of the session
-func (s *session) copy() session {
-	s.mux.RLock()
-	defer s.mux.RUnlock()
-	sess := session{
-		realm:                s.realm,
-		authTime:             s.authTime,
-		endTime:              s.endTime,
-		renewTill:            s.renewTill,
-		tgt:                  s.tgt,
-		sessionKey:           s.sessionKey,
-		sessionKeyExpiration: s.sessionKeyExpiration,
-	}
-	return sess
-}
-
 // enableAutoSessionRenewal turns on the automatic renewal for the client's TGT session.
 func (cl *Client) enableAutoSessionRenewal(s *session) {
 	var timer *time.Timer