Re: [RUN] Timeout occurs

From: Mike Breuer (mbreuer@new.rr.com)
Date: 03/22/01


From: "George Greer" <greerga@CIRCLEMUD.ORG>
> On Thu, 22 Mar 2001, Janvier D. Anonical wrote:
>
> >SYSERR: gethostbyaddr: No error
> >Mar 22 19:33:28 :: SYSERR: Missed 54 seconds worth of pulses.
> >Mar 22 19:33:28 :: SYSERR: Losing descriptor without char.
> >
> >I tried to trace this and the cause was in comm.c. It seems that
resolution
> >has failed as given by the code below:
> >
> >  /* find the sitename */
> >  if (nameserver_is_slow || !(from = gethostbyaddr((char *)
&peer.sin_addr,
> >                                      sizeof(peer.sin_addr),
AF_INET))) {
>
> Try setting 'nameserver_is_slow' in config.c or the 'slowns' command.

I had this trouble when I had my MUD on a machine that is running NAT,
and has access both to the outside and to my private network.  The
private network would take as long as 45 seconds before time out on the
call to gethostbyaddr(..).  I added the following code in order to
detect private networks, but still resolve names for external networks.
Sorry it's not in patch format, but I have quite a few other changes in
comm.c, and didn't have time to sift through them.

---Somewhere near the top of comm.c add:

#define EX_BYTE(b, x) ( ((x) >> (((b) - 1) * 8)) & 0xFF )

---In the variable declaration portion of new_descriptor(..) add:
  unsigned long b;

---Replace the if (nameserver_is_slow .... test in new_descriptor(..)
with:

  /* Check for a private network address */
  b = ((unsigned long)peer.sin_addr.s_addr);
  if ( (EX_BYTE(1,b) == 10) ||
       (EX_BYTE(1,b) == 172 && EX_BYTE(2,b) >= 16 && EX_BYTE(2,b) <= 31)
||
       (EX_BYTE(1,b) == 192 && EX_BYTE(2,b) == 168)) {
    strcpy(newd->host, "LAN (");
    strncpy(newd->host + strlen(newd->host), (char
*)inet_ntoa(peer.sin_addr),
            HOST_LENGTH - strlen(newd->host));
    *(newd->host + HOST_LENGTH) = '\0';
    if (strlen(newd->host) < HOST_LENGTH -1) strcat(newd->host, ")");
  /* find the sitename */
  } else if (nameserver_is_slow ||
             !(from = gethostbyaddr((char *) &peer.sin_addr,
               sizeof(peer.sin_addr), AF_INET))) {

--
   +---------------------------------------------------------------+
   | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
   | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
   +---------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/04/01 PST