aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Nokis Mavrogiannopoulos 2009-07-21 20:46:13 +0000
committerGravatar Nokis Mavrogiannopoulos 2009-07-21 20:46:13 +0000
commitfed285b4c3601bd6da08e8a5f07fc52b9f0c69cf (patch)
treedf5853c536e6a06e2e31fdde6e1ab7743ecd139d
parent76cbe022c8c1158615615e54a53be8fb1f07a718 (diff)
On connection termination be polite and send a bye (common handling of EOC and EOS).
-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);