Skip to content

[th/connectivity-resolve] connectivity: resolve hostname ourselves to avoid blocking libcurl

Thomas Haller requested to merge th/connectivity-resolve into main

Usually we anyway require systemd-resolved to resolve the hostname for connectivity checking. Only systemd-resolved provides a per-interface API. Without it, connectivity check (together with bumping the route metric) has problems.

Anyway. If we had no systemd-resolved or it failed, we would just call libcurl. That would then try to resolve the name, using with whatever resolver it has configured. Usually that means it was using the threaded resolved, which calls blocking getaddrinfo() libc API on a thread.

libcurl has a bug that can cause the process to block, waiting to join the resolver thread:

  #0  0x00007ffff781fb27 in __pthread_timedjoin_ex () at /lib64/libpthread.so.0
  #1  0x00007ffff7c0ac9a in Curl_thread_join () at /lib64/libcurl.so.4
  #2  0x00007ffff7c0d693 in thread_wait_resolv () at /lib64/libcurl.so.4
  #3  0x00007ffff7bf9284 in multi_done () at /lib64/libcurl.so.4
  #4  0x00007ffff7bfb588 in curl_multi_remove_handle () at /lib64/libcurl.so.4
  #5  0x000055555574adc3 in cb_data_complete

That's not acceptable. Resolve the name ourselves using glib's implementatin. If we fail, we no longer call to libcurl.

https://github.com/curl/curl/issues/8515

#312 (closed) #404 (closed)

Edited by Thomas Haller

Merge request reports