This commit is contained in:
insanity 2018-09-18 22:38:20 +09:00
parent aefdb4d724
commit 5f0c3e9fc6
2 changed files with 9 additions and 5 deletions

View File

@ -38,6 +38,7 @@ func processPrepacket(service *omd.Service, pingOption ounp.Option, matchCtx *os
LOOP: LOOP:
for indexR := 0; indexR < pingOption.GetRetry(); indexR++ { for indexR := 0; indexR < pingOption.GetRetry(); indexR++ {
startTime := time.Now()
matchCtx.InitAttribute() matchCtx.InitAttribute()
conn, err := getConnection(service, pingOption) conn, err := getConnection(service, pingOption)
if nil != err { if nil != err {
@ -128,8 +129,9 @@ LOOP:
conn.Close() conn.Close()
if isMatched { if isMatched {
elapsed := time.Since(startTime)
pingResult.Responses[indexR] = &ounp.PingResponse{ pingResult.Responses[indexR] = &ounp.PingResponse{
Time: 0, Time: float32(elapsed),
} }
} }
} }
@ -147,6 +149,7 @@ func processPostpacket(service *omd.Service, pingOption ounp.Option, matchCtx *o
LOOP: LOOP:
for indexR := 0; indexR < pingOption.GetRetry(); indexR++ { for indexR := 0; indexR < pingOption.GetRetry(); indexR++ {
startTime := time.Now()
matchCtx.InitAttribute() matchCtx.InitAttribute()
packetCount := _matcher.PacketCount(matchCtx) packetCount := _matcher.PacketCount(matchCtx)
@ -215,8 +218,9 @@ LOOP:
conn.Close() conn.Close()
if isMatched { if isMatched {
elapsed := time.Since(startTime)
pingResult.Responses[indexR] = &ounp.PingResponse{ pingResult.Responses[indexR] = &ounp.PingResponse{
Time: 0, Time: float32(elapsed),
} }
} }
} }

View File

@ -74,7 +74,7 @@ func Test_processPrepacket(t *testing.T) {
args args args args
want ounp.Result want ounp.Result
}{ }{
// TODO: Add test cases. // TODO: Add test cases.
} }
for _, tt := range tests { for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
@ -97,7 +97,7 @@ func Test_processPostpacket(t *testing.T) {
args args args args
want ounp.Result want ounp.Result
}{ }{
// TODO: Add test cases. // TODO: Add test cases.
} }
for _, tt := range tests { for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
@ -119,7 +119,7 @@ func Test_getConnection(t *testing.T) {
want net.Conn want net.Conn
wantErr bool wantErr bool
}{ }{
// TODO: Add test cases. // TODO: Add test cases.
} }
for _, tt := range tests { for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {