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

added a lock to startnetworlfollower and stopnetworkfollwer so only one can run at a time

parent 498f079b
Branches
Tags
1 merge request!23Release
...@@ -30,6 +30,7 @@ import ( ...@@ -30,6 +30,7 @@ import (
"gitlab.com/xx_network/crypto/signature/rsa" "gitlab.com/xx_network/crypto/signature/rsa"
"gitlab.com/xx_network/primitives/id" "gitlab.com/xx_network/primitives/id"
"gitlab.com/xx_network/primitives/ndf" "gitlab.com/xx_network/primitives/ndf"
"sync"
"time" "time"
) )
...@@ -65,6 +66,10 @@ type Client struct { ...@@ -65,6 +66,10 @@ type Client struct {
services *serviceProcessiesList services *serviceProcessiesList
clientErrorChannel chan interfaces.ClientError clientErrorChannel chan interfaces.ClientError
//lock to ensure only once instance of stop/start network follower is
//going at a time
followerLock sync.Mutex
} }
// NewClient creates client storage, generates keys, connects, and registers // NewClient creates client storage, generates keys, connects, and registers
...@@ -381,6 +386,8 @@ func (c *Client) initPermissioning(def *ndf.NetworkDefinition) error { ...@@ -381,6 +386,8 @@ func (c *Client) initPermissioning(def *ndf.NetworkDefinition) error {
// - Auth Callback (/auth/callback.go) // - Auth Callback (/auth/callback.go)
// Handles both auth confirm and requests // Handles both auth confirm and requests
func (c *Client) StartNetworkFollower(timeout time.Duration) (<-chan interfaces.ClientError, error) { func (c *Client) StartNetworkFollower(timeout time.Duration) (<-chan interfaces.ClientError, error) {
c.followerLock.Lock()
defer c.followerLock.Unlock()
u := c.GetUser() u := c.GetUser()
jww.INFO.Printf("StartNetworkFollower() \n\tTransmisstionID: %s "+ jww.INFO.Printf("StartNetworkFollower() \n\tTransmisstionID: %s "+
"\n\tReceptionID: %s", u.TransmissionID, u.ReceptionID) "\n\tReceptionID: %s", u.TransmissionID, u.ReceptionID)
...@@ -441,6 +448,8 @@ func (c *Client) StartNetworkFollower(timeout time.Duration) (<-chan interfaces. ...@@ -441,6 +448,8 @@ func (c *Client) StartNetworkFollower(timeout time.Duration) (<-chan interfaces.
// if the network follower is running and this fails, the client object will // if the network follower is running and this fails, the client object will
// most likely be in an unrecoverable state and need to be trashed. // most likely be in an unrecoverable state and need to be trashed.
func (c *Client) StopNetworkFollower() error { func (c *Client) StopNetworkFollower() error {
c.followerLock.Lock()
defer c.followerLock.Unlock()
err := c.status.toStopping() err := c.status.toStopping()
if err != nil { if err != nil {
return errors.WithMessage(err, "Failed to Stop the Network Follower") return errors.WithMessage(err, "Failed to Stop the Network Follower")
......
...@@ -81,7 +81,7 @@ func DefaultPoolParams() PoolParams { ...@@ -81,7 +81,7 @@ func DefaultPoolParams() PoolParams {
p.HostParams.EnableCoolOff = true p.HostParams.EnableCoolOff = true
p.HostParams.NumSendsBeforeCoolOff = 1 p.HostParams.NumSendsBeforeCoolOff = 1
p.HostParams.CoolOffTimeout = 5 * time.Minute p.HostParams.CoolOffTimeout = 5 * time.Minute
p.HostParams.SendTimeout = 3500 * time.Millisecond p.HostParams.SendTimeout = 2000 * time.Millisecond
return p return p
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment