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/09/26 20:07:47 UTC
thrift git commit: THRIFT-3855 Replaced complex CompareAndSwapInt64
with syncOnce. Client: Go Paul
Repository: thrift
Updated Branches:
refs/heads/master 1ac0a80aa -> 2df9c20dc
THRIFT-3855 Replaced complex CompareAndSwapInt64 with syncOnce.
Client: Go
Paul <pa...@gmail.com>
This closes #1094
Project: http://git-wip-us.apache.org/repos/asf/thrift/repo
Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/2df9c20d
Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/2df9c20d
Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/2df9c20d
Branch: refs/heads/master
Commit: 2df9c20dc76c044e502861a2111b90cbdcbbb957
Parents: 1ac0a80
Author: Paul <pa...@gmail.com>
Authored: Sat Sep 24 22:47:58 2016 +0300
Committer: Jens Geyer <je...@apache.org>
Committed: Mon Sep 26 22:05:19 2016 +0200
----------------------------------------------------------------------
lib/go/thrift/simple_server.go | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/thrift/blob/2df9c20d/lib/go/thrift/simple_server.go
----------------------------------------------------------------------
diff --git a/lib/go/thrift/simple_server.go b/lib/go/thrift/simple_server.go
index 8c56a4f..4097c4a 100644
--- a/lib/go/thrift/simple_server.go
+++ b/lib/go/thrift/simple_server.go
@@ -22,13 +22,12 @@ package thrift
import (
"log"
"runtime/debug"
- "sync/atomic"
+ "sync"
)
// Simple, non-concurrent server for testing.
type TSimpleServer struct {
quit chan struct{}
- stopped int64
processorFactory TProcessorFactory
serverTransport TServerTransport
@@ -150,11 +149,14 @@ func (p *TSimpleServer) Serve() error {
return nil
}
+var once sync.Once
+
func (p *TSimpleServer) Stop() error {
- if atomic.CompareAndSwapInt64(&p.stopped, 0, 1) {
+ q := func() {
p.quit <- struct{}{}
p.serverTransport.Interrupt()
}
+ once.Do(q)
return nil
}
@@ -186,7 +188,7 @@ func (p *TSimpleServer) processRequests(client TTransport) error {
if err, ok := err.(TApplicationException); ok && err.TypeId() == UNKNOWN_METHOD {
continue
}
- if !ok {
+ if !ok {
break
}
}