PROTON-1075: Data races detected in go_test_electron.

Removed un-necessary code to drain the Engine.inject channel, the channel is not
buffered so there cannot be anything to drain. Inject also selects on the done
channel so all goroutines waiting to inject will unblock.

Made endpoint.closed() idempotent, fixing the above revealed that it can be
called twice depending on timing.


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/3f4dc74a
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/3f4dc74a
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/3f4dc74a

Branch: refs/heads/go1
Commit: 3f4dc74a4bab7af639a6c8e0bfe4853fb69744dd
Parents: 22c3ee9
Author: Alan Conway <[email protected]>
Authored: Fri Dec 11 12:30:07 2015 -0500
Committer: Alan Conway <[email protected]>
Committed: Fri Dec 11 13:13:30 2015 -0500

----------------------------------------------------------------------
 .../bindings/go/src/qpid.apache.org/electron/endpoint.go | 11 ++++++++---
 .../bindings/go/src/qpid.apache.org/proton/engine.go     |  7 -------
 2 files changed, 8 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3f4dc74a/proton-c/bindings/go/src/qpid.apache.org/electron/endpoint.go
----------------------------------------------------------------------
diff --git a/proton-c/bindings/go/src/qpid.apache.org/electron/endpoint.go 
b/proton-c/bindings/go/src/qpid.apache.org/electron/endpoint.go
index 8cbeadb..2b1f62d 100644
--- a/proton-c/bindings/go/src/qpid.apache.org/electron/endpoint.go
+++ b/proton-c/bindings/go/src/qpid.apache.org/electron/endpoint.go
@@ -73,9 +73,14 @@ func makeEndpoint(s string) endpoint { return endpoint{str: 
s, done: make(chan s
 // Returns the error stored on the endpoint, which may not be different to err 
if there was
 // already a n error
 func (e *endpoint) closed(err error) error {
-       e.err.Set(err)
-       e.err.Set(Closed)
-       close(e.done)
+       select {
+       case <-e.done:
+               // Already closed
+       default:
+               e.err.Set(err)
+               e.err.Set(Closed)
+               close(e.done)
+       }
        return e.err.Get()
 }
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3f4dc74a/proton-c/bindings/go/src/qpid.apache.org/proton/engine.go
----------------------------------------------------------------------
diff --git a/proton-c/bindings/go/src/qpid.apache.org/proton/engine.go 
b/proton-c/bindings/go/src/qpid.apache.org/proton/engine.go
index 2e67ef7..95d70e9 100644
--- a/proton-c/bindings/go/src/qpid.apache.org/proton/engine.go
+++ b/proton-c/bindings/go/src/qpid.apache.org/proton/engine.go
@@ -315,13 +315,6 @@ func (eng *Engine) Run() error {
        wait.Wait()
        close(eng.running) // Signal goroutines have exited and Error is set.
 
-       // Execute any injected functions for side effects on application data 
structures.
-       inject := eng.inject
-       eng.inject = nil // Further calls to Inject() will return an error.
-       for f := range inject {
-               f()
-       }
-
        if !eng.connection.IsNil() {
                eng.connection.Free()
        }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to