Skip to content

Commit

Permalink
Issue #38 fix WriteDeadline to make it work as expected
Browse files Browse the repository at this point in the history
  • Loading branch information
itomsawyer committed Nov 6, 2017
1 parent 4b471f3 commit 2657f7f
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func (c *Connection) wireWrite(d wiredata) {
// fmt.Printf("WWD01 f:[%v]\n", f)
switch f.Command {
case "\n": // HeartBeat frame
if c.dld.wde && c.dld.dns {
if c.dld.wde && c.dld.wds {
_ = c.netconn.SetWriteDeadline(time.Now().Add(c.dld.wdld))
}
_, e := c.wtr.WriteString(f.Command)
Expand Down Expand Up @@ -147,7 +147,7 @@ func (f *Frame) writeFrame(w *bufio.Writer, c *Connection) error {
}
}

if c.dld.wde && c.dld.dns {
if c.dld.wde && c.dld.wds {
_ = c.netconn.SetWriteDeadline(time.Now().Add(c.dld.wdld))
}

Expand All @@ -161,7 +161,7 @@ func (f *Frame) writeFrame(w *bufio.Writer, c *Connection) error {
// fmt.Println("WRCMD", f.Command)
// Write the frame Headers
for i := 0; i < len(f.Headers); i += 2 {
if c.dld.wde && c.dld.dns {
if c.dld.wde && c.dld.wds {
_ = c.netconn.SetWriteDeadline(time.Now().Add(c.dld.wdld))
}
_, e := w.WriteString(f.Headers[i] + ":" + f.Headers[i+1] + "\n")
Expand All @@ -172,7 +172,7 @@ func (f *Frame) writeFrame(w *bufio.Writer, c *Connection) error {
}

// Write the last Header LF
if c.dld.wde && c.dld.dns {
if c.dld.wde && c.dld.wds {
_ = c.netconn.SetWriteDeadline(time.Now().Add(c.dld.wdld))
}
e = w.WriteByte('\n')
Expand All @@ -189,7 +189,7 @@ func (f *Frame) writeFrame(w *bufio.Writer, c *Connection) error {
return e
}
}
if c.dld.wde && c.dld.dns {
if c.dld.wde && c.dld.wds {
_ = c.netconn.SetWriteDeadline(time.Now().Add(c.dld.wdld))
}
e = w.WriteByte(0)
Expand Down Expand Up @@ -225,7 +225,7 @@ func (c *Connection) writeBody(f *Frame) error {
var n = 0
var e error
for {
if c.dld.wde && c.dld.dns {
if c.dld.wde && c.dld.wds {
_ = c.netconn.SetWriteDeadline(time.Now().Add(c.dld.wdld))
}
n, e = c.wtr.Write(f.Body)
Expand All @@ -239,7 +239,7 @@ func (c *Connection) writeBody(f *Frame) error {
if !c.dld.rfsw {
return e
}
if c.dld.wde && c.dld.dns && isErrorTimeout(e) {
if c.dld.wde && c.dld.wds && isErrorTimeout(e) {
c.log("invoking write deadline callback 2")
c.dld.dlnotify(e, true)
}
Expand Down

0 comments on commit 2657f7f

Please sign in to comment.