diff --git a/ext/extconf.rb b/ext/extconf.rb index 9a795d3eb..da8bea8a6 100755 --- a/ext/extconf.rb +++ b/ext/extconf.rb @@ -142,6 +142,7 @@ module PG have_func 'timegm' have_func 'rb_gc_adjust_memory_usage' # since ruby-2.4 have_func 'rb_gc_mark_movable' # since ruby-2.7 +have_func 'rb_io_wait' # since ruby-3.0 # unistd.h confilicts with ruby/win32.h when cross compiling for win32 and ruby 1.9.1 have_header 'unistd.h' diff --git a/ext/pg_connection.c b/ext/pg_connection.c index e3d0397ff..4948da52a 100644 --- a/ext/pg_connection.c +++ b/ext/pg_connection.c @@ -3101,6 +3101,17 @@ pgconn_get_last_result(VALUE self) return rb_pgresult; } +#if !defined(HAVE_RB_IO_WAIT) +#define rb_io_wait(io, event, timeout) do { \ + rb_io_t *fptr; \ + GetOpenFile((io), fptr); \ + if( (event) == RB_INT2NUM(RUBY_IO_READABLE) ) \ + rb_io_wait_readable(fptr->fd); \ + else \ + rb_io_wait_writable(fptr->fd); \ +} while(false) +#endif + /* * call-seq: * conn.discard_results()