Fixed bug introduces by previous commit / refit
authorSebastien Douheret <sebastien.douheret@iot.bzh>
Wed, 29 Nov 2017 14:17:03 +0000 (15:17 +0100)
committerSebastien Douheret <sebastien.douheret@iot.bzh>
Wed, 29 Nov 2017 14:17:03 +0000 (15:17 +0100)
Signed-off-by: Sebastien Douheret <sebastien.douheret@iot.bzh>
lib/xdsserver/sessions.go
lib/xdsserver/webserver.go
lib/xsapiv1/folders.go

index 6da9fd8..c1e7b3b 100644 (file)
@@ -5,7 +5,6 @@ import (
        "strconv"
        "time"
 
        "strconv"
        "time"
 
-       "github.com/Sirupsen/logrus"
        "github.com/gin-gonic/gin"
        "github.com/googollee/go-socket.io"
        uuid "github.com/satori/go.uuid"
        "github.com/gin-gonic/gin"
        "github.com/googollee/go-socket.io"
        uuid "github.com/satori/go.uuid"
@@ -37,12 +36,10 @@ type ClientSession struct {
 // Sessions holds client sessions
 type Sessions struct {
        *Context
 // Sessions holds client sessions
 type Sessions struct {
        *Context
-       cookieMaxAge  int64
-       sessMap       map[string]ClientSession
-       mutex         sync.Mutex
-       log           *logrus.Logger
-       LogLevelSilly bool
-       stop          chan struct{} // signals intentional stop
+       cookieMaxAge int64
+       sessMap      map[string]ClientSession
+       mutex        sync.Mutex
+       stop         chan struct{} // signals intentional stop
 }
 
 // NewClientSessions .
 }
 
 // NewClientSessions .
@@ -174,7 +171,7 @@ func (s *Sessions) newSession(prefix string) *ClientSession {
 
        s.sessMap[se.ID] = se
 
 
        s.sessMap[se.ID] = se
 
-       s.log.Debugf("NEW session (%d): %s", len(s.sessMap), id)
+       s.Log.Debugf("NEW session (%d): %s", len(s.sessMap), id)
        return &se
 }
 
        return &se
 }
 
@@ -200,22 +197,22 @@ func (s *Sessions) monitorSessMap() {
        for {
                select {
                case <-s.stop:
        for {
                select {
                case <-s.stop:
-                       s.log.Debugln("Stop monitorSessMap")
+                       s.Log.Debugln("Stop monitorSessMap")
                        return
                case <-time.After(sessionMonitorTime * time.Second):
                        if s.LogLevelSilly {
                        return
                case <-time.After(sessionMonitorTime * time.Second):
                        if s.LogLevelSilly {
-                               s.log.Debugf("Sessions Map size: %d", len(s.sessMap))
-                               s.log.Debugf("Sessions Map : %v", s.sessMap)
+                               s.Log.Debugf("Sessions Map size: %d", len(s.sessMap))
+                               s.Log.Debugf("Sessions Map : %v", s.sessMap)
                        }
 
                        if len(s.sessMap) > maxSessions {
                        }
 
                        if len(s.sessMap) > maxSessions {
-                               s.log.Errorln("TOO MUCH sessions, cleanup old ones !")
+                               s.Log.Errorln("TOO MUCH sessions, cleanup old ones !")
                        }
 
                        s.mutex.Lock()
                        for _, ss := range s.sessMap {
                                if ss.expireAt.Sub(time.Now()) < 0 {
                        }
 
                        s.mutex.Lock()
                        for _, ss := range s.sessMap {
                                if ss.expireAt.Sub(time.Now()) < 0 {
-                                       s.log.Debugf("Delete expired session id: %s", ss.ID)
+                                       s.Log.Debugf("Delete expired session id: %s", ss.ID)
                                        delete(s.sessMap, ss.ID)
                                }
                        }
                                        delete(s.sessMap, ss.ID)
                                }
                        }
index 0e1676a..ddedd6d 100644 (file)
@@ -47,6 +47,7 @@ func NewWebServer(ctx *Context) *WebServer {
        r := gin.New()
 
        svr := &WebServer{
        r := gin.New()
 
        svr := &WebServer{
+               Context:   ctx,
                router:    r,
                api:       nil,
                sIOServer: nil,
                router:    r,
                api:       nil,
                sIOServer: nil,
index 9506a1d..4a33385 100644 (file)
@@ -58,4 +58,10 @@ type PathMapConfig struct {
 // CloudSyncConfig CloudSync (AKA Syncthing) specific data
 type CloudSyncConfig struct {
        SyncThingID string `json:"syncThingID"`
 // CloudSyncConfig CloudSync (AKA Syncthing) specific data
 type CloudSyncConfig struct {
        SyncThingID string `json:"syncThingID"`
+
+       // Not exported fields (only used internally)
+       STSvrStatus   string `json:"-"`
+       STSvrIsInSync bool   `json:"-"`
+       STLocStatus   string `json:"-"`
+       STLocIsInSync bool   `json:"-"`
 }
 }