diff options
author | Ulrich Drepper <drepper@redhat.com> | 2006-04-26 17:32:10 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2006-04-26 17:32:10 +0000 |
commit | 797ed6f7e17732cb207293d406d6cf14336f5de0 (patch) | |
tree | c264c8be61ed68f7da042492c4a5a5a823f3c4ce /nscd/grpcache.c | |
parent | 1f063dcadb802c57759e2ca2bf9c08e108bb3d70 (diff) | |
download | glibc-797ed6f7e17732cb207293d406d6cf14336f5de0.tar.gz glibc-797ed6f7e17732cb207293d406d6cf14336f5de0.tar.xz glibc-797ed6f7e17732cb207293d406d6cf14336f5de0.zip |
* nscd/nscd.h (struct database_dyn): Add propagate field.
* nscd/nscd_conf.c (nscd_parse_file): Parse auto-propagate lines. * nscd/nscd.conf: Add auto-propagate lines. * nscd/connections.c (dbs): Initialize .propagate fields. * nscd/grpcache.c (cache_addgr): Do not add ID entry for name lookups and vice versa if propagation is disabled for the database. * nscd/pwdcache.c (cache_addpw): Likewise.
Diffstat (limited to 'nscd/grpcache.c')
-rw-r--r-- | nscd/grpcache.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/nscd/grpcache.c b/nscd/grpcache.c index 4bc9977bc4..5a8fba4759 100644 --- a/nscd/grpcache.c +++ b/nscd/grpcache.c @@ -342,10 +342,10 @@ cache_addgr (struct database_dyn *db, int fd, request_header *req, marked with FIRST first. Otherwise we end up with dangling "pointers" in case a latter hash entry cannot be added. */ - bool first = req->type == GETGRBYNAME; + bool first = true; /* If the request was by GID, add that entry first. */ - if (req->type != GETGRBYNAME) + if (req->type == GETGRBYGID) { if (cache_add (GETGRBYGID, cp, key_offset, &dataset->head, true, db, owner) < 0) @@ -355,12 +355,14 @@ cache_addgr (struct database_dyn *db, int fd, request_header *req, dataset->head.usable = false; goto out; } + + first = false; } /* If the key is different from the name add a separate entry. */ else if (strcmp (key_copy, gr_name) != 0) { if (cache_add (GETGRBYNAME, key_copy, key_len + 1, - &dataset->head, first, db, owner) < 0) + &dataset->head, true, db, owner) < 0) { /* Could not allocate memory. Make sure the data gets discarded. */ @@ -372,11 +374,13 @@ cache_addgr (struct database_dyn *db, int fd, request_header *req, } /* We have to add the value for both, byname and byuid. */ - if (__builtin_expect (cache_add (GETGRBYNAME, gr_name, gr_name_len, - &dataset->head, first, db, owner) - == 0, 1)) + if ((req->type == GETGRBYNAME || db->propagate) + && __builtin_expect (cache_add (GETGRBYNAME, gr_name, + gr_name_len, + &dataset->head, first, db, owner) + == 0, 1)) { - if (req->type == GETGRBYNAME) + if (req->type == GETGRBYNAME && db->propagate) (void) cache_add (GETGRBYGID, cp, key_offset, &dataset->head, req->type != GETGRBYNAME, db, owner); } |