diff options
| author | Kazuki Yamaguchi <k@rhe.jp> | 2025-12-08 00:55:15 +0900 |
|---|---|---|
| committer | git <svn-admin@ruby-lang.org> | 2026-01-23 16:41:17 +0000 |
| commit | 0fddb9afcac8d68da07a24a2db3763e237f59a22 (patch) | |
| tree | bba1f8bb330dd0fd18f1bca2add3ce5817b52d57 | |
| parent | 0379aab6c0f345908e03868ced03936c07b7651a (diff) | |
[ruby/openssl] ssl: refactor peeraddr_ip_str()
Remove an unnecessary instance variable lookup and constant lookup.
Ruby's public headers provide rb_eSystemCallError.
https://github.com/ruby/openssl/commit/46c92233fb
| -rw-r--r-- | ext/openssl/ossl_ssl.c | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/ext/openssl/ossl_ssl.c b/ext/openssl/ossl_ssl.c index f7292520e3..c6dec32a9e 100644 --- a/ext/openssl/ossl_ssl.c +++ b/ext/openssl/ossl_ssl.c @@ -1590,26 +1590,24 @@ ossl_ssl_s_alloc(VALUE klass) } static VALUE -peer_ip_address(VALUE self) +peer_ip_address(VALUE io) { - VALUE remote_address = rb_funcall(rb_attr_get(self, id_i_io), rb_intern("remote_address"), 0); + VALUE remote_address = rb_funcall(io, rb_intern("remote_address"), 0); return rb_funcall(remote_address, rb_intern("inspect_sockaddr"), 0); } static VALUE -fallback_peer_ip_address(VALUE self, VALUE args) +fallback_peer_ip_address(VALUE self, VALUE exc) { return rb_str_new_cstr("(null)"); } static VALUE -peeraddr_ip_str(VALUE self) +peeraddr_ip_str(VALUE io) { - VALUE rb_mErrno = rb_const_get(rb_cObject, rb_intern("Errno")); - VALUE rb_eSystemCallError = rb_const_get(rb_mErrno, rb_intern("SystemCallError")); - - return rb_rescue2(peer_ip_address, self, fallback_peer_ip_address, (VALUE)0, rb_eSystemCallError, NULL); + return rb_rescue2(peer_ip_address, io, fallback_peer_ip_address, Qnil, + rb_eSystemCallError, (VALUE)0); } /* @@ -1856,7 +1854,7 @@ ossl_start_ssl(VALUE self, int (*func)(SSL *), const char *funcname, VALUE opts) code == SSL_ERROR_SYSCALL ? " SYSCALL" : "", code, saved_errno, - peeraddr_ip_str(self), + peeraddr_ip_str(io), SSL_state_string_long(ssl), error_append); } |
