retry connect if interrupted by signals
The MySQL client libraries normally retry system calls when interrupted by signals. The lone exception I've found is in the (infrequent) connection setup where it'll propagate the connect(2) syscall error all the way back up to the caller. Fortunately inspection of the MySQL client library reveals it properly preserves the global "errno" variable even with debugging enabled. Note that the net.last_errno member does NOT correspond to the system "errno".
This commit is contained in:
parent
8bfbfa2708
commit
8e81dcb053
@ -1,5 +1,6 @@
|
||||
#include <mysql2_ext.h>
|
||||
#include <client.h>
|
||||
#include <errno.h>
|
||||
|
||||
VALUE cMysql2Client;
|
||||
extern VALUE mMysql2, cMysql2Error;
|
||||
@ -96,10 +97,12 @@ static VALUE nogvl_connect(void *ptr) {
|
||||
struct nogvl_connect_args *args = ptr;
|
||||
MYSQL *client;
|
||||
|
||||
client = mysql_real_connect(args->mysql, args->host,
|
||||
args->user, args->passwd,
|
||||
args->db, args->port, args->unix_socket,
|
||||
args->client_flag);
|
||||
do {
|
||||
client = mysql_real_connect(args->mysql, args->host,
|
||||
args->user, args->passwd,
|
||||
args->db, args->port, args->unix_socket,
|
||||
args->client_flag);
|
||||
} while (! client && errno == EINTR && (errno = 0) == 0);
|
||||
|
||||
return client ? Qtrue : Qfalse;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user