Skip to content

Instantly share code, notes, and snippets.

@methodmissing
Created October 2, 2008 01:48
Show Gist options
  • Select an option

  • Save methodmissing/14252 to your computer and use it in GitHub Desktop.

Select an option

Save methodmissing/14252 to your computer and use it in GitHub Desktop.
static void schedule_query(VALUE obj, VALUE timeout)
{
MYSQL* m = GetHandler(obj);
fd_set read;
timeout = ( NIL_P(timeout) ? m->net.read_timeout : INT2NUM(timeout) );
struct timeval tv = { tv_sec: timeout, tv_usec: 0 };
FD_ZERO(&read);
FD_SET(m->net.fd, &read);
if (rb_thread_select(m->net.fd + 1, &read, NULL, NULL, &tv) < 0) {
rb_raise(eMysql, "query: timeout");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment