etcdhttp: do message statistics only on valid ones

This commit is contained in:
Yicheng Qin 2014-10-21 17:49:55 -07:00
parent 9ad4a8e33a
commit 3162ead7b1

View File

@ -238,9 +238,6 @@ func (h serverHandler) serveRaft(w http.ResponseWriter, r *http.Request) {
return
}
log.Printf("etcdhttp: raft recv message from %#x: %+v", m.From, m)
if m.Type == raftpb.MsgApp {
h.stats.UpdateRecvApp(m.From, r.ContentLength)
}
if err := h.server.Process(context.TODO(), m); err != nil {
log.Println("etcdhttp: error processing raft message:", err)
switch err {
@ -251,6 +248,9 @@ func (h serverHandler) serveRaft(w http.ResponseWriter, r *http.Request) {
}
return
}
if m.Type == raftpb.MsgApp {
h.stats.UpdateRecvApp(m.From, r.ContentLength)
}
w.WriteHeader(http.StatusNoContent)
}