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