Piggy back schedule loop on MYSQL_STATUS_READY
This commit is contained in:
parent
e81e145c15
commit
9d66a3b71e
22
ext/mysql.c
22
ext/mysql.c
@ -938,16 +938,28 @@ 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 };
|
||||||
|
|
||||||
FD_ZERO(&read);
|
for(;;){
|
||||||
FD_SET(m->net.fd, &read);
|
FD_ZERO(&read);
|
||||||
|
FD_SET(m->net.fd, &read);
|
||||||
|
|
||||||
|
ret = rb_thread_select(m->net.fd + 1, &read, NULL, NULL, &tv);
|
||||||
|
if (ret < 0) {
|
||||||
|
rb_raise(eMysql, "query: timeout");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ret == 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (rb_thread_select(m->net.fd + 1, &read, NULL, NULL, &tv) < 0) {
|
if (m->status == MYSQL_STATUS_READY){
|
||||||
rb_raise(eMysql, "query: timeout");
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user