Skip to content

Commit

Permalink
[FAB-1275] fix peer process doesn't stop issue
Browse files Browse the repository at this point in the history
https://jira.hyperledger.org/projects/FAB/issues/FAB-1275
peer process doesn't stop if orderer is not started or stopped before peer.
This is caused by block and wait on stopChan

Change-Id: I7e14a25df052b345bb843671f82dc6d32dc490b5
Signed-off-by: Xi Xue Jia <xixuejia@gmail.com>
  • Loading branch information
xixuejia committed Dec 7, 2016
1 parent 71805c9 commit ebcc8b4
Showing 1 changed file with 0 additions and 19 deletions.
19 changes: 0 additions & 19 deletions core/committer/noopssinglechain/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ limitations under the License.
package noopssinglechain

import (
"sync/atomic"
"time"

"github.com/golang/protobuf/proto"
Expand Down Expand Up @@ -62,9 +61,6 @@ type DeliverService struct {
stateProvider state.GossipStateProvider
gossip gossip.Gossip
conn *grpc.ClientConn

stopFlag int32
stopChan chan bool
}

// StopDeliveryService sends stop to the delivery service reference
Expand All @@ -84,7 +80,6 @@ func NewDeliverService(chainID string, address string, grpcServer *grpc.Server)
// Instance of RawLedger
committer: committer.NewLedgerCommitter(kvledger.GetLedger(chainID)),
windowSize: 10,
stopChan: make(chan bool),
}

deliverService.initStateProvider(address, grpcServer)
Expand Down Expand Up @@ -176,9 +171,7 @@ func (d *DeliverService) Start() {

// Stop all service and release resources
func (d *DeliverService) Stop() {
atomic.StoreInt32(&d.stopFlag, 1)
d.stopDeliver()
d.stopChan <- true
d.stateProvider.Stop()
d.gossip.Stop()
}
Expand All @@ -189,8 +182,6 @@ func (d *DeliverService) checkLeaderAndRunDeliver() {

if isLeader {
d.startDeliver()
} else {
<-d.stopChan
}
}

Expand Down Expand Up @@ -219,13 +210,6 @@ func (d *DeliverService) seekLatestFromCommitter(height uint64) error {
})
}

// Internal function to check whenever we need to finish listening
// for new messages to arrive
func (d *DeliverService) isDone() bool {

return atomic.LoadInt32(&d.stopFlag) == 1
}

func isTxValidForVscc(payload *common.Payload, envBytes []byte) error {
// TODO: Extract the VSCC/policy from LCCC as soon as this is ready
vscc := "vscc"
Expand Down Expand Up @@ -278,9 +262,6 @@ func (d *DeliverService) readUntilClose() {
msg, err := d.client.Recv()
if err != nil {
logger.Warningf("Receive error: %s", err.Error())
if d.isDone() {
<-d.stopChan
}
return
}
switch t := msg.Type.(type) {
Expand Down

0 comments on commit ebcc8b4

Please sign in to comment.