Subject: Re: [PATCH] download: Do not wrap TLS port on GnuTLS >= 3.7.7.

From: Ludovic Courtès <[email-masked]>
Date: Tue, 02 Aug 2022 09:59:22 +0200

Hi,

Maxime Devos <[email-masked]> skribis:

> On 01-08-2022 11:07, Ludovic Courtès wrote:

[...]

>> +  (define (read! bv start count)
>> +    (define read
>> +      (catch 'gnutls-error
>> +        (lambda ()
>> +          (get-bytevector-n! record bv start count))
>> +        (lambda (key err proc . rest)
>> +          ;; When responding to "Connection: close" requests, some servers
>> +          ;; close the connection abruptly after sending the response body,
>> +          ;; without doing a proper TLS connection termination.  Treat it as
>> +          ;; EOF.  This is fixed in GnuTLS 3.7.7.
>> +          (if (eq? err error/premature-termination)
>> +              the-eof-object
>> +              (apply throw key err proc rest)))))
>
> Objection: 'catch' makes the backtrace part happening inside the
> 'get-bytevector-n!' disappear, because it is unwinding, as has been
> noted a few times (in different contexts) by Attila Lendvai and me. 
> Maybe use 'guard' with an appropriate condition instead?

This code was already there and has just been moved around.  (It’s also
code that will no longer be used going forward.)

>> +      (if (module-defined? (resolve-interface '(gnutls))
>> +                           'set-session-record-port-close!) ;GnuTLS >= 3.7.7
>
> resolve-module (and presumably also sets #:ensure #t by default, which
> sometimes causes 'module not found' messages to be replaced by
> 'unbound variable', which I don't think is useful behaviour, can
> #:ensure be set to #false?

This is unnecessary: see the ‘load-gnutls’ mechanism there.  The idiom
above is already used in a couple of places.

Thanks for your feedback!

Ludo’.