From 5740f52c1e62d943eb50b4e1b9ae14f824c2dd39 Mon Sep 17 00:00:00 2001 From: Nokis Mavrogiannopoulos Date: Mon, 20 Jul 2009 21:14:37 +0000 Subject: More fixes related to bug #102 --- src/gnutls_io.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/gnutls_io.c b/src/gnutls_io.c index a8fd242..e145466 100644 --- a/src/gnutls_io.c +++ b/src/gnutls_io.c @@ -379,9 +379,11 @@ tryagain: ap_log_error(APLOG_MARK, APLOG_ERR, 0, ctxt->c->base_server, "GnuTLS: Handshake Failed. Hit Maximum Attempts"); #endif - gnutls_alert_send(ctxt->session, GNUTLS_AL_FATAL, + if (ctxt->session) { + gnutls_alert_send(ctxt->session, GNUTLS_AL_FATAL, gnutls_error_to_alert(ret, NULL)); - if (ctxt->session) gnutls_deinit(ctxt->session); + gnutls_deinit(ctxt->session); + } ctxt->session = NULL; return -1; } @@ -411,9 +413,11 @@ tryagain: gnutls_strerror(ret)); #endif ctxt->status = -1; - gnutls_alert_send(ctxt->session, GNUTLS_AL_FATAL, + if (ctxt->session) { + gnutls_alert_send(ctxt->session, GNUTLS_AL_FATAL, gnutls_error_to_alert(ret, NULL)); - if (ctxt->session) gnutls_deinit(ctxt->session); + gnutls_deinit(ctxt->session); + } ctxt->session = NULL; return ret; } @@ -559,8 +563,10 @@ apr_status_t mgs_filter_output(ap_filter_t * f, } apr_brigade_cleanup(ctxt->output_bb); - if (ctxt->session) gnutls_deinit(ctxt->session); - ctxt->session = NULL; + if (APR_BUCKET_IS_EOS(bucket) && ctxt->session) { + gnutls_deinit(ctxt->session); + ctxt->session = NULL; + } continue; } else if (APR_BUCKET_IS_FLUSH(bucket) || APR_BUCKET_IS_EOS(bucket)) { -- cgit