ValentinBELYN / icmplib

Easily forge ICMP packets and make your own ping and traceroute.
GNU Lesser General Public License v3.0
266 stars 46 forks source link

skip socket.getaddrinfo before sendto #77

Closed wukgdu closed 5 months ago

wukgdu commented 5 months ago

On one hand, since the address of destination in request has been resolved before sock.send in ping and traceroute, call socket.getaddrinfo before sendto seems redundant.

On the other hand, socket.getaddrinfo before python 3.9 (including 3.9) will ACQUIRE_GETADDRINFO_LOCK (https://github.com/python/cpython/blob/3.9/Modules/socketmodule.c#L1193). So getaddrinfo may be locked. When user uses multi-threading with icmplib and other network functions, ping provided by icmplib may be blocked by other getaddrinfo's timeout.

wukgdu commented 5 months ago

may introduce a breaking change

kalvdans commented 5 months ago

On most modern platforms the lock isn't used, see https://github.com/python/cpython/blob/3.9/Modules/socketmodule.c#L201 . Good to not merge it.