Changeset f5a36ee in mod_gnutls


Ignore:
Timestamp:
Nov 11, 2015, 9:10:35 PM (2 years ago)
Author:
Thomas Klute <thomas2.klute@…>
Branches:
master, debian, jessie-backports, upstream
Children:
a63301f
Parents:
02a6a18
Message:

Pass EAGAIN/EINTR from gnutls_io_input_read to input filter

Unconditionally repeating calls to gnutls_record_recv on EAGAIN or
EINTR can lead to busy wait loops on nonblocking reads, which
particularly affects Keep-Alive connections waiting for new
requests. Passing the error code up to the filter instead lets the
higher levels deal with the interruption as appropriate in the given
context.

However, the input filter (mgs_filter_input) needs to handle a special
case for nonblocking reads: Those (strangely) return APR_EINTR if no
data is available. This has to be caught and APR_EAGAIN returned
instead, or mod_proxy will assume that the connection failed,
potentially breaking transmissions.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/gnutls_io.c

    r02a6a18 rf5a36ee  
    241241    }
    242242
    243     while (1) {
    244 
    245         do
    246             rc = gnutls_record_recv(ctxt->session, buf + bytes,
    247                                     wanted - bytes);
    248         while (rc == GNUTLS_E_INTERRUPTED || rc == GNUTLS_E_AGAIN);
     243    while (1)
     244    {
     245        rc = gnutls_record_recv(ctxt->session, buf + bytes, wanted - bytes);
     246
     247        if (rc == GNUTLS_E_INTERRUPTED)
     248            ctxt->input_rc = APR_EINTR;
     249        else if (rc == GNUTLS_E_AGAIN)
     250            ctxt->input_rc = APR_EAGAIN;
    249251
    250252        if (rc > 0) {
     
    557559    }
    558560
    559     if (status != APR_SUCCESS) {
     561    if (status != APR_SUCCESS)
     562    {
     563        /* no data for nonblocking read, return APR_EAGAIN */
     564        if ((block == APR_NONBLOCK_READ) && (status == APR_EINTR))
     565            return APR_EAGAIN;
     566
    560567        return gnutls_io_filter_error(f, bb, status);
    561568    }
Note: See TracChangeset for help on using the changeset viewer.