summaryrefslogtreecommitdiff
path: root/nscd/connections.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2003-04-26 04:15:50 +0000
committerUlrich Drepper <drepper@redhat.com>2003-04-26 04:15:50 +0000
commitc86e6aec55e00afc6aca584b13ce8e64ff305d51 (patch)
tree9ff99e44e223a8ddf051fa116698f59296a389be /nscd/connections.c
parent468777e1d0dbd6cb8bcaee244a954824d5c84167 (diff)
Update.
* nscd/cache.c (cache_search): Keep track of how many chain links we searched and update table statistics. (cache_add): Keep track of how many values are in the table. (prune_cache): Likewise. Keep track of locking success. Print messages about removed entries in separate pass. * nscd/connections.c (handle_request): Don't print debug message here. The caller will do it. Keep track of locking success. (nscd_run): Print debug message. Also print PID of the client process. * nscd/nscd.c (start_time): New variable. (main): Remember start time. * nscd/nscd.h: Declare start_time. (struct database): Add more members for new statistics. * nscd/nscd_stat.c: Add support for sending, receiving, and printing of new statistics.
Diffstat (limited to 'nscd/connections.c')
-rw-r--r--nscd/connections.c37
1 files changed, 32 insertions, 5 deletions
diff --git a/nscd/connections.c b/nscd/connections.c
index 2e87269d10..3628877dab 100644
--- a/nscd/connections.c
+++ b/nscd/connections.c
@@ -256,10 +256,6 @@ invalidate_cache (char *key)
static void
handle_request (int fd, request_header *req, void *key, uid_t uid)
{
- if (__builtin_expect (debug_level, 0) > 0)
- dbg_log (_("handle_request: request received (Version = %d)"),
- req->version);
-
if (__builtin_expect (req->version, NSCD_VERSION) != NSCD_VERSION)
{
if (debug_level > 0)
@@ -309,7 +305,11 @@ cannot handle old request version %d; current version is %d"),
}
/* Be sure we can read the data. */
- pthread_rwlock_rdlock (&db->lock);
+ if (__builtin_expect (pthread_rwlock_tryrdlock (&db->lock) != 0, 0))
+ {
+ ++db->rdlockdelayed;
+ pthread_rwlock_rdlock (&db->lock);
+ }
/* See whether we can handle it from the cache. */
cached = (struct hashentry *) cache_search (req->type, key, req->key_len,
@@ -465,6 +465,9 @@ nscd_run (void *p)
request_header req;
char buf[256];
uid_t uid = 0;
+#ifdef SO_PEERCRED
+ pid_t pid = 0;
+#endif
if (__builtin_expect (fd, 0) < 0)
{
@@ -505,6 +508,17 @@ nscd_run (void *p)
if (req.type < GETPWBYNAME || req.type > LASTDBREQ
|| secure[serv2db[req.type]])
uid = caller.uid;
+
+ pid = caller.pid;
+ }
+ else if (__builtin_expect (debug_level > 0, 0))
+ {
+ struct ucred caller;
+ socklen_t optlen = sizeof (caller);
+
+ if (getsockopt (fd, SOL_SOCKET, SO_PEERCRED,
+ &caller, &optlen) == 0)
+ pid = caller.pid;
}
#endif
@@ -535,6 +549,19 @@ nscd_run (void *p)
continue;
}
+ if (__builtin_expect (debug_level, 0) > 0)
+ {
+#ifdef SO_PEERCRED
+ if (pid != 0)
+ dbg_log (_("\
+handle_request: request received (Version = %d) from PID %ld"),
+ req.version, (long int) pid);
+ else
+#endif
+ dbg_log (_("\
+handle_request: request received (Version = %d)"), req.version);
+ }
+
/* Phew, we got all the data, now process it. */
handle_request (fd, &req, keybuf, uid);