Skip to content
Snippets Groups Projects
Commit 5f7494fb authored by Hans Moog's avatar Hans Moog
Browse files

Fix: fixed shutdown error due to autopeering

parent 75eed018
No related branches found
No related tags found
No related merge requests found
package protocol package protocol
import ( import (
"github.com/iotaledger/goshimmer/plugins/autopeering/instances/outgoingrequest"
"github.com/iotaledger/goshimmer/plugins/autopeering/protocol/types"
"github.com/iotaledger/goshimmer/plugins/autopeering/server/tcp"
"time" "time"
"github.com/iotaledger/goshimmer/packages/timeutil" "github.com/iotaledger/goshimmer/packages/timeutil"
...@@ -10,10 +13,7 @@ import ( ...@@ -10,10 +13,7 @@ import (
"github.com/iotaledger/goshimmer/packages/node" "github.com/iotaledger/goshimmer/packages/node"
"github.com/iotaledger/goshimmer/plugins/autopeering/instances/acceptedneighbors" "github.com/iotaledger/goshimmer/plugins/autopeering/instances/acceptedneighbors"
"github.com/iotaledger/goshimmer/plugins/autopeering/instances/chosenneighbors" "github.com/iotaledger/goshimmer/plugins/autopeering/instances/chosenneighbors"
"github.com/iotaledger/goshimmer/plugins/autopeering/instances/outgoingrequest"
"github.com/iotaledger/goshimmer/plugins/autopeering/protocol/constants" "github.com/iotaledger/goshimmer/plugins/autopeering/protocol/constants"
"github.com/iotaledger/goshimmer/plugins/autopeering/protocol/types"
"github.com/iotaledger/goshimmer/plugins/autopeering/server/tcp"
"github.com/iotaledger/goshimmer/plugins/autopeering/types/peer" "github.com/iotaledger/goshimmer/plugins/autopeering/types/peer"
) )
...@@ -46,14 +46,27 @@ func sendOutgoingRequests(plugin *node.Plugin) { ...@@ -46,14 +46,27 @@ func sendOutgoingRequests(plugin *node.Plugin) {
timeutil.Sleep(5 * time.Second) timeutil.Sleep(5 * time.Second)
if candidateShouldBeContacted(chosenNeighborCandidate) { if candidateShouldBeContacted(chosenNeighborCandidate) {
if dialed, err := chosenNeighborCandidate.Send(outgoingrequest.INSTANCE.Marshal(), types.PROTOCOL_TYPE_TCP, true); err != nil { doneChan := make(chan int, 1)
plugin.LogDebug(err.Error())
} else { go func(doneChan chan int) {
plugin.LogDebug("sent peering request to " + chosenNeighborCandidate.String()) if dialed, err := chosenNeighborCandidate.Send(outgoingrequest.INSTANCE.Marshal(), types.PROTOCOL_TYPE_TCP, true); err != nil {
plugin.LogDebug(err.Error())
} else {
plugin.LogDebug("sent peering request to " + chosenNeighborCandidate.String())
if dialed { if dialed {
tcp.HandleConnection(chosenNeighborCandidate.Conn) tcp.HandleConnection(chosenNeighborCandidate.Conn)
}
} }
close(doneChan)
}(doneChan)
select {
case <-daemon.ShutdownSignal:
return
case <-doneChan:
continue
} }
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment