Re: Flushing the DNS cache?

Eirik Byrkjeflot Anonsen <[email protected]>
Newsgroups gmane.comp.web.opera.linux
Message-ID <[email protected]>
Kenneth Crudup <[email protected]> writes:

> On Fri, 19 Dec 2008, Eirik Byrkjeflot Anonsen wrote:
>
>> I'd be very disappointed in the desktop team if they aren't leaving
>> the whole job of dns resolution to the system resolver.
>
> Oh, I understand; it's just that (and maybe this is an issue with my
> installed set of libs) that it's trying to talk to (and I believe,
> spinning while doing so) a non-existant resolver.

Should be easy to test whether this is the standard behaviour of the
library:

#include <stdio.h>
#include <netdb.h>
#include <unistd.h>
int main(int argc, char ** argv)
{
        while (true)
        {
                struct hostent * he = gethostbyname("somewhere.com");
                if (he == 0)
                {
                        printf("gethostbyname failed\n");
                }
                else
                {
                        printf("gethostbyname succeeded\n");
                }
                sleep(10);
        }
        return 0;
}


Compile (and fix compile errors...), run and see if the program
behaves the same way as opera does.  If it does, I guess that means
that libc doesn't reread the dns server address when it changes.

Note that the above is not really how opera works, due to shortcomings
of various platforms' implementation of the resolver functions.  But I
expect we are still basically using gethostbyname() (well, actually
gethostbyname_r() on the platforms where that is not utterly broken).
It is a horrible function, but at least its behavioural quirks are
well-known.

eirik
--
Opera-Linux: https://list.opera.com/mailman/listinfo/opera-linux
More lists: https://list.opera.com/mailman/listinfo/
Unsubscribe: mailto:[email protected]?subject=unsubscribe
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.