fix session manager concurrency error and error in HTML Checker doFlushNewlines

This commit is contained in:
2025-11-05 22:13:49 -07:00
parent 5571a58ea2
commit 2783d94952
2 changed files with 9 additions and 1 deletions
+1 -1
View File
@@ -420,7 +420,7 @@ func (ht *htmlCheckerImpl) doFlushWhitespace() {
func (ht *htmlCheckerImpl) doFlushNewlines() {
// Measure the number of line breaks we have.
lineBreaks, crs := 0, 0
for ch := range []byte(ht.tempBuffer.String()) {
for _, ch := range []byte(ht.tempBuffer.String()) {
switch ch {
case '\r':
crs++
+8
View File
@@ -229,24 +229,32 @@ func setSessionAnon(session *sessions.Session) {
}
}
var lastHitMutex sync.Mutex
// AmSessionFirstTime initializes the session after it's first created.
func AmSessionFirstTime(session *sessions.Session) {
lastHitMutex.Lock()
setSessionAnon(session)
session.Values["lasthit"] = time.Now()
lastHitMutex.Unlock()
}
// AmResetSession clears the specified session.
func AmResetSession(session *sessions.Session) {
lastHitMutex.Lock()
for k := range session.Values {
delete(session.Values, k)
}
setSessionAnon(session)
session.Values["lasthit"] = time.Now()
lastHitMutex.Unlock()
}
// AmHitSession "hits" a session, updating its "last hit" time.
func AmHitSession(session *sessions.Session) {
lastHitMutex.Lock()
session.Values["lasthit"] = time.Now()
lastHitMutex.Unlock()
}
/* AmSessions returns information about the currently active sessions.