Back to index

lightning-sunbird  0.9+nobinonly
Classes | Defines | Functions | Variables
nsHostResolver.cpp File Reference
#include <stdlib.h>
#include "nsHostResolver.h"
#include "nsNetError.h"
#include "nsISupportsBase.h"
#include "nsISupportsUtils.h"
#include "nsAutoLock.h"
#include "nsAutoPtr.h"
#include "pratom.h"
#include "prthread.h"
#include "prerror.h"
#include "prcvar.h"
#include "prtime.h"
#include "prlong.h"
#include "prlog.h"
#include "pldhash.h"
#include "plstr.h"
#include "nsURLHelper.h"

Go to the source code of this file.

Classes

struct  nsHostDBEnt

Defines

#define MAX_THREADS   8
#define IDLE_TIMEOUT   PR_SecondsToInterval(60)
#define LOG(args)
#define RES_KEY_FLAGS(_f)   ((_f) & nsHostResolver::RES_CANON_NAME)

Functions

static void MoveCList (PRCList &from, PRCList &to)
static PRUint32 NowInMinutes ()
 HostDB_GetKey (PLDHashTable *table, PLDHashEntryHdr *entry)
 HostDB_HashKey (PLDHashTable *table, const void *key)
 HostDB_MatchEntry (PLDHashTable *table, const PLDHashEntryHdr *entry, const void *key)
 HostDB_MoveEntry (PLDHashTable *table, const PLDHashEntryHdr *from, PLDHashEntryHdr *to)
 HostDB_ClearEntry (PLDHashTable *table, PLDHashEntryHdr *entry)
 HostDB_InitEntry (PLDHashTable *table, PLDHashEntryHdr *entry, const void *key)
 HostDB_RemoveEntry (PLDHashTable *table, PLDHashEntryHdr *hdr, PRUint32 number, void *arg)

Variables

static PLDHashTableOps gHostDB_ops

Define Documentation

#define IDLE_TIMEOUT   PR_SecondsToInterval(60)

Definition at line 72 of file nsHostResolver.cpp.

#define LOG (   args)

Definition at line 80 of file nsHostResolver.cpp.

Definition at line 71 of file nsHostResolver.cpp.

Definition at line 157 of file nsHostResolver.cpp.


Function Documentation

HostDB_ClearEntry ( PLDHashTable table,
PLDHashEntryHdr entry 
)

Definition at line 238 of file nsHostResolver.cpp.

{
    LOG(("evicting record\n"));
    nsHostDBEnt *he = NS_STATIC_CAST(nsHostDBEnt *, entry);
#if defined(DEBUG) && defined(PR_LOGGING)
    if (!he->rec->addr_info)
        LOG(("%s: => no addr_info\n", he->rec->host));
    else {
        PRInt32 now = (PRInt32) NowInMinutes();
        PRInt32 diff = (PRInt32) he->rec->expiration - now;
        LOG(("%s: exp=%d => %s\n",
            he->rec->host, diff,
            PR_GetCanonNameFromAddrInfo(he->rec->addr_info)));
        void *iter = nsnull;
        PRNetAddr addr;
        char buf[64];
        for (;;) {
            iter = PR_EnumerateAddrInfo(iter, he->rec->addr_info, 0, &addr);
            if (!iter)
                break;
            PR_NetAddrToString(&addr, buf, sizeof(buf));
            LOG(("  %s\n", buf));
        }
    }
#endif
    NS_RELEASE(he->rec);
}

Here is the call graph for this function:

HostDB_GetKey ( PLDHashTable table,
PLDHashEntryHdr entry 
)

Definition at line 202 of file nsHostResolver.cpp.

{
    nsHostDBEnt *he = NS_STATIC_CAST(nsHostDBEnt *, entry);
    return NS_STATIC_CAST(const nsHostKey *, he->rec);
}
HostDB_HashKey ( PLDHashTable table,
const void key 
)

Definition at line 209 of file nsHostResolver.cpp.

{
    const nsHostKey *hk = NS_STATIC_CAST(const nsHostKey *, key);
    return PL_DHashStringKey(table, hk->host) ^ hk->flags ^ hk->af;
}

Here is the call graph for this function:

HostDB_InitEntry ( PLDHashTable table,
PLDHashEntryHdr entry,
const void key 
)

Definition at line 268 of file nsHostResolver.cpp.

Here is the call graph for this function:

HostDB_MatchEntry ( PLDHashTable table,
const PLDHashEntryHdr entry,
const void key 
)

Definition at line 216 of file nsHostResolver.cpp.

{
    const nsHostDBEnt *he = NS_STATIC_CAST(const nsHostDBEnt *, entry);
    const nsHostKey *hk = NS_STATIC_CAST(const nsHostKey *, key); 

    return !strcmp(he->rec->host, hk->host) &&
            he->rec->flags == hk->flags &&
            he->rec->af == hk->af;
}

Definition at line 229 of file nsHostResolver.cpp.

{
    NS_STATIC_CAST(nsHostDBEnt *, to)->rec =
            NS_STATIC_CAST(const nsHostDBEnt *, from)->rec;
}
HostDB_RemoveEntry ( PLDHashTable table,
PLDHashEntryHdr hdr,
PRUint32  number,
void arg 
)

Definition at line 291 of file nsHostResolver.cpp.

{
    return PL_DHASH_REMOVE;
}

Here is the caller graph for this function:

static void MoveCList ( PRCList &  from,
PRCList &  to 
) [inline, static]

Definition at line 86 of file nsHostResolver.cpp.

{
    if (!PR_CLIST_IS_EMPTY(&from)) {
        to.next = from.next;
        to.prev = from.prev;
        to.next->prev = &to;
        to.prev->next = &to;
        PR_INIT_CLIST(&from);
    }             
}

Here is the caller graph for this function:

static PRUint32 NowInMinutes ( ) [static]

Definition at line 98 of file nsHostResolver.cpp.

{
    PRTime now = PR_Now(), minutes, factor;
    LL_I2L(factor, 60 * PR_USEC_PER_SEC);
    LL_DIV(minutes, now, factor);
    PRUint32 result;
    LL_L2UI(result, minutes);
    return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation