Github user huaiyun commented on a diff in the pull request:
https://github.com/apache/thrift/pull/1028#discussion_r67449308
--- Diff: lib/go/thrift/simple_server.go ---
@@ -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) {
--- End diff --
Actually no ticket, I am sorry.
Itn64 is initialized to 0 automatically. It will be setted to 1 and return
true when 0, return false with no change otherwise.
I want to make the Stop() content actually executed only at the first
calling, when stopped equals to 0, and repeated callings will be skipped.
------------------------------------------------------------------------------------------------------------
å§åï¼å°¹æºå®
çµè¯ï¼13312111858
é®ç®±ï¼[email protected]
å°åï¼åäº¬å¸æµ·æ·åºæ¯çººè·¯58å·å°ç±³æ»å
________________________________
å件人: James E. King, III <[email protected]>
åéæ¶é´: 2016å¹´6æ17æ¥ 8:21
æ¶ä»¶äºº: apache/thrift
æé: å°¹æºå®; Author
主é¢: Re: [apache/thrift] MOD: fix the blocked bug when call Stop() twice
or more (#1028)
In
lib/go/thrift/simple_server.go<https://github.com/apache/thrift/pull/1028#discussion_r67445983>:
> @@ -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) {
Do you want to be checking for a return value of 0 here instead of non-zero?
â
You are receiving this because you authored the thread.
Reply to this email directly, view it on
GitHub<https://github.com/apache/thrift/pull/1028/files/24d16aaaf20c97a944d22551a8a5215d830546c0#r67445983>,
or mute the
thread<https://github.com/notifications/unsubscribe/ATC7PLzGQ5BhZkP583E7Z2k-B8EKZZ8oks5qMehwgaJpZM4I3M67>.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---