[前][次][番号順一覧][スレッド一覧]

ruby-changes:73910

From: Samuel <ko1@a...>
Date: Fri, 7 Oct 2022 18:51:56 +0900 (JST)
Subject: [ruby-changes:73910] a081fe76de (master): Simplify default argument specification. (#6507)

https://git.ruby-lang.org/ruby.git/commit/?id=a081fe76de

From a081fe76de5de0307651d99324a0e454fd8b8a8b Mon Sep 17 00:00:00 2001
From: Samuel Williams <samuel.williams@o...>
Date: Fri, 7 Oct 2022 22:51:27 +1300
Subject: Simplify default argument specification. (#6507)

---
 ext/openssl/extconf.rb |  1 -
 ext/openssl/ossl_ssl.c | 14 ++++----------
 include/ruby/io.h      |  5 +++++
 3 files changed, 9 insertions(+), 11 deletions(-)

diff --git a/ext/openssl/extconf.rb b/ext/openssl/extconf.rb
index a856646fe5..cc2b1f8ba2 100644
--- a/ext/openssl/extconf.rb
+++ b/ext/openssl/extconf.rb
@@ -27,7 +27,6 @@ if with_config("debug") or enable_config("debug") https://github.com/ruby/ruby/blob/trunk/ext/openssl/extconf.rb#L27
 end
 
 have_func("rb_io_maybe_wait") # Ruby 3.1
-have_func("rb_io_timeout") # Ruby 3.2
 
 Logging::message "=== Checking for system dependent stuff... ===\n"
 have_library("nsl", "t_open")
diff --git a/ext/openssl/ossl_ssl.c b/ext/openssl/ossl_ssl.c
index 605591efe5..319ba5840e 100644
--- a/ext/openssl/ossl_ssl.c
+++ b/ext/openssl/ossl_ssl.c
@@ -1641,21 +1641,15 @@ no_exception_p(VALUE opts) https://github.com/ruby/ruby/blob/trunk/ext/openssl/ossl_ssl.c#L1641
     return 0;
 }
 
-inline static
-VALUE io_timeout()
-{
-#ifdef HAVE_RB_IO_TIMEOUT
-    return Qundef;
-#else
-    return Qnil;
+#ifndef RB_IO_TIMEOUT_DEFAULT
+#define RB_IO_TIMEOUT_DEFAULT Qnil
 #endif
-}
 
 static void
 io_wait_writable(rb_io_t *fptr)
 {
 #ifdef HAVE_RB_IO_MAYBE_WAIT
-    rb_io_maybe_wait_writable(errno, fptr->self, io_timeout());
+    rb_io_maybe_wait_writable(errno, fptr->self, RB_IO_TIMEOUT_DEFAULT);
 #else
     rb_io_wait_writable(fptr->fd);
 #endif
@@ -1665,7 +1659,7 @@ static void https://github.com/ruby/ruby/blob/trunk/ext/openssl/ossl_ssl.c#L1659
 io_wait_readable(rb_io_t *fptr)
 {
 #ifdef HAVE_RB_IO_MAYBE_WAIT
-    rb_io_maybe_wait_readable(errno, fptr->self, io_timeout());
+    rb_io_maybe_wait_readable(errno, fptr->self, RB_IO_TIMEOUT_DEFAULT);
 #else
     rb_io_wait_readable(fptr->fd);
 #endif
diff --git a/include/ruby/io.h b/include/ruby/io.h
index b91ecd00cb..bb3bb9cd53 100644
--- a/include/ruby/io.h
+++ b/include/ruby/io.h
@@ -58,6 +58,9 @@ https://github.com/ruby/ruby/blob/trunk/include/ruby/io.h#L58
 // IO#wait, IO#wait_readable, IO#wait_writable, IO#wait_priority are defined by this implementation.
 #define RUBY_IO_WAIT_METHODS
 
+// Used as the default timeout argument to `rb_io_wait` to use the `IO#timeout` value.
+#define RUBY_IO_TIMEOUT_DEFAULT Qundef
+
 RBIMPL_SYMBOL_EXPORT_BEGIN()
 
 struct stat;
@@ -884,6 +887,8 @@ VALUE rb_io_set_timeout(VALUE io, VALUE timeout); https://github.com/ruby/ruby/blob/trunk/include/ruby/io.h#L887
  * @param[in]  io                   An IO object to wait.
  * @param[in]  events               See above.
  * @param[in]  timeout              Time, or numeric seconds since UNIX epoch.
+ *                                  If Qnil, wait forever. If Qundef, use the
+ *                                  default timeout.
  * @exception  rb_eIOError          `io` is not open.
  * @exception  rb_eRangeError       `timeout` is out of range.
  * @exception  rb_eSystemCallError  `select(2)` failed for some reason.
-- 
cgit v1.2.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]