Skip to content

clientDoDeadline maybe timeout before deadline #1071

@chhquan

Description

@chhquan

client.go clientDoDeadline routinue (G0) raise a routinue (G1) to recive response, and start a new timer according to deadline。G0 will wait for response and timer。But the connection for reading response will timeout before the deadline, because the connection will be set deadline when client's ReadTimeout/WriteTimeout is set.

//func (c *HostClient) doNonNilReqResp(req *Request, resp *Response) (bool, error) {
	if c.WriteTimeout > 0 {
		// Set Deadline every time, since golang has fixed the performance issue
		// See https://github.com/golang/go/issues/15133#issuecomment-271571395 for details
		currentTime := time.Now()
		if err = conn.SetWriteDeadline(currentTime.Add(c.WriteTimeout)); err != nil {
			c.closeConn(cc)
			return true, err
		}
	}

	if c.ReadTimeout > 0 {
		// Set Deadline every time, since golang has fixed the performance issue
		// See https://github.com/golang/go/issues/15133#issuecomment-271571395 for details
		currentTime := time.Now()
		if err = conn.SetReadDeadline(currentTime.Add(c.ReadTimeout)); err != nil {
			c.closeConn(cc)
			return true, err
		}
	}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions