Better performance without the tight loop
This commit is contained in:
parent
3c5dd38037
commit
25a76a4d8b
18
ext/mysql.c
18
ext/mysql.c
@ -827,7 +827,6 @@ static VALUE schedule(VALUE obj, VALUE timeout)
|
|||||||
{
|
{
|
||||||
MYSQL* m = GetHandler(obj);
|
MYSQL* m = GetHandler(obj);
|
||||||
fd_set read;
|
fd_set read;
|
||||||
int ret;
|
|
||||||
|
|
||||||
timeout = ( NIL_P(timeout) ? m->net.read_timeout : INT2NUM(timeout) );
|
timeout = ( NIL_P(timeout) ? m->net.read_timeout : INT2NUM(timeout) );
|
||||||
|
|
||||||
@ -836,20 +835,9 @@ static VALUE schedule(VALUE obj, VALUE timeout)
|
|||||||
FD_ZERO(&read);
|
FD_ZERO(&read);
|
||||||
FD_SET(m->net.fd, &read);
|
FD_SET(m->net.fd, &read);
|
||||||
|
|
||||||
for(;;) {
|
if (rb_thread_select(m->net.fd + 1, &read, NULL, NULL, &tv) < 0) {
|
||||||
ret = rb_thread_select(m->net.fd + 1, &read, NULL, NULL, &tv);
|
rb_raise(eMysql, "query: timeout");
|
||||||
if (ret < 0) {
|
}
|
||||||
rb_raise(eMysql, "query: timeout");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ret == 0) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( vio_poll_read( m->net.vio, INT2NUM(timeout) ) == 0 ) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user