Putty with Asynchronous DNS

Windows binaries

putty, pscp, psftp, plink

Complete Patch

This patch rearranges the cross-platform code to handle asynchronous DNS lookups. Further, it implements async DNS on Windows; other platforms can have async DNS lookup added with entirely platform-specific changes.

The complete patch (110K)

Incremental, Atomic Patches

I've also broken the complete patch down into four atomic patches. Each patch builds on the previous, rearranging code, but everything should run fine at each patch "step".

Patch 1: SockAddr (37K)
This makes the SockAddr structure "stateful" in that it can be resolved or not. It is initialized with the host to resolve, and actually resolves things with a separate call. It also updates the various bits of code that touch SockAddr's to do the appropriate thing, depending on it's state.

Patch 2: namelookup (28K)
This pushes the actual namelookup call into the backend init/socket creation code, and extracts the canonical name from the SockAddr on return.

Patch 3: frontend (42K)
This makes all of the frontend/cross-platform code (except for the proxy code) handle async DNS lookups. Specifically, it adds a new plug to the frontend to handle namelookup results, and handles any "canonical" name usage to that (updating the titlebar, for example). The platform specific code is now entirely responsible for DNS lookup handling, but all platforms still effectively do sync lookups before returning a socket.

Patch 4: Asynch DNS for Windows (15K)
This patch implements async DNS for the Windows platform using a helper thread. The async resolve function in WinSock doesn't support IPv6, so it is handled generically with a second thread (which does the appropriate IPv4 or v6 resolution).

TODO: