Skip to content

Commit

Permalink
Another attempt at working around the EOF issue
Browse files Browse the repository at this point in the history
  • Loading branch information
edsrzf committed Apr 13, 2012
1 parent 943691d commit 7f1a1c6
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions ironmq.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,15 @@ func (c *Client) req(method, endpoint string, body []byte, data interface{}) err

const maxRetries = 5
tries := uint(0)
expectingEOF := false
eofCount := 0
var resp *http.Response
for tries < maxRetries {
resp, err = http.DefaultClient.Do(req)
if expectingEOF && err == io.EOF {
continue
}
if err != nil {
if err == io.EOF && eofCount < 3 {
eofCount++
continue
}
return err
}
// ELB sometimes returns this when load is increasing; we retry
Expand All @@ -93,9 +94,6 @@ func (c *Client) req(method, endpoint string, body []byte, data interface{}) err
delayMs := time.Duration(localRand.Int63n(pow))
time.Sleep(delayMs * time.Millisecond)
req.Body = ioutil.NopCloser(bytes.NewBuffer(body))
// the next retry is expected to fail; issue between Go's
// core library and ELB
expectingEOF = true
continue
}
break
Expand Down

0 comments on commit 7f1a1c6

Please sign in to comment.