You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by ne...@apache.org on 2016/10/28 20:16:03 UTC

[25/30] incubator-trafficcontrol git commit: Fix TM2 HTTP serving to log write errors

Fix TM2 HTTP serving to log write errors


Project: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/commit/ed20d0a0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/tree/ed20d0a0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/diff/ed20d0a0

Branch: refs/heads/master
Commit: ed20d0a076b7a1235748db6ef168ebd0a8faf747
Parents: 8ee9521
Author: Robert Butts <ro...@gmail.com>
Authored: Fri Oct 21 15:35:51 2016 -0600
Committer: Dave Neuman <ne...@apache.org>
Committed: Fri Oct 28 14:00:36 2016 -0600

----------------------------------------------------------------------
 .../experimental/traffic_monitor/srvhttp/srvhttp.go   | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/ed20d0a0/traffic_monitor/experimental/traffic_monitor/srvhttp/srvhttp.go
----------------------------------------------------------------------
diff --git a/traffic_monitor/experimental/traffic_monitor/srvhttp/srvhttp.go b/traffic_monitor/experimental/traffic_monitor/srvhttp/srvhttp.go
index ebbad03..a1ef6af 100644
--- a/traffic_monitor/experimental/traffic_monitor/srvhttp/srvhttp.go
+++ b/traffic_monitor/experimental/traffic_monitor/srvhttp/srvhttp.go
@@ -138,7 +138,10 @@ func (s Server) Run(f GetDataFunc, addr string, readTimeout time.Duration, write
 	s.stoppableListenerWaitGroup.Add(1)
 	go func() {
 		defer s.stoppableListenerWaitGroup.Done()
-		server.Serve(s.stoppableListener)
+		err := server.Serve(s.stoppableListener)
+		if err != nil {
+			log.Warnf("HTTP server stopped with error: %v\n", err)
+		}
 	}()
 
 	log.Infof("Web server listening on %s", addr)
@@ -284,10 +287,15 @@ func (s Server) dataRequest(w http.ResponseWriter, req *http.Request, t Type, f
 	})
 	if len(data) > 0 {
 		w.WriteHeader(responseCode)
-		w.Write(data)
+		if _, err := w.Write(data); err != nil {
+			log.Warnf("received error writing data request %v: %v\n", t, err)
+		}
+
 	} else {
 		w.WriteHeader(http.StatusInternalServerError)
-		w.Write([]byte("Internal Server Error"))
+		if _, err := w.Write([]byte("Internal Server Error")); err != nil {
+			log.Warnf("received error writing data request %v: %v\n", t, err)
+		}
 	}
 }