소스 검색

fixing deadlock

reid 2 년 전
부모
커밋
a86d1a4352
3개의 변경된 파일10개의 추가작업 그리고 2개의 파일을 삭제
  1. 3 1
      auth/auth.go
  2. 5 0
      broadcast/broadcast.go
  3. 2 1
      ws/ws.go

+ 3 - 1
auth/auth.go

@@ -202,9 +202,11 @@ func Hasher(password string) string {
 // check if pw matches sysconfig
 func AuthenticateLogin(password string) bool {
 	conf := config.Conf()
-	if Hasher(password) == conf.PwHash {
+	hash := Hasher(password)
+	if hash == conf.PwHash {
 		return true
 	} else {
+		config.Logger.Warn(fmt.Sprintf("debug: failed pw hash: %v",hash))
 		return false
 	}
 }

+ 5 - 0
broadcast/broadcast.go

@@ -352,11 +352,14 @@ func hostStatusLoop() {
 	for {
 		select {
 		case <-ticker.C:
+			config.Logger.Info("host bstate updating")
 			update := constructSystemInfo()
 			err := UpdateBroadcastState(update)
 			if err != nil {
 				config.Logger.Warn(fmt.Sprintf("Error updating system status: %v", err))
 			}
+			
+			config.Logger.Info("host bstate updated")
 		}
 	}
 }
@@ -367,6 +370,7 @@ func shipStatusLoop() {
 	for {
 		select {
 		case <-ticker.C:
+			config.Logger.Info("ship bstate updating")
 			conf := config.Conf()
 			piers := conf.Piers
 			updates, err := constructPierInfo(piers)
@@ -382,6 +386,7 @@ func shipStatusLoop() {
 				errmsg := fmt.Sprintf("Unable to update ship state: %v", err)
 				config.Logger.Error(errmsg)
 			}
+			config.Logger.Info("ship bstate updated")
 		}
 	}
 }

+ 2 - 1
ws/ws.go

@@ -115,7 +115,7 @@ func WsHandler(w http.ResponseWriter, r *http.Request) {
 	}
 }
 
-// validate password and add to auth session
+// validate password and add to auth session map
 func loginHandler(msg []byte, payload structs.WsPayload) error {
 	config.Logger.Info("Login")
 	now := time.Now().Format("2006-01-02_15:04:05")
@@ -138,6 +138,7 @@ func loginHandler(msg []byte, payload structs.WsPayload) error {
 	return nil
 }
 
+// create tokens for those who have not auth
 func verifyHandler(msg []byte, payload structs.WsPayload, r *http.Request, conn *websocket.Conn) error {
 	config.Logger.Info("Verify")
 	payload.Payload = structs.WsLoginPayload{}