Piggy back schedule loop on MYSQL_STATUS_READY
This commit is contained in:
parent
e81e145c15
commit
9d66a3b71e
14
ext/mysql.c
14
ext/mysql.c
@ -938,17 +938,29 @@ static void schedule_query(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) );
|
||||||
|
|
||||||
struct timeval tv = { tv_sec: timeout, tv_usec: 0 };
|
struct timeval tv = { tv_sec: timeout, tv_usec: 0 };
|
||||||
|
|
||||||
|
for(;;){
|
||||||
FD_ZERO(&read);
|
FD_ZERO(&read);
|
||||||
FD_SET(m->net.fd, &read);
|
FD_SET(m->net.fd, &read);
|
||||||
|
|
||||||
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);
|
||||||
|
if (ret < 0) {
|
||||||
rb_raise(eMysql, "query: timeout");
|
rb_raise(eMysql, "query: timeout");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ret == 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m->status == MYSQL_STATUS_READY){
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* async_query(sql,timeout=nil) */
|
/* async_query(sql,timeout=nil) */
|
||||||
|
Loading…
Reference in New Issue
Block a user