brianmario/mysql2 — pull request #505 by dylanahsmith (2014-04-08 07:08:46+00:00)
Title: Fix connect retry on interrupt and connection timeout

Fixes #365

See https://github.com/brianmario/mysql2/issues/365#issuecomment-39786199 for the diagnosis of the issue.

## Solution

Revert pull #254 since it effectively disabled retries on signal interrupts on connect, then fix #189 properly by reducing the connect_timeout by the elapsed time in the Client#connect function.

Currently the time method from the c standard library is used to get the current time. This was chosen for portability, but can be replaced by platform specific functions to get the monotonic time with greater than second precision (e.g. clock_gettime, QueryPerformanceCounter, etc).

## Testing

I tested using https://gist.github.com/dylanahsmith/10047924 to make sure issue #365 was fixed.

To make sure issue #189 was fixed properly, I used https://gist.github.com/dylanahsmith/10069061.