1 commit 3e1aa84e7f9f38815f5db9cd7654b1a9497cf6e4
2 Author: Ulrich Drepper <drepper@gmail.com>
3 Date: Fri Jan 20 22:39:54 2012 -0500
5 Do not cache negative results in nscd if these are transient
7 diff -rup a/nscd/aicache.c b/nscd/aicache.c
8 --- a/nscd/aicache.c 2012-01-24 20:32:58.906826425 -0700
9 +++ b/nscd/aicache.c 2012-01-24 20:42:17.663968882 -0700
10 @@ -511,9 +511,17 @@ next_nip:
12 TEMP_FAILURE_RETRY (send (fd, ¬found, total, MSG_NOSIGNAL));
14 - dataset = mempool_alloc (db, sizeof (struct dataset) + req->key_len, 1);
15 - /* If we cannot permanently store the result, so be it. */
16 - if (dataset != NULL)
17 + /* If we have a transient error or cannot permanently store the
18 + result, so be it. */
19 + if (rc4 == EAGAIN || __builtin_expect (db->negtimeout == 0, 0))
21 + /* Mark the old entry as obsolete. */
26 + else if ((dataset = mempool_alloc (db, (sizeof (struct dataset)
27 + + req->key_len), 1)) != NULL)
29 dataset->head.allocsize = sizeof (struct dataset) + req->key_len;
30 dataset->head.recsize = total;
31 diff -rup a/nscd/grpcache.c b/nscd/grpcache.c
32 --- a/nscd/grpcache.c 2012-01-24 20:32:58.910826427 -0700
33 +++ b/nscd/grpcache.c 2012-01-24 20:42:17.666968883 -0700
34 @@ -114,13 +114,21 @@ cache_addgr (struct database_dyn *db, in
36 total = sizeof (notfound);
38 - written = TEMP_FAILURE_RETRY (send (fd, ¬found, total,
41 + written = TEMP_FAILURE_RETRY (send (fd, ¬found, total,
46 - dataset = mempool_alloc (db, sizeof (struct dataset) + req->key_len,
48 - /* If we cannot permanently store the result, so be it. */
49 - if (dataset != NULL)
50 + /* If we have a transient error or cannot permanently store
51 + the result, so be it. */
52 + if (errno == EAGAIN || __builtin_expect (db->negtimeout == 0, 0))
54 + /* Mark the old entry as obsolete. */
58 + else if ((dataset = mempool_alloc (db, sizeof (struct dataset) + req->key_len, 1)) != NULL)
60 dataset->head.allocsize = sizeof (struct dataset) + req->key_len;
61 dataset->head.recsize = total;
62 diff -rup a/nscd/hstcache.c b/nscd/hstcache.c
63 --- a/nscd/hstcache.c 2012-01-24 20:32:58.911826427 -0700
64 +++ b/nscd/hstcache.c 2012-01-24 20:42:17.668968883 -0700
65 @@ -141,10 +141,16 @@ cache_addhst (struct database_dyn *db, i
66 MSG_NOSIGNAL)) != total)
69 - dataset = mempool_alloc (db, sizeof (struct dataset) + req->key_len,
71 - /* If we cannot permanently store the result, so be it. */
72 - if (dataset != NULL)
73 + /* If we have a transient error or cannot permanently store
74 + the result, so be it. */
75 + if (errval == EAGAIN || __builtin_expect (db->negtimeout == 0, 0))
77 + /* Mark the old entry as obsolete. */
81 + else if ((dataset = mempool_alloc (db, (sizeof (struct dataset)
82 + + req->key_len), 1)) != NULL)
84 dataset->head.allocsize = sizeof (struct dataset) + req->key_len;
85 dataset->head.recsize = total;
86 diff -rup a/nscd/initgrcache.c b/nscd/initgrcache.c
87 --- a/nscd/initgrcache.c 2012-01-24 20:32:58.912826427 -0700
88 +++ b/nscd/initgrcache.c 2012-01-24 20:42:17.671968883 -0700
89 @@ -202,10 +202,16 @@ addinitgroupsX (struct database_dyn *db,
90 written = TEMP_FAILURE_RETRY (send (fd, ¬found, total,
93 - dataset = mempool_alloc (db, sizeof (struct dataset) + req->key_len,
95 - /* If we cannot permanently store the result, so be it. */
96 - if (dataset != NULL)
97 + /* If we have a transient error or cannot permanently store
98 + the result, so be it. */
99 + if (all_tryagain || __builtin_expect (db->negtimeout == 0, 0))
101 + /* Mark the old entry as obsolete. */
103 + dh->usable = false;
105 + else if ((dataset = mempool_alloc (db, (sizeof (struct dataset)
106 + + req->key_len), 1)) != NULL)
108 dataset->head.allocsize = sizeof (struct dataset) + req->key_len;
109 dataset->head.recsize = total;
110 diff -rup a/nscd/pwdcache.c b/nscd/pwdcache.c
111 --- a/nscd/pwdcache.c 2012-01-24 20:32:58.914826427 -0700
112 +++ b/nscd/pwdcache.c 2012-01-24 20:42:17.671968883 -0700
113 @@ -124,10 +124,16 @@ cache_addpw (struct database_dyn *db, in
114 written = TEMP_FAILURE_RETRY (send (fd, ¬found, total,
117 - dataset = mempool_alloc (db, sizeof (struct dataset) + req->key_len,
119 - /* If we cannot permanently store the result, so be it. */
120 - if (dataset != NULL)
121 + /* If we have a transient error or cannot permanently store
122 + the result, so be it. */
123 + if (errno == EAGAIN || __builtin_expect (db->negtimeout == 0, 0))
125 + /* Mark the old entry as obsolete. */
127 + dh->usable = false;
129 + else if ((dataset = mempool_alloc (db, (sizeof (struct dataset)
130 + + req->key_len), 1)) != NULL)
132 dataset->head.allocsize = sizeof (struct dataset) + req->key_len;
133 dataset->head.recsize = total;
134 diff -rup a/nscd/servicescache.c b/nscd/servicescache.c
135 --- a/nscd/servicescache.c 2012-01-24 20:32:58.915826427 -0700
136 +++ b/nscd/servicescache.c 2012-01-24 20:42:17.672968884 -0700
137 @@ -102,15 +102,22 @@ cache_addserv (struct database_dyn *db,
139 /* We have no data. This means we send the standard reply for this
141 - total = sizeof (notfound);
142 + written = total = sizeof (notfound);
144 - written = TEMP_FAILURE_RETRY (send (fd, ¬found, total,
147 + written = TEMP_FAILURE_RETRY (send (fd, ¬found, total,
150 - dataset = mempool_alloc (db, sizeof (struct dataset) + req->key_len,
152 - /* If we cannot permanently store the result, so be it. */
153 - if (dataset != NULL)
154 + /* If we have a transient error or cannot permanently store
155 + the result, so be it. */
156 + if (errval == EAGAIN || __builtin_expect (db->negtimeout == 0, 0))
158 + /* Mark the old entry as obsolete. */
160 + dh->usable = false;
162 + else if ((dataset = mempool_alloc (db, (sizeof (struct dataset)
163 + + req->key_len), 1)) != NULL)
165 dataset->head.allocsize = sizeof (struct dataset) + req->key_len;
166 dataset->head.recsize = total;