summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-03-12 22:03:53 +0000
committernormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-03-12 22:03:53 +0000
commitddf2558a167652cfec6a901b2116b832221e6e83 (patch)
treed5c9bc4522fb8893406d0142d0b76133fc489030
parent6014e76a4088472bb8d2b08e40c690feb548b701 (diff)
ext/openssl/ossl_ssl.c: predefine wait_*able symbols
This leads to a size reduction in openssl.so and reduces the chance of bugs due to typos. text data bss dec hex before: 333022 13164 3312 349498 5553a after: 332790 13164 3232 349186 55402 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49954 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog4
-rw-r--r--ext/openssl/ossl_ssl.c17
2 files changed, 14 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index 4c0d8bb84f3..d992d96dc13 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Fri Mar 13 07:01:38 2015 Eric Wong <e@80x24.org>
+
+ * ext/openssl/ossl_ssl.c: predefine wait_*able symbols
+
Thu Mar 12 22:59:53 2015 Tanaka Akira <akr@fsij.org>
* test/lib/leakchecker.rb: Check environment variables.
diff --git a/ext/openssl/ossl_ssl.c b/ext/openssl/ossl_ssl.c
index 48e97308e3e..496d9483cd1 100644
--- a/ext/openssl/ossl_ssl.c
+++ b/ext/openssl/ossl_ssl.c
@@ -107,7 +107,7 @@ static const char *ossl_ssl_attrs[] = {
ID ID_callback_state;
-static VALUE sym_exception;
+static VALUE sym_exception, sym_wait_readable, sym_wait_writable;
/*
* SSLContext class
@@ -1296,12 +1296,12 @@ ossl_start_ssl(VALUE self, int (*func)(), const char *funcname,
switch((ret2 = ssl_get_error(ssl, ret))){
case SSL_ERROR_WANT_WRITE:
- if (no_exception) { return ID2SYM(rb_intern("wait_writable")); }
+ if (no_exception) { return sym_wait_writable; }
write_would_block(nonblock);
rb_io_wait_writable(FPTR_TO_FD(fptr));
continue;
case SSL_ERROR_WANT_READ:
- if (no_exception) { return ID2SYM(rb_intern("wait_readable")); }
+ if (no_exception) { return sym_wait_readable; }
read_would_block(nonblock);
rb_io_wait_readable(FPTR_TO_FD(fptr));
continue;
@@ -1444,12 +1444,12 @@ ossl_ssl_read_internal(int argc, VALUE *argv, VALUE self, int nonblock)
if (no_exception) { return Qnil; }
rb_eof_error();
case SSL_ERROR_WANT_WRITE:
- if (no_exception) { return ID2SYM(rb_intern("wait_writable")); }
+ if (no_exception) { return sym_wait_writable; }
write_would_block(nonblock);
rb_io_wait_writable(FPTR_TO_FD(fptr));
continue;
case SSL_ERROR_WANT_READ:
- if (no_exception) { return ID2SYM(rb_intern("wait_readable")); }
+ if (no_exception) { return sym_wait_readable; }
read_would_block(nonblock);
rb_io_wait_readable(FPTR_TO_FD(fptr));
continue;
@@ -1532,12 +1532,12 @@ ossl_ssl_write_internal(VALUE self, VALUE str, int nonblock, int no_exception)
case SSL_ERROR_NONE:
goto end;
case SSL_ERROR_WANT_WRITE:
- if (no_exception) { return ID2SYM(rb_intern("wait_writable")); }
+ if (no_exception) { return sym_wait_writable; }
write_would_block(nonblock);
rb_io_wait_writable(FPTR_TO_FD(fptr));
continue;
case SSL_ERROR_WANT_READ:
- if (no_exception) { return ID2SYM(rb_intern("wait_readable")); }
+ if (no_exception) { return sym_wait_readable; }
read_would_block(nonblock);
rb_io_wait_readable(FPTR_TO_FD(fptr));
continue;
@@ -2313,5 +2313,8 @@ Init_ossl_ssl(void)
ossl_ssl_def_const(OP_NETSCAPE_CA_DN_BUG);
ossl_ssl_def_const(OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG);
+#undef rb_intern
sym_exception = ID2SYM(rb_intern("exception"));
+ sym_wait_readable = ID2SYM(rb_intern("wait_readable"));
+ sym_wait_writable = ID2SYM(rb_intern("wait_writable"));
}