Explorar o código

More debug to reconnect loop

Audrius Butkevicius %!s(int64=10) %!d(string=hai) anos
pai
achega
403583cfbb
Modificáronse 1 ficheiros con 9 adicións e 0 borrados
  1. 9 0
      lib/connections/connections.go

+ 9 - 0
lib/connections/connections.go

@@ -260,12 +260,15 @@ next:
 func (s *connectionSvc) connect() {
 func (s *connectionSvc) connect() {
 	delay := time.Second
 	delay := time.Second
 	for {
 	for {
+		l.Debugln("Reconnect loop")
 	nextDevice:
 	nextDevice:
 		for deviceID, deviceCfg := range s.cfg.Devices() {
 		for deviceID, deviceCfg := range s.cfg.Devices() {
 			if deviceID == s.myID {
 			if deviceID == s.myID {
 				continue
 				continue
 			}
 			}
 
 
+			l.Debugln("Reconnect loop for", deviceID)
+
 			if s.model.IsPaused(deviceID) {
 			if s.model.IsPaused(deviceID) {
 				continue
 				continue
 			}
 			}
@@ -277,6 +280,7 @@ func (s *connectionSvc) connect() {
 			relaysEnabled := s.relaysEnabled
 			relaysEnabled := s.relaysEnabled
 			s.mut.RUnlock()
 			s.mut.RUnlock()
 			if connected && ok && ct.IsDirect() {
 			if connected && ok && ct.IsDirect() {
+				l.Debugln("Already connected to", deviceID, "via", ct.String())
 				continue
 				continue
 			}
 			}
 
 
@@ -284,6 +288,7 @@ func (s *connectionSvc) connect() {
 
 
 			for _, addr := range addrs {
 			for _, addr := range addrs {
 				if conn := s.connectDirect(deviceID, addr); conn != nil {
 				if conn := s.connectDirect(deviceID, addr); conn != nil {
+					l.Debugln("Connectin to", deviceID, "via", addr, "succeeded")
 					if connected {
 					if connected {
 						s.model.Close(deviceID, fmt.Errorf("switching connections"))
 						s.model.Close(deviceID, fmt.Errorf("switching connections"))
 					}
 					}
@@ -292,6 +297,7 @@ func (s *connectionSvc) connect() {
 					}
 					}
 					continue nextDevice
 					continue nextDevice
 				}
 				}
+				l.Debugln("Connectin to", deviceID, "via", addr, "failed")
 			}
 			}
 
 
 			// Only connect via relays if not already connected
 			// Only connect via relays if not already connected
@@ -300,6 +306,7 @@ func (s *connectionSvc) connect() {
 			// wait up to RelayReconnectIntervalM to connect again.
 			// wait up to RelayReconnectIntervalM to connect again.
 			// Also, do not try relays if we are explicitly told not to.
 			// Also, do not try relays if we are explicitly told not to.
 			if connected || len(relays) == 0 || !relaysEnabled {
 			if connected || len(relays) == 0 || !relaysEnabled {
+				l.Debugln("Not connecting via relay", connected, len(relays) == 0, !relaysEnabled)
 				continue nextDevice
 				continue nextDevice
 			}
 			}
 
 
@@ -315,11 +322,13 @@ func (s *connectionSvc) connect() {
 
 
 			for _, addr := range relays {
 			for _, addr := range relays {
 				if conn := s.connectViaRelay(deviceID, addr); conn != nil {
 				if conn := s.connectViaRelay(deviceID, addr); conn != nil {
+					l.Debugln("Connectin to", deviceID, "via", addr, "succeeded")
 					s.conns <- model.IntermediateConnection{
 					s.conns <- model.IntermediateConnection{
 						conn, model.ConnectionTypeRelayDial,
 						conn, model.ConnectionTypeRelayDial,
 					}
 					}
 					continue nextDevice
 					continue nextDevice
 				}
 				}
+				l.Debugln("Connectin to", deviceID, "via", addr, "failed")
 			}
 			}
 		}
 		}