Skip to content

Commit

Permalink
* nscd/cache.c (prune_cache): Add more debug output. Only for
Browse files Browse the repository at this point in the history
	debug level 3 and higher and very verbose.
  • Loading branch information
Ulrich Drepper committed Aug 16, 2005
1 parent 80ea303 commit a757fda
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
3 changes: 3 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
2005-08-16 Ulrich Drepper <drepper@redhat.com>

* nscd/cache.c (prune_cache): Add more debug output. Only for
debug level 3 and higher and very verbose.

* nscd/cache.c (prune_cache): Use stat64 not stat.
* nscd/connections.c (nscd_init): Likewise.

Expand Down
30 changes: 27 additions & 3 deletions nscd/cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <atomic.h>
#include <errno.h>
#include <error.h>
#include <inttypes.h>
#include <limits.h>
#include <stdlib.h>
#include <string.h>
Expand Down Expand Up @@ -238,6 +239,10 @@ prune_cache (struct database_dyn *table, time_t now)
char *const data = table->data;
bool any = false;

if (__builtin_expect (debug_level > 2, 0))
dbg_log (_("pruning %s cache; time %ld"),
dbnames[table - dbs], (long int) now);

do
{
ref_t run = table->head->array[--cnt];
Expand All @@ -247,6 +252,25 @@ prune_cache (struct database_dyn *table, time_t now)
struct hashentry *runp = (struct hashentry *) (data + run);
struct datahead *dh = (struct datahead *) (data + runp->packet);

/* Some debug support. */
if (__builtin_expect (debug_level > 2, 0))
{
char buf[INET6_ADDRSTRLEN];
const char *str;

if (runp->type == GETHOSTBYADDR || runp->type == GETHOSTBYADDRv6)
{
inet_ntop (runp->type == GETHOSTBYADDR ? AF_INET : AF_INET6,
data + runp->key, buf, sizeof (buf));
str = buf;
}
else
str = data + runp->key;

dbg_log (_("considering %s entry \"%s\", timeout %" PRIu64),
serv2str[runp->type], str, dh->timeout);
}

/* Check whether the entry timed out. */
if (dh->timeout < now)
{
Expand Down Expand Up @@ -401,7 +425,7 @@ prune_cache (struct database_dyn *table, time_t now)
/* Make sure the data is saved to disk. */
if (table->persistent)
msync (table->head,
table->data + table->head->first_free - (char *) table->head,
data + table->head->first_free - (char *) table->head,
MS_ASYNC);

/* One extra pass if we do debugging. */
Expand All @@ -417,11 +441,11 @@ prune_cache (struct database_dyn *table, time_t now)
if (runp->type == GETHOSTBYADDR || runp->type == GETHOSTBYADDRv6)
{
inet_ntop (runp->type == GETHOSTBYADDR ? AF_INET : AF_INET6,
table->data + runp->key, buf, sizeof (buf));
data + runp->key, buf, sizeof (buf));
str = buf;
}
else
str = table->data + runp->key;
str = data + runp->key;

dbg_log ("remove %s entry \"%s\"", serv2str[runp->type], str);

Expand Down

0 comments on commit a757fda

Please sign in to comment.