crypto/tls: make deleting a missing session cache key a no-op

lruSessionCache.Put is documented to remove the entry for sessionKey
when cs is nil, but it only did so if the key was already in the cache.
Otherwise it inserted an entry with a nil state, evicting the least
recently used entry if the cache was full.

Fixes #79861

Change-Id: Ie9abd6921a1a949f3fa796b63a235790fa42fb87
GitHub-Last-Rev: db2c9b9
GitHub-Pull-Request: #81042
Reviewed-on: https://go-review.googlesource.com/c/go/+/819960
Auto-Submit: Filippo Valsorda <filippo@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
yuhan6665
2026-09-12 20:11:14 -04:00
parent d6e98c8b05
commit 67d0706ea4
+4
View File
@@ -1770,6 +1770,10 @@ func (c *lruSessionCache) Put(sessionKey string, cs *ClientSessionState) {
return
}
if cs == nil {
return
}
if c.q.Len() < c.capacity {
entry := &lruSessionCacheEntry{sessionKey, cs}
c.m[sessionKey] = c.q.PushFront(entry)