diff options
author | Ulrich Drepper <drepper@redhat.com> | 2004-09-12 10:04:03 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2004-09-12 10:04:03 +0000 |
commit | 8c89236fd36aac2a048c9a400572ef0ee642fb83 (patch) | |
tree | c94c0e5c3e8c994045f83d59fac7dff80771324c /nscd/hstcache.c | |
parent | 9d78d122725a52bd5389921bba9e36e99879f8d4 (diff) | |
download | glibc-8c89236fd36aac2a048c9a400572ef0ee642fb83.tar.gz glibc-8c89236fd36aac2a048c9a400572ef0ee642fb83.tar.xz glibc-8c89236fd36aac2a048c9a400572ef0ee642fb83.zip |
(cache_addhst): Sync also negative results to disk.
Diffstat (limited to 'nscd/hstcache.c')
-rw-r--r-- | nscd/hstcache.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/nscd/hstcache.c b/nscd/hstcache.c index 78e29fb3d1..4066aeec7f 100644 --- a/nscd/hstcache.c +++ b/nscd/hstcache.c @@ -136,6 +136,16 @@ cache_addhst (struct database_dyn *db, int fd, request_header *req, /* Copy the key data. */ memcpy (dataset->strdata, key, req->key_len); + /* If necessary, we also propagate the data to disk. */ + if (db->persistent) + { + // XXX async OK? + uintptr_t pval = (uintptr_t) dataset & ~pagesize_m1; + msync ((void *) pval, + ((uintptr_t) dataset & pagesize_m1) + + sizeof (struct dataset) + req->key_len, MS_ASYNC); + } + /* Now get the lock to safely insert the records. */ pthread_rwlock_rdlock (&db->lock); @@ -282,7 +292,7 @@ cache_addhst (struct database_dyn *db, int fd, request_header *req, && memcmp (&dataset->resp, dh->data, dh->allocsize - offsetof (struct dataset, resp)) == 0) { - /* The sata has not changed. We will just bump the + /* The data has not changed. We will just bump the timeout value. Note that the new record has been allocated on the stack and need not be freed. */ dh->timeout = dataset->head.timeout; @@ -386,15 +396,14 @@ lookup (int type, void *key, struct hostent *resultbufp, char *buffer, if (type == GETHOSTBYNAME) return __gethostbyname2_r (key, AF_INET, resultbufp, buffer, buflen, hst, &h_errno); - else if (type == GETHOSTBYNAMEv6) + if (type == GETHOSTBYNAMEv6) return __gethostbyname2_r (key, AF_INET6, resultbufp, buffer, buflen, hst, &h_errno); - else if (type == GETHOSTBYADDR) + if (type == GETHOSTBYADDR) return __gethostbyaddr_r (key, NS_INADDRSZ, AF_INET, resultbufp, buffer, buflen, hst, &h_errno); - else - return __gethostbyaddr_r (key, NS_IN6ADDRSZ, AF_INET6, resultbufp, buffer, - buflen, hst, &h_errno); + return __gethostbyaddr_r (key, NS_IN6ADDRSZ, AF_INET6, resultbufp, buffer, + buflen, hst, &h_errno); } |