diff options
author | gotoyuzo <gotoyuzo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2005-08-07 20:21:40 +0000 |
---|---|---|
committer | gotoyuzo <gotoyuzo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2005-08-07 20:21:40 +0000 |
commit | ec4671166848ccc203e415ba3227b6f04bf1cc81 (patch) | |
tree | 47b6e258cc938b4cdcdbd181235b4079b3224861 | |
parent | b1e29f011dd4c275f7a06c073ff7f100f42732d8 (diff) | |
download | ruby-ec4671166848ccc203e415ba3227b6f04bf1cc81.tar.gz |
* ext/openssl/ossl.c (ossl_raise): should use ERR_peek_last_error
to get last error on the current thread. And should report
if errors are on the stack while OpenSSL.debug is true.
* ext/openssl/ossl.c (ossl_get_errors): new method for debugging
this library.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8944 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | ext/openssl/ossl.c | 24 |
2 files changed, 31 insertions, 2 deletions
@@ -1,3 +1,12 @@ +Mon Aug 8 05:16:55 2005 GOTOU Yuuzou <gotoyuzo@notwork.org> + + * ext/openssl/ossl.c (ossl_raise): should use ERR_peek_last_error + to get last error on the current thread. And should report + if errors are on the stack while OpenSSL.debug is true. + + * ext/openssl/ossl.c (ossl_get_errors): new method for debugging + this library. + Mon Aug 8 05:15:19 2005 GOTOU Yuuzou <gotoyuzo@notwork.org> * lib/webrick/httpproxy.rb (HTTPProxyServer#intialize), diff --git a/ext/openssl/ossl.c b/ext/openssl/ossl.c index 41659f0e81..2ad2ee38d0 100644 --- a/ext/openssl/ossl.c +++ b/ext/openssl/ossl.c @@ -278,7 +278,7 @@ ossl_raise(VALUE exc, const char *fmt, ...) va_list args; char buf[BUFSIZ]; const char *msg; - long e = ERR_get_error(); + long e = ERR_peek_last_error(); int len = 0; if (fmt) { @@ -291,15 +291,34 @@ ossl_raise(VALUE exc, const char *fmt, ...) msg = ERR_error_string(e, NULL); else msg = ERR_reason_error_string(e); - ERR_clear_error(); fmt = len ? ": %s" : "%s"; len += snprintf(buf+len, BUFSIZ-len, fmt, msg); } + if (dOSSL == Qtrue){ /* show all errors on the stack */ + while ((e = ERR_get_error()) != 0){ + rb_warn("error on stack: %s", ERR_error_string(e, NULL)); + } + } + ERR_clear_error(); if(len > BUFSIZ) len = strlen(buf); rb_exc_raise(rb_exc_new(exc, buf, len)); } +VALUE +ossl_get_errors() +{ + VALUE ary; + long e; + + ary = rb_ary_new(); + while ((e = ERR_get_error()) != 0){ + rb_ary_push(ary, rb_str_new2(ERR_error_string(e, NULL))); + } + + return ary; +} + /* * Debug */ @@ -411,6 +430,7 @@ Init_openssl() dOSSL = Qfalse; rb_define_module_function(mOSSL, "debug", ossl_debug_get, 0); rb_define_module_function(mOSSL, "debug=", ossl_debug_set, 1); + rb_define_module_function(mOSSL, "errors", ossl_get_errors, 0); /* * Get ID of to_der |