Skip to content

Commit

Permalink
fileLibraryVersion >= common.LibraryVersion
Browse files Browse the repository at this point in the history
  • Loading branch information
Jovis7 committed Dec 11, 2024
1 parent 55789d2 commit 2f2d7e8
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions chained/tls_file_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,18 +64,14 @@ func PersistSessionStates(configDir string) {
})
}

func isSameLibraryVersion(rows []string) bool {
if len(rows) > 0 && strings.HasPrefix(rows[0], libraryVersionString) {
fileLibraryVersion := strings.TrimPrefix(rows[0], libraryVersionString)
log.Debugf("tls_session_states LibraryVersion %v", fileLibraryVersion)
log.Debugf("current LibraryVersion %v", common.LibraryVersion)
if fileLibraryVersion == common.LibraryVersion {
return true
}
} else {
func isSameLibraryVersion(first_row string) bool {
if !strings.HasPrefix(first_row, libraryVersionString) {
log.Debugf("%v string not found in tls_session_states", libraryVersionString)
return false
}
return false
fileLibraryVersion := strings.TrimPrefix(first_row, libraryVersionString)
log.Debugf("tls_session_states file LibraryVersion %v, current LibraryVersion %v", fileLibraryVersion, common.LibraryVersion)
return fileLibraryVersion >= common.LibraryVersion
}

func persistSessionStates(configDir string, saveInterval time.Duration) {
Expand All @@ -85,7 +81,7 @@ func persistSessionStates(configDir string, saveInterval time.Duration) {
if err == nil {
log.Debugf("Initializing current session states from %v", filename)
rows := strings.Split(string(existing), "\n")
if isSameLibraryVersion(rows) {
if len(rows) > 0 && isSameLibraryVersion(rows[0]) { // the first row contains the LibraryVersion
rows = rows[1:] // Remove the first item containing the LibraryVersion
for _, row := range rows {
state, err := parsePersistedState(row)
Expand Down

0 comments on commit 2f2d7e8

Please sign in to comment.