aboutsummaryrefslogtreecommitdiffstats
path: root/src/gnutls_io.c
diff options
context:
space:
mode:
authorGravatar Nikos Mavrogiannopoulos 2009-07-21 20:46:13 +0000
committerGravatar Nokis Mavrogiannopoulos 2009-07-21 20:46:13 +0000
commitdcf11188825117a0ead90b383093e87f9a6ed445 (patch)
treedf5853c536e6a06e2e31fdde6e1ab7743ecd139d /src/gnutls_io.c
parentdaf3dc9b09b01240ed8baa607f72f4ec26d6e91f (diff)
On connection termination be polite and send a bye (common handling of EOC and EOS).
Diffstat (limited to 'src/gnutls_io.c')
-rw-r--r--src/gnutls_io.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/gnutls_io.c b/src/gnutls_io.c
index f6da535..15de422 100644
--- a/src/gnutls_io.c
+++ b/src/gnutls_io.c
@@ -368,7 +368,7 @@ tryagain:
368 do { 368 do {
369 ret = gnutls_handshake(ctxt->session); 369 ret = gnutls_handshake(ctxt->session);
370 maxtries--; 370 maxtries--;
371 } while (ret == GNUTLS_E_AGAIN && maxtries > 0); 371 } while ((ret == GNUTLS_E_INTERRUPTED || ret == GNUTLS_E_AGAIN) && maxtries > 0);
372 372
373 if (maxtries < 1) { 373 if (maxtries < 1) {
374 ctxt->status = -1; 374 ctxt->status = -1;
@@ -381,7 +381,7 @@ tryagain:
381#endif 381#endif
382 if (ctxt->session) { 382 if (ctxt->session) {
383 gnutls_alert_send(ctxt->session, GNUTLS_AL_FATAL, 383 gnutls_alert_send(ctxt->session, GNUTLS_AL_FATAL,
384 gnutls_error_to_alert(ret, NULL)); 384 gnutls_error_to_alert(GNUTLS_E_INTERNAL_ERROR, NULL));
385 gnutls_deinit(ctxt->session); 385 gnutls_deinit(ctxt->session);
386 } 386 }
387 ctxt->session = NULL; 387 ctxt->session = NULL;
@@ -547,7 +547,16 @@ apr_status_t mgs_filter_output(ap_filter_t * f,
547 547
548 while (!APR_BRIGADE_EMPTY(bb)) { 548 while (!APR_BRIGADE_EMPTY(bb)) {
549 apr_bucket *bucket = APR_BRIGADE_FIRST(bb); 549 apr_bucket *bucket = APR_BRIGADE_FIRST(bb);
550 if (AP_BUCKET_IS_EOC(bucket)) { 550
551 if (AP_BUCKET_IS_EOC(bucket) || APR_BUCKET_IS_EOS(bucket)) {
552 apr_bucket_brigade * tmpb;
553
554 if (APR_BUCKET_IS_EOS(bucket)) {
555 tmpb = bb;
556 } else {
557 tmpb = ctxt->output_bb;
558 }
559
551 if (ctxt->session != NULL) { 560 if (ctxt->session != NULL) {
552 do { 561 do {
553 ret = gnutls_bye( ctxt->session, GNUTLS_SHUT_WR); 562 ret = gnutls_bye( ctxt->session, GNUTLS_SHUT_WR);
@@ -557,7 +566,7 @@ apr_status_t mgs_filter_output(ap_filter_t * f,
557 apr_bucket_copy(bucket, &e); 566 apr_bucket_copy(bucket, &e);
558 APR_BRIGADE_INSERT_TAIL(ctxt->output_bb, e); 567 APR_BRIGADE_INSERT_TAIL(ctxt->output_bb, e);
559 568
560 if ((status = ap_pass_brigade(f->next, ctxt->output_bb)) != APR_SUCCESS) { 569 if ((status = ap_pass_brigade(f->next, tmpb)) != APR_SUCCESS) {
561 apr_brigade_cleanup(ctxt->output_bb); 570 apr_brigade_cleanup(ctxt->output_bb);
562 return status; 571 return status;
563 } 572 }
@@ -568,8 +577,7 @@ apr_status_t mgs_filter_output(ap_filter_t * f,
568 ctxt->session = NULL; 577 ctxt->session = NULL;
569 } 578 }
570 continue; 579 continue;
571 580 } else if (APR_BUCKET_IS_FLUSH(bucket)) {
572 } else if (APR_BUCKET_IS_FLUSH(bucket) || APR_BUCKET_IS_EOS(bucket)) {
573 581
574 apr_bucket_copy(bucket, &e); 582 apr_bucket_copy(bucket, &e);
575 APR_BRIGADE_INSERT_TAIL(ctxt->output_bb, e); 583 APR_BRIGADE_INSERT_TAIL(ctxt->output_bb, e);