From fc2eb1c11c0e581f6269178612a7e82a00145d00 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Thu, 1 Mar 2012 15:42:13 -0700 Subject: [PATCH] openssl: fix error handling The recent thread-safety change wasn't right. --- collects/openssl/mzssl.rkt | 8 ++++---- collects/tests/openssl/github.rkt | 6 ++++++ 2 files changed, 10 insertions(+), 4 deletions(-) create mode 100644 collects/tests/openssl/github.rkt diff --git a/collects/openssl/mzssl.rkt b/collects/openssl/mzssl.rkt index 53e93761ba..80289223aa 100644 --- a/collects/openssl/mzssl.rkt +++ b/collects/openssl/mzssl.rkt @@ -312,9 +312,9 @@ ;; so that this library is thread-safe (at the level of Racket threads) (atomically (define v (thunk)) - (define e (if (negative? v) - (SSL_get_error ssl v) - 0)) + (define e (if (positive? v) + 0 + (SSL_get_error ssl v))) (define estr (cond [(= e SSL_ERROR_SSL) @@ -649,7 +649,7 @@ [else (set! must-read-len #f) ((mzssl-error mzssl) 'read-bytes - "SSL read failed ~a" + "SSL read failed ~a ~a" estr)]))))))] [top-read (lambda (buffer) diff --git a/collects/tests/openssl/github.rkt b/collects/tests/openssl/github.rkt new file mode 100644 index 0000000000..d53c822c23 --- /dev/null +++ b/collects/tests/openssl/github.rkt @@ -0,0 +1,6 @@ +#lang racket/base +(require net/url) + +(unless (input-port? (get-pure-port (string->url "https://api.github.com/"))) + (error "failed for https://api.github.com/")) +