[Opera-Linux] Flushing the DNS cache?

Eirik Byrkjeflot Anonsen eirik at opera.com
Mon Dec 22 09:37:17 UTC 2008


Kenneth Crudup <kenny at panix.com> 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


More information about the Opera-Linux mailing list