Skip to content

Curl passes c-ares sockets to the CURLMOPT_SOCKETFUNCTION but does not open them via the CURLOPT_OPENSOCKETFUNCTION #2734

@Marc-Aldorasi-Imprivata

Description

I did this

I am using the curl multi interface with boost::asio, which cannot wait on sockets without taking ownership of them. For most sockets this is fine, since curl will create them via the CURLOPT_OPENSOCKETFUNCTION callback and close them with the CURLOPT_CLOSESOCKETFUNCTION callback, so asio can open and close them on its own. However, c-ares does not use those functions and instead opens and closes the sockets itself. This means that when curl passes the c-ares socket to the CURLMOPT_SOCKETFUNCTION it isn't owned by asio, and asio can't take ownership of the socket because c-ares will later close the socket. This means the program can't wait on data from that socket and so can't call curl_multi_socket_action at the right time.

I expected the following

Curl should use the OPEN/CLOSESOCKETFUNCTION to open/close c-ares sockets.

curl/libcurl version

curl 7.61.0-DEV (x86_64-pc-linux-gnu) libcurl/7.61.0-DEV OpenSSL/1.1.0h zlib/1.2.11 brotli/1.0.5 c-ares/1.14.0 libidn2/2.0.5 libpsl/0.20.2 (+libidn2/2.0.4) nghttp2/1.32.0
Release-Date: [unreleased]
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp smb smbs smtp smtps telnet tftp
Features: AsynchDNS IDN IPv6 Largefile NTLM NTLM_WB SSL libz brotli TLS-SRP HTTP2 UnixSockets HTTPS-proxy PSL

operating system

Linux, Windows

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions