cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: [PATCH] gnutls 3 compatibility

From: Mark Brand <mabrand_at_mabrand.nl>
Date: Fri, 28 Oct 2011 21:25:03 +0200

Daniel Stenberg wrote:
> On Fri, 28 Oct 2011, Mark Brand wrote:
>
>> +# fixme: ugly workaround for loss of this gnutls function
>> +void
>> +gnutls_transport_set_global_errno (int err)
>> +{
>> +#ifdef _WIN32
>> + /* Keep this in sync with system_errno */
>> + switch (err)
>> + {
>> + case EAGAIN:
>> + SetLastError (WSAEWOULDBLOCK);
>> + break;
>
> Is this really correct? The gnutls_transport_set_global_errno() gets
> called with the input argument being gtls_EAGAIN, gtls_EINTR or
> gtls_EIO (as returned by gtls_mapped_sockerrno) so it seems incorrect
> to assume that they match EAGAIN and EINTR!
>

Agreed that it's not correct to assume that they match, but in this case
they seem to. The MinGW runtime errno.h defines:

#define EINTR 4 /* Interrupted function call */
#define EIO 5 /* Input/output error */
#define EAGAIN 11 /* Resource temporarily unavailable */

These agree with the corresponding gtls_ definitions in gtls.c.

I figured there was a good chance that this should be simplified. It
doesn't make much sense to map the socket error number and then map it
back again. You could just as well replace
gnutls_transport_set_global_errno() with SetLastError() since it only
occurs inside the #ifdef USE_WINSOCK. Do you want me to do that?

By the way, the "fixme" comment is a syntax error!

Mark

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2011-10-28