You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by mi...@apache.org on 2016/10/28 21:07:06 UTC
[43/50] 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/3c17dab7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/tree/3c17dab7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/diff/3c17dab7
Branch: refs/heads/master
Commit: 3c17dab74725ba7f9aafe8c4124399d8edb1206f
Parents: 044b759
Author: Robert Butts <ro...@gmail.com>
Authored: Fri Oct 21 15:35:51 2016 -0600
Committer: Jeremy Mitchell <mi...@gmail.com>
Committed: Fri Oct 28 15:04:12 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/3c17dab7/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)
+ }
}
}