You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by je...@apache.org on 2016/07/23 13:15:50 UTC
thrift git commit: THRIFT-3855 In the go simple server,
if Stop() is called multiple times it hangs Client: Go Patch:
ZhiyuYin
Repository: thrift
Updated Branches:
refs/heads/master e1b8540a0 -> 47f9b9d7c
THRIFT-3855 In the go simple server, if Stop() is called multiple times it hangs
Client: Go
Patch: ZhiyuYin <yi...@xiaomi.com>
This closes #1028
Project: http://git-wip-us.apache.org/repos/asf/thrift/repo
Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/47f9b9d7
Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/47f9b9d7
Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/47f9b9d7
Branch: refs/heads/master
Commit: 47f9b9d7c8b449878cada56f20316bbfb7e12301
Parents: e1b8540
Author: ZhiyuYin <yi...@xiaomi.com>
Authored: Thu Jun 16 17:28:42 2016 +0800
Committer: Jens Geyer <je...@apache.org>
Committed: Sat Jul 23 15:15:18 2016 +0200
----------------------------------------------------------------------
lib/go/thrift/simple_server.go | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/thrift/blob/47f9b9d7/lib/go/thrift/simple_server.go
----------------------------------------------------------------------
diff --git a/lib/go/thrift/simple_server.go b/lib/go/thrift/simple_server.go
index a54d804..6b3811e 100644
--- a/lib/go/thrift/simple_server.go
+++ b/lib/go/thrift/simple_server.go
@@ -22,11 +22,13 @@ package thrift
import (
"log"
"runtime/debug"
+ "sync/atomic"
)
// Simple, non-concurrent server for testing.
type TSimpleServer struct {
quit chan struct{}
+ stopped int64
processorFactory TProcessorFactory
serverTransport TServerTransport
@@ -149,8 +151,10 @@ func (p *TSimpleServer) Serve() error {
}
func (p *TSimpleServer) Stop() error {
- p.quit <- struct{}{}
- p.serverTransport.Interrupt()
+ if atomic.CompareAndSwapInt64(&p.stopped, 0, 1) {
+ p.quit <- struct{}{}
+ p.serverTransport.Interrupt()
+ }
return nil
}