fix session manager concurrency error and error in HTML Checker doFlushNewlines
This commit is contained in:
@@ -420,7 +420,7 @@ func (ht *htmlCheckerImpl) doFlushWhitespace() {
|
|||||||
func (ht *htmlCheckerImpl) doFlushNewlines() {
|
func (ht *htmlCheckerImpl) doFlushNewlines() {
|
||||||
// Measure the number of line breaks we have.
|
// Measure the number of line breaks we have.
|
||||||
lineBreaks, crs := 0, 0
|
lineBreaks, crs := 0, 0
|
||||||
for ch := range []byte(ht.tempBuffer.String()) {
|
for _, ch := range []byte(ht.tempBuffer.String()) {
|
||||||
switch ch {
|
switch ch {
|
||||||
case '\r':
|
case '\r':
|
||||||
crs++
|
crs++
|
||||||
|
|||||||
@@ -229,24 +229,32 @@ func setSessionAnon(session *sessions.Session) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var lastHitMutex sync.Mutex
|
||||||
|
|
||||||
// AmSessionFirstTime initializes the session after it's first created.
|
// AmSessionFirstTime initializes the session after it's first created.
|
||||||
func AmSessionFirstTime(session *sessions.Session) {
|
func AmSessionFirstTime(session *sessions.Session) {
|
||||||
|
lastHitMutex.Lock()
|
||||||
setSessionAnon(session)
|
setSessionAnon(session)
|
||||||
session.Values["lasthit"] = time.Now()
|
session.Values["lasthit"] = time.Now()
|
||||||
|
lastHitMutex.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
// AmResetSession clears the specified session.
|
// AmResetSession clears the specified session.
|
||||||
func AmResetSession(session *sessions.Session) {
|
func AmResetSession(session *sessions.Session) {
|
||||||
|
lastHitMutex.Lock()
|
||||||
for k := range session.Values {
|
for k := range session.Values {
|
||||||
delete(session.Values, k)
|
delete(session.Values, k)
|
||||||
}
|
}
|
||||||
setSessionAnon(session)
|
setSessionAnon(session)
|
||||||
session.Values["lasthit"] = time.Now()
|
session.Values["lasthit"] = time.Now()
|
||||||
|
lastHitMutex.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
// AmHitSession "hits" a session, updating its "last hit" time.
|
// AmHitSession "hits" a session, updating its "last hit" time.
|
||||||
func AmHitSession(session *sessions.Session) {
|
func AmHitSession(session *sessions.Session) {
|
||||||
|
lastHitMutex.Lock()
|
||||||
session.Values["lasthit"] = time.Now()
|
session.Values["lasthit"] = time.Now()
|
||||||
|
lastHitMutex.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
/* AmSessions returns information about the currently active sessions.
|
/* AmSessions returns information about the currently active sessions.
|
||||||
|
|||||||
Reference in New Issue
Block a user