You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ac...@apache.org on 2017/11/15 21:05:29 UTC

[05/31] qpid-proton git commit: NO-JIRA: [go] disable go with sanitizer flags, example fixes

NO-JIRA: [go] disable go with sanitizer flags, example fixes

- disable go by default if sanitizer flags are enabled
- restore error handling in client_server example
- use ipv4 in example to avoid problems on ipv6-disabled platforms


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

Branch: refs/heads/go1
Commit: affa7cbf63771829c6fea1404cce8bf4917e51d8
Parents: e479d4c
Author: Alan Conway <ac...@redhat.com>
Authored: Fri Oct 20 16:58:16 2017 +0100
Committer: Alan Conway <ac...@redhat.com>
Committed: Fri Oct 20 17:12:00 2017 +0100

----------------------------------------------------------------------
 CMakeLists.txt                                  |  2 +-
 .../qpid.apache.org/electron/electron_test.go   |  2 +-
 .../electron/example_client_server_test.go      | 24 +++++++++++++++-----
 3 files changed, 20 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/affa7cbf/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 36b1b34..3bec2d1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -174,7 +174,7 @@ endif (ENABLE_VALGRIND)
 option(ENABLE_SANITIZERS "Compile with sanitizers (ASan, UBSan, TSan); incompatible with Valgrind" OFF)
 option(ENABLE_TSAN "Compile with Thread Sanitizer (TSan); incompatible with Valgrind" OFF)
 if (ENABLE_SANITIZERS OR ENABLE_TSAN)
-  set(DISABLE ENABLE_VALGRIND ENABLE_UNDEFINED_ERROR)
+  set(DISABLE ENABLE_VALGRIND ENABLE_UNDEFINED_ERROR BUILD_GO)
   message(STATUS "Building with sanitizers; disables ${DISABLE}")
   foreach(d ${DISABLE})
     set(${d} OFF CACHE BOOL "Disabled to run sanitizers" FORCE)

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/affa7cbf/proton-c/bindings/go/src/qpid.apache.org/electron/electron_test.go
----------------------------------------------------------------------
diff --git a/proton-c/bindings/go/src/qpid.apache.org/electron/electron_test.go b/proton-c/bindings/go/src/qpid.apache.org/electron/electron_test.go
index 294e952..4cd8453 100644
--- a/proton-c/bindings/go/src/qpid.apache.org/electron/electron_test.go
+++ b/proton-c/bindings/go/src/qpid.apache.org/electron/electron_test.go
@@ -59,7 +59,7 @@ func checkEqual(want interface{}, got interface{}) error {
 
 // Start a server, return listening addr and channel for incoming Connections.
 func newServer(t *testing.T, cont Container, opts ...ConnectionOption) (net.Addr, <-chan Connection) {
-	listener, err := net.Listen("tcp", "")
+	listener, err := net.Listen("tcp4", "") // For systems with ipv6 disabled
 	fatalIf(t, err)
 	addr := listener.Addr()
 	ch := make(chan Connection)

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/affa7cbf/proton-c/bindings/go/src/qpid.apache.org/electron/example_client_server_test.go
----------------------------------------------------------------------
diff --git a/proton-c/bindings/go/src/qpid.apache.org/electron/example_client_server_test.go b/proton-c/bindings/go/src/qpid.apache.org/electron/example_client_server_test.go
index 3aa5892..385c865 100644
--- a/proton-c/bindings/go/src/qpid.apache.org/electron/example_client_server_test.go
+++ b/proton-c/bindings/go/src/qpid.apache.org/electron/example_client_server_test.go
@@ -2,6 +2,7 @@ package electron_test
 
 import (
 	"fmt"
+	"log"
 	"net"
 	"qpid.apache.org/amqp"
 	"qpid.apache.org/electron"
@@ -12,8 +13,11 @@ import (
 // and prints messages received until the link closes.
 func Server(l net.Listener) {
 	cont := electron.NewContainer("server")
-	c, _ := cont.Accept(l) // Ignoring error handling
-	l.Close()              // This server only accepts one connection
+	c, err := cont.Accept(l)
+	if err != nil {
+		log.Fatal(err)
+	}
+	l.Close() // This server only accepts one connection
 	// Process incoming endpoints till we get a Receiver link
 	var r electron.Receiver
 	for r == nil {
@@ -51,8 +55,10 @@ func Server(l net.Listener) {
 //     https://github.com/apache/qpid-proton/blob/master/examples/go/README.md
 //
 func Example_clientServer() {
-	// NOTE: We ignoring error handling in this example
-	l, _ := net.Listen("tcp", "") // Open a listening port for server, client connect to this port
+	l, err := net.Listen("tcp", "127.0.0.1:0") // tcp4 so example will work on ipv6-disabled platforms
+	if err != nil {
+		log.Fatal(err)
+	}
 
 	// SERVER: start the server running in a separate goroutine
 	var waitServer sync.WaitGroup // We will wait for the server goroutine to finish before exiting
@@ -64,8 +70,14 @@ func Example_clientServer() {
 
 	// CLIENT: Send messages to the server
 	addr := l.Addr()
-	c, _ := electron.Dial(addr.Network(), addr.String())
-	s, _ := c.Sender()
+	c, err := electron.Dial(addr.Network(), addr.String())
+	if err != nil {
+		log.Fatal(err)
+	}
+	s, err := c.Sender()
+	if err != nil {
+		log.Fatal(err)
+	}
 	for i := 0; i < 3; i++ {
 		msg := fmt.Sprintf("hello %v", i)
 		// Send and wait for the Outcome from the server.


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org