Skip to content
Snippets Groups Projects
Commit a3515308 authored by Benjamin Wenger's avatar Benjamin Wenger
Browse files

removed last usage of cleanup stoppers

parent 52611fb1
No related branches found
No related tags found
No related merge requests found
......@@ -18,10 +18,11 @@ import (
)
func startConfirm(sess *storage.Session, c chan message.Receive,
stop *stoppable.Single) {
stop *stoppable.Single, cleanup func()) {
for true {
select {
case <-stop.Quit():
cleanup()
return
case confirmation := <-c:
handleConfirm(sess, confirmation)
......
......@@ -15,7 +15,6 @@ import (
"gitlab.com/elixxir/client/storage"
"gitlab.com/elixxir/client/switchboard"
"gitlab.com/xx_network/primitives/id"
"time"
)
const keyExchangeTriggerName = "KeyExchangeTrigger"
......@@ -32,14 +31,13 @@ func Start(switchboard *switchboard.Switchboard, sess *storage.Session, net inte
// create the trigger stoppable
triggerStop := stoppable.NewSingle(keyExchangeTriggerName)
triggerStopCleanup := stoppable.NewCleanup(triggerStop,
func(duration time.Duration) error {
cleanupTrigger := func(){
switchboard.Unregister(triggerID)
return nil
})
}
// start the trigger thread
go startTrigger(sess, net, triggerCh, triggerStop, params)
go startTrigger(sess, net, triggerCh, triggerStop, params, cleanupTrigger)
//register the rekey confirm thread
confirmCh := make(chan message.Receive, 100)
......@@ -48,18 +46,16 @@ func Start(switchboard *switchboard.Switchboard, sess *storage.Session, net inte
// register the confirm stoppable
confirmStop := stoppable.NewSingle(keyExchangeConfirmName)
confirmStopCleanup := stoppable.NewCleanup(confirmStop,
func(duration time.Duration) error {
cleanupConfirm := func(){
switchboard.Unregister(confirmID)
return nil
})
}
// start the confirm thread
go startConfirm(sess, confirmCh, confirmStop)
go startConfirm(sess, confirmCh, confirmStop, cleanupConfirm)
//bundle the stoppables and return
exchangeStop := stoppable.NewMulti(keyExchangeMulti)
exchangeStop.Add(triggerStopCleanup)
exchangeStop.Add(confirmStopCleanup)
exchangeStop.Add(triggerStop)
exchangeStop.Add(confirmStop)
return exchangeStop
}
......@@ -31,10 +31,11 @@ const (
)
func startTrigger(sess *storage.Session, net interfaces.NetworkManager,
c chan message.Receive, stop *stoppable.Single, params params.Rekey) {
c chan message.Receive, stop *stoppable.Single, params params.Rekey, cleanup func()) {
for true {
select {
case <-stop.Quit():
cleanup()
return
case request := <-c:
go func() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment