Re: gethostbyname

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, May 13, 2001 at 10:32:45AM -0700, Lee Chin wrote:
> Hi,
> On the same topic.... who is responsible for freeing
> the struct hostent structure returned by
> gethostbyname?

  It is internal static data to that function.
  NOT safe for multithreaded access, NOT valid
  after the next call to  gethostbyname().

> Thanks
> Lee

/Matti Aarnio

> --- Mark Hahn <hahn@coffee.psychology.mcmaster.ca>
> wrote:
> > > gethostbyname just takes too long once in a while
> > on
> > > certain sites... is there a way to set a time out
> > for
> > > gethostbyname?
> > 
> > that's the right approach, I think.  you might try
> > plain old signal(connect_timeout,SIGALRM), since 
> > the sigaction stuff is somewhat complicated.
> > 
> > > I tried this:
> > > act.sa_flags = SA_NOMASK;
> > > act.sa_handler = connect_timeout;
> > > sigaction(SIGALRM, &act, NULL);
> > > alarm(DNS_TIMEOUT);
> > > hostentry = gethostbyname(host);
> > > alarm(0);
> > > 
> > > but when the alarm happened, I got a SIGSEGV in
> > > gethostbyname
> > 
> > could you strace this?  gethostbyname is actually a
> > libc
> > thing, so it could well be that libc is simply not
> > dealing
> > with some syscall (probably a sendmsg to a
> > nameserver)
> > getting EINTR.
> > 
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Auctions - buy the things you want at great prices
> http://auctions.yahoo.com/
> -
> : send the line "unsubscribe linux-net" in
> the body of a message to majordomo@vger.kernel.org
-
: send the line "unsubscribe linux-net" in
the body of a message to majordomo@vger.kernel.org


[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux 802.1Q VLAN]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Git]     [Bugtraq]     [Yosemite News and Information]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux PCI]     [Linux Admin]     [Samba]

  Powered by Linux