Browse Source

refactored service loop

pull/3370/head
Juan Leni 6 years ago
parent
commit
c501305744
No known key found for this signature in database GPG Key ID: 23F1452155140419
1 changed files with 20 additions and 17 deletions
  1. +20
    -17
      privval/signer_listener_endpoint.go

+ 20
- 17
privval/signer_listener_endpoint.go View File

@ -264,27 +264,30 @@ func (sl *SignerListenerEndpoint) serviceLoop() {
select {
case <-sl.connectCh:
{
for {
sl.Logger.Info("Listening for new connection")
conn, err := sl.acceptNewConnection()
if err == nil {
sl.Logger.Info("Connected")
select {
case sl.connectedCh <- conn:
{
sl.Logger.Debug("SignerListenerEndpoint: connection relayed")
}
case <-sl.stopCh:
{
sl.Logger.Debug("SignerListenerEndpoint: stopping")
return
}
sl.Logger.Info("Listening for new connection")
conn, err := sl.acceptNewConnection()
if err == nil {
sl.Logger.Info("Connected")
// We have a good connection, wait for someone that needs one or cancellation
select {
case sl.connectedCh <- conn:
{
sl.Logger.Debug("SignerListenerEndpoint: connection relayed")
}
case <-sl.stopCh:
{
sl.Logger.Debug("SignerListenerEndpoint::serviceLoop Stop")
return
}
}
}
}
select {
case sl.connectCh <- struct{}{}:
default:
}
}
case <-sl.stopCh:
{
sl.Logger.Debug("SignerListenerEndpoint::serviceLoop Stop")


Loading…
Cancel
Save