@@ -25,11 +25,17 @@ static ID intern_brackets, intern_merge, intern_merge_bang, intern_new_with_args
2525 rb_raise(cMysql2Error, "MySQL client is not initialized"); \
2626 }
2727
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 ) 1
33+ #endif
34+
2835#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))
3137#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) )
3339#endif
3440
3541#define REQUIRE_CONNECTED (wrapper ) \
@@ -1366,6 +1372,14 @@ static VALUE initialize_ext(VALUE self) {
13661372 return self ;
13671373}
13681374
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+
13691383/* call-seq: client.prepare # => Mysql2::Statement
13701384 *
13711385 * Create a new prepared statement.
@@ -1455,6 +1469,8 @@ void init_mysql2_client() {
14551469 rb_define_private_method (cMysql2Client , "connect" , rb_mysql_connect , 8 );
14561470 rb_define_private_method (cMysql2Client , "_query" , rb_mysql_query , 2 );
14571471
1472+ rb_define_private_method (cMysql2Client , "_has_vio_is_connected?" , rb_vio_is_connected , 0 );
1473+
14581474 sym_id = ID2SYM (rb_intern ("id" ));
14591475 sym_version = ID2SYM (rb_intern ("version" ));
14601476 sym_header_version = ID2SYM (rb_intern ("header_version" ));
0 commit comments