Skip to content

Commit

Permalink
Random timeouts were caused by brute force retry method not reseting …
Browse files Browse the repository at this point in the history
…retry count between requests. Documented cause of fails.
  • Loading branch information
Ben Sandofsky committed Oct 16, 2009
1 parent 86458ad commit 093449d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions ext/typhoeus/typhoeus_multi.c
Expand Up @@ -75,6 +75,11 @@ static void multi_read_info(VALUE self, CURLM *multi_handle) {
// this next bit is a horrible hack. For some reason my tests against a local server on my laptop
// fail intermittently and return this result number. However, it will succeed if you try it a few
// more times. Also noteworthy is that this doens't happen when hitting an external server. WTF?!

// Sandofsky says:
// This is caused by OS X first attempting to resolve using IPV6.
// Hack solution: connect to yourself with 127.0.0.1, not localhost
// http://curl.haxx.se/mail/tracker-2009-09/0018.html
if (result == 7) {
VALUE max_retries = rb_funcall(easy, rb_intern("max_retries?"), 0);
if (max_retries != Qtrue) {
Expand Down
1 change: 1 addition & 0 deletions lib/typhoeus/easy.rb
Expand Up @@ -185,6 +185,7 @@ def max_retries?
end

def reset
@retries = 0
@response_code = 0
@response_header = ""
@response_body = ""
Expand Down

0 comments on commit 093449d

Please sign in to comment.