mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
accept_nonblock: favor rb_hash_lookup2 to avoid Hash#default
* ext/socket/init.c (rsock_s_accept_nonblock): use rb_hash_lookup2 * ext/openssl/ossl_ssl.c (get_no_exception): new function (ossl_ssl_accept_nonblock): use get_no_exception (ossl_ssl_read_internal): ditto (ossl_ssl_write_nonblock): ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49955 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
ddf2558a16
commit
9941f348e0
3 changed files with 24 additions and 13 deletions
|
@ -1,3 +1,12 @@
|
|||
Fri Mar 13 07:02:20 2015 Eric Wong <e@80x24.org>
|
||||
|
||||
* ext/socket/init.c (rsock_s_accept_nonblock): use rb_hash_lookup2
|
||||
* ext/openssl/ossl_ssl.c (get_no_exception): new function
|
||||
(ossl_ssl_accept_nonblock): use get_no_exception
|
||||
(ossl_ssl_read_internal): ditto
|
||||
(ossl_ssl_write_nonblock): ditto
|
||||
[ruby-core:68511]
|
||||
|
||||
Fri Mar 13 07:01:38 2015 Eric Wong <e@80x24.org>
|
||||
|
||||
* ext/openssl/ossl_ssl.c: predefine wait_*able symbols
|
||||
|
|
|
@ -1369,6 +1369,14 @@ ossl_ssl_accept(VALUE self)
|
|||
return ossl_start_ssl(self, SSL_accept, "SSL_accept", 0, 0);
|
||||
}
|
||||
|
||||
static int
|
||||
get_no_exception(VALUE opts)
|
||||
{
|
||||
if (!NIL_P(opts) && Qfalse == rb_hash_lookup2(opts, sym_exception, Qundef))
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* ssl.accept_nonblock([options]) => self
|
||||
|
@ -1394,13 +1402,11 @@ ossl_ssl_accept(VALUE self)
|
|||
static VALUE
|
||||
ossl_ssl_accept_nonblock(int argc, VALUE *argv, VALUE self)
|
||||
{
|
||||
int no_exception = 0;
|
||||
int no_exception;
|
||||
VALUE opts = Qnil;
|
||||
|
||||
rb_scan_args(argc, argv, "0:", &opts);
|
||||
|
||||
if (!NIL_P(opts) && Qfalse == rb_hash_aref(opts, sym_exception))
|
||||
no_exception = 1;
|
||||
no_exception = get_no_exception(opts);
|
||||
|
||||
ossl_ssl_setup(self);
|
||||
return ossl_start_ssl(self, SSL_accept, "SSL_accept", 1, no_exception);
|
||||
|
@ -1411,15 +1417,13 @@ ossl_ssl_read_internal(int argc, VALUE *argv, VALUE self, int nonblock)
|
|||
{
|
||||
SSL *ssl;
|
||||
int ilen, nread = 0;
|
||||
int no_exception = 0;
|
||||
int no_exception;
|
||||
VALUE len, str;
|
||||
rb_io_t *fptr;
|
||||
VALUE opts = Qnil;
|
||||
|
||||
rb_scan_args(argc, argv, "11:", &len, &str, &opts);
|
||||
|
||||
if (!NIL_P(opts) && Qfalse == rb_hash_aref(opts, sym_exception))
|
||||
no_exception = 1;
|
||||
no_exception = get_no_exception(opts);
|
||||
|
||||
ilen = NUM2INT(len);
|
||||
if(NIL_P(str)) str = rb_str_new(0, ilen);
|
||||
|
@ -1582,12 +1586,10 @@ ossl_ssl_write_nonblock(int argc, VALUE *argv, VALUE self)
|
|||
{
|
||||
VALUE str;
|
||||
VALUE opts = Qnil;
|
||||
int no_exception = 0;
|
||||
int no_exception;
|
||||
|
||||
rb_scan_args(argc, argv, "1:", &str, &opts);
|
||||
|
||||
if (!NIL_P(opts) && Qfalse == rb_hash_aref(opts, sym_exception))
|
||||
no_exception = 1;
|
||||
no_exception = get_no_exception(opts);
|
||||
|
||||
return ossl_ssl_write_internal(self, str, 1, no_exception);
|
||||
}
|
||||
|
|
|
@ -516,7 +516,7 @@ rsock_s_accept_nonblock(int argc, VALUE *argv, VALUE klass, rb_io_t *fptr,
|
|||
|
||||
rb_scan_args(argc, argv, "0:", &opts);
|
||||
|
||||
if (!NIL_P(opts) && Qfalse == rb_hash_aref(opts, sym_exception))
|
||||
if (!NIL_P(opts) && Qfalse == rb_hash_lookup2(opts, sym_exception, Qundef))
|
||||
ex = 0;
|
||||
|
||||
rb_secure(3);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue