Skip to content

Commit d001b5e

Browse files
committed
remove read timeout, use global
1 parent 1dafbf4 commit d001b5e

3 files changed

Lines changed: 16 additions & 21 deletions

File tree

cmd/root.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ func init() {
9797
rootCmd.Flags().Uint16VarP(&clientConfig.TargetPort, "target-port", "p", 0, "target port")
9898
rootCmd.Flags().StringVarP(&clientConfig.Message, "message", "m", "defaultmessage", "message to send")
9999
rootCmd.Flags().UintVarP(&clientConfig.Timeout, "timeout", "t", 2000, "timeout in ms")
100-
rootCmd.Flags().UintVarP(&clientConfig.ReadTimeout, "read-timeout", "", 1500, "response read timeout in ms (tcp only)")
101100
rootCmd.Flags().UintVarP(&clientConfig.Attempts, "attempts", "r", 1, "number of attempts, successful or not")
102101
rootCmd.Flags().UintVar(&clientConfig.Period, "period", 5000, "send a new message every <period> ms")
103102
rootCmd.Flags().UintVar(&clientConfig.SuccThrPec, "success-threshold", 80, "percentage of successful attempts needed")

pkg/config/config.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ type Config struct {
2222
TargetPort uint16
2323
Message string
2424
Timeout uint
25-
ReadTimeout uint
2625
Attempts uint
2726
Period uint
2827
SuccThrPec uint

pkg/conntester/conntester.go

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,14 @@ var ErrTestFailed = errors.New("test failed")
2020

2121
// ConnTester performs connections against a certain destination
2222
type ConnTester struct {
23-
protocol string
24-
targetHost string
25-
targetPort uint16
26-
message string
27-
timeout uint
28-
readTimeout uint
29-
attempts uint
30-
period uint
31-
succThrPec uint
23+
protocol string
24+
targetHost string
25+
targetPort uint16
26+
message string
27+
timeout uint
28+
attempts uint
29+
period uint
30+
succThrPec uint
3231

3332
logger *log.Logger
3433

@@ -46,15 +45,14 @@ func New(config *config.Config, logger *log.Logger) (*ConnTester, error) {
4645
}
4746

4847
ct := &ConnTester{
49-
protocol: config.Protocol,
50-
targetHost: config.TargetHost,
51-
targetPort: config.TargetPort,
52-
message: config.Message,
53-
timeout: config.Timeout,
54-
readTimeout: config.ReadTimeout,
55-
attempts: config.Attempts,
56-
period: config.Period,
57-
succThrPec: config.SuccThrPec,
48+
protocol: config.Protocol,
49+
targetHost: config.TargetHost,
50+
targetPort: config.TargetPort,
51+
message: config.Message,
52+
timeout: config.Timeout,
53+
attempts: config.Attempts,
54+
period: config.Period,
55+
succThrPec: config.SuccThrPec,
5856
}
5957
ct.logger = logger
6058
return ct, nil
@@ -143,7 +141,6 @@ func (c *ConnTester) send(ctx context.Context, wg *sync.WaitGroup) {
143141
c.logger.Info("TCP FIN packet sent, writing side closed")
144142
}
145143

146-
conn.SetReadDeadline(time.Now().Add(time.Duration(c.readTimeout) * time.Millisecond))
147144
_, err = io.Copy(io.Discard, conn)
148145
if err != nil && err != io.EOF {
149146
c.logger.Info(fmt.Sprintf("stopped discarding data from %s: %s", dstEndpoint, err))

0 commit comments

Comments
 (0)