@@ -25,11 +25,17 @@ static ID intern_brackets, intern_merge, intern_merge_bang, intern_new_with_args
25
25
rb_raise(cMysql2Error, "MySQL client is not initialized"); \
26
26
}
27
27
28
+ #if defined(HAVE_VIO_IS_CONNECTED )
29
+ my_bool vio_is_connected (Vio * vio );
30
+ #define IO_IS_CONNECTED (wrapper ) vio_is_connected(wrapper->client->net.vio)
31
+ #else
32
+ #define IO_IS_CONNECTED (wrapper )
33
+ #endif
34
+
28
35
#if defined(HAVE_MYSQL_NET_VIO ) || defined(HAVE_ST_NET_VIO )
29
- my_bool vio_is_connected (Vio * vio );
30
- #define CONNECTED (wrapper ) (wrapper->client->net.vio != NULL && wrapper->client->net.fd != -1 && vio_is_connected(wrapper->client->net.vio))
36
+ #define CONNECTED (wrapper ) (wrapper->client->net.vio != NULL && wrapper->client->net.fd != -1 && IO_IS_CONNECTED(wrapper))
31
37
#elif defined(HAVE_MYSQL_NET_PVIO ) || defined(HAVE_ST_NET_PVIO )
32
- #define CONNECTED (wrapper ) (wrapper->client->net.pvio != NULL && wrapper->client->net.fd != -1)
38
+ #define CONNECTED (wrapper ) (wrapper->client->net.pvio != NULL && wrapper->client->net.fd != -1 && IO_IS_CONNECTED(wrapper) )
33
39
#endif
34
40
35
41
#define REQUIRE_CONNECTED (wrapper ) \
@@ -1366,6 +1372,14 @@ static VALUE initialize_ext(VALUE self) {
1366
1372
return self ;
1367
1373
}
1368
1374
1375
+ static VALUE rb_vio_is_connected (VALUE self ) {
1376
+ #if defined(HAVE_VIO_IS_CONNECTED )
1377
+ return Qtrue ;
1378
+ #else
1379
+ return Qfalse ;
1380
+ #endif
1381
+ }
1382
+
1369
1383
/* call-seq: client.prepare # => Mysql2::Statement
1370
1384
*
1371
1385
* Create a new prepared statement.
@@ -1455,6 +1469,8 @@ void init_mysql2_client() {
1455
1469
rb_define_private_method (cMysql2Client , "connect" , rb_mysql_connect , 8 );
1456
1470
rb_define_private_method (cMysql2Client , "_query" , rb_mysql_query , 2 );
1457
1471
1472
+ rb_define_private_method (cMysql2Client , "_vio_is_connected?" , rb_vio_is_connected , 0 );
1473
+
1458
1474
sym_id = ID2SYM (rb_intern ("id" ));
1459
1475
sym_version = ID2SYM (rb_intern ("version" ));
1460
1476
sym_header_version = ID2SYM (rb_intern ("header_version" ));
0 commit comments