Changeset 70c2d86 in mod_gnutls for src/gnutls_io.c


Ignore:
Timestamp:
Jan 11, 2013, 12:55:20 AM (9 years ago)
Author:
Daniel Kahn Gillmor <dkg@…>
Branches:
debian/master, debian/stretch-backports, jessie-backports, upstream
Children:
3f5c713, ec06980
Parents:
3e94bd3
Message:

Imported Upstream version 0.3.4

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/gnutls_io.c

    r3e94bd3 r70c2d86  
    354354}
    355355
     356#define HANDSHAKE_MAX_TRIES 100
    356357static int gnutls_do_handshake(mgs_handle_t * ctxt)
    357358{
    358359    int ret;
    359360    int errcode;
     361    int maxtries = HANDSHAKE_MAX_TRIES;
     362
    360363    if (ctxt->status != 0) {
    361364        return -1;
     
    365368    do {
    366369        ret = gnutls_handshake(ctxt->session);
    367     } while (ret == GNUTLS_E_AGAIN);
    368    
     370        maxtries--;
     371    } while (ret == GNUTLS_E_AGAIN && maxtries > 0);
     372
     373    if (maxtries < 1) {
     374        ctxt->status = -1;
     375#if USING_2_1_RECENT
     376        ap_log_cerror(APLOG_MARK, APLOG_ERR, 0, ctxt->c,
     377                     "GnuTLS: Handshake Failed. Hit Maximum Attempts");
     378#else
     379        ap_log_error(APLOG_MARK, APLOG_ERR, 0, ctxt->c->base_server,
     380                     "GnuTLS: Handshake Failed. Hit Maximum Attempts");
     381#endif
     382        gnutls_alert_send(ctxt->session, GNUTLS_AL_FATAL,
     383                          gnutls_error_to_alert(ret, NULL));
     384        gnutls_deinit(ctxt->session);
     385        return -1;
     386    }
     387
    369388    if (ret < 0) {
    370389        if (ret == GNUTLS_E_WARNING_ALERT_RECEIVED
     
    525544        if (AP_BUCKET_IS_EOC(bucket)) {
    526545            do {
    527                 ret = gnutls_alert_send(ctxt->session, GNUTLS_AL_FATAL,
    528                                         GNUTLS_A_CLOSE_NOTIFY);
     546                ret = gnutls_bye( ctxt->session, GNUTLS_SHUT_WR);
    529547            } while(ret == GNUTLS_E_INTERRUPTED || ret == GNUTLS_E_AGAIN);
    530548
     
    538556
    539557            apr_brigade_cleanup(ctxt->output_bb);
    540             gnutls_bye(ctxt->session, GNUTLS_SHUT_WR);
    541558            gnutls_deinit(ctxt->session);
    542559            continue;
     
    550567                return status;
    551568            }
     569
    552570            apr_brigade_cleanup(ctxt->output_bb);
    553571            continue;
     
    581599                             ctxt->c->base_server,
    582600                             "GnuTLS: Error writing data."
    583                              " (%d) '%s'", ret, gnutls_strerror(ret));
     601                             " (%d) '%s'", (int)ret, gnutls_strerror(ret));
    584602                if (ctxt->output_rc == APR_SUCCESS) {
    585603                    ctxt->output_rc = APR_EGENERAL;
Note: See TracChangeset for help on using the changeset viewer.