Change connection timeout to be float rather than int, allowing for subsecond precision
This commit is contained in:
@@ -91,7 +91,7 @@ const TABLE_MARK = "----"
|
|||||||
|
|
||||||
//Types
|
//Types
|
||||||
type Client struct {
|
type Client struct {
|
||||||
ConnTimoutSecs int
|
ConnTimout float64
|
||||||
ProtocolVersion string
|
ProtocolVersion string
|
||||||
Host string
|
Host string
|
||||||
User string
|
User string
|
||||||
@@ -108,7 +108,7 @@ type SpamDOut struct {
|
|||||||
type FnCallback func(*bufio.Reader) (*SpamDOut, error)
|
type FnCallback func(*bufio.Reader) (*SpamDOut, error)
|
||||||
|
|
||||||
//new instance of Client
|
//new instance of Client
|
||||||
func New(host string, timeout int) *Client {
|
func New(host string, timeout float64) *Client {
|
||||||
return &Client{timeout, PROTOCOL_VERSION, host, ""}
|
return &Client{timeout, PROTOCOL_VERSION, host, ""}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -272,7 +272,7 @@ func (s *Client) call(abort chan bool, cmd string, msgpars []string, onData FnCa
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
// Set connection timeout
|
// Set connection timeout
|
||||||
timeout := time.Now().Add(time.Duration(s.ConnTimoutSecs) * time.Duration(time.Second))
|
timeout := time.Now().Add(time.Duration(s.ConnTimout) * time.Duration(time.Second))
|
||||||
errTimeout := stream.SetDeadline(timeout)
|
errTimeout := stream.SetDeadline(timeout)
|
||||||
if errTimeout != nil {
|
if errTimeout != nil {
|
||||||
err = errors.New("Connection to spamd Timed Out:" + errTimeout.Error())
|
err = errors.New("Connection to spamd Timed Out:" + errTimeout.Error())
|
||||||
|
|||||||
Reference in New Issue
Block a user