Don't spawn goroutines for addPeerLoop, TCP connect timeout of 5 seconds for now

This commit is contained in:
Neil Alexander 2019-09-18 23:44:28 +01:00
parent 64570a8d3e
commit 909e4e29a8
No known key found for this signature in database
GPG Key ID: A02A2019A2BB0944
3 changed files with 8 additions and 11 deletions

View File

@ -91,21 +91,17 @@ func (c *Core) _addPeerLoop() {
// Add peers from the Peers section // Add peers from the Peers section
for _, peer := range current.Peers { for _, peer := range current.Peers {
go func() { if err := c.AddPeer(peer, ""); err != nil {
if err := c.AddPeer(peer, ""); err != nil { c.log.Errorln("Failed to add peer:", err)
c.log.Errorln("Failed to add peer:", err) }
}
}() // TODO: this should be acted and not in a goroutine?
} }
// Add peers from the InterfacePeers section // Add peers from the InterfacePeers section
for intf, intfpeers := range current.InterfacePeers { for intf, intfpeers := range current.InterfacePeers {
for _, peer := range intfpeers { for _, peer := range intfpeers {
go func() { if err := c.AddPeer(peer, intf); err != nil {
if err := c.AddPeer(peer, intf); err != nil { c.log.Errorln("Failed to add peer:", err)
c.log.Errorln("Failed to add peer:", err) }
}
}() // TODO: this should be acted and not in a goroutine?
} }
} }

View File

@ -86,7 +86,7 @@ func (l *link) reconfigure() {
func (l *link) call(uri string, sintf string) error { func (l *link) call(uri string, sintf string) error {
u, err := url.Parse(uri) u, err := url.Parse(uri)
if err != nil { if err != nil {
return fmt.Errorf("peer %s is not correctly formatted (%s)", uri, err) return fmt.Errorf("peer %s is not correctly formatted", uri)
} }
pathtokens := strings.Split(strings.Trim(u.Path, "/"), "/") pathtokens := strings.Split(strings.Trim(u.Path, "/"), "/")
switch u.Scheme { switch u.Scheme {

View File

@ -266,6 +266,7 @@ func (t *tcp) call(saddr string, options interface{}, sintf string) {
} }
dialer := net.Dialer{ dialer := net.Dialer{
Control: t.tcpContext, Control: t.tcpContext,
Timeout: time.Second * 5,
} }
if sintf != "" { if sintf != "" {
ief, err := net.InterfaceByName(sintf) ief, err := net.InterfaceByName(sintf)