On Wed, Dec 12, 2001 at 02:23:07AM -0500, Big Red wrote: > Yeah, I heard something about DNS lookups lagging things immensly. > > ...So how do you fix it?
One of the following. A) Disable dns lookups on connections B) Use a coprocess to look up the hostname C) Use a seperate thread to look up the hostname. A) is trivial (look in comm.c). B) is what I do: when the mud starts, it spawns a coprocess that does the DNS lookups. (every incoming socket sends "<id#> <IP> <port>\n" through a pipe to the coprocess, the coprocess sends back "<id#> [EMAIL PROTECTED]" through another pipe ... the id# is a simple counter to ensure we're getting the response we think even if they return out of order.) Because children keep open files, the coprocess actually forks when it gets a new request, so one slow resolving site doesn't slow down others trying to log in, and characters are put in a 'GETTTING_IDENT' CON_ state until their hostname resolves or times out. This is pretty simple to do if you know how to do coprocesses (or steal the code from Advanced Programming in the Unix Environment). C) can be much trickier: beware that threads can be tricky to debug and you now have to ensure your threads don't piss on the parent's memory (the memory management, for example, isn't thread safe... so you'll have to be carful in allocating strings.)

