From ebcc8b4fbb61b57e9dd28444e534ef5dca2c29bc Mon Sep 17 00:00:00 2001 From: Xi Xue Jia Date: Wed, 7 Dec 2016 08:29:28 +0800 Subject: [PATCH] [FAB-1275] fix peer process doesn't stop issue 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 --- core/committer/noopssinglechain/client.go | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/core/committer/noopssinglechain/client.go b/core/committer/noopssinglechain/client.go index 7d650352233..09c4eb73228 100644 --- a/core/committer/noopssinglechain/client.go +++ b/core/committer/noopssinglechain/client.go @@ -17,7 +17,6 @@ limitations under the License. package noopssinglechain import ( - "sync/atomic" "time" "github.com/golang/protobuf/proto" @@ -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 @@ -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) @@ -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() } @@ -189,8 +182,6 @@ func (d *DeliverService) checkLeaderAndRunDeliver() { if isLeader { d.startDeliver() - } else { - <-d.stopChan } } @@ -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" @@ -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) {