]>
Commit | Line | Data |
---|---|---|
12788f63 MT |
1 | commit 3e1aa84e7f9f38815f5db9cd7654b1a9497cf6e4 |
2 | Author: Ulrich Drepper <drepper@gmail.com> | |
3 | Date: Fri Jan 20 22:39:54 2012 -0500 | |
4 | ||
5 | Do not cache negative results in nscd if these are transient | |
6 | ||
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: | |
11 | if (fd != -1) | |
12 | TEMP_FAILURE_RETRY (send (fd, ¬found, total, MSG_NOSIGNAL)); | |
13 | ||
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)) | |
20 | + { | |
21 | + /* Mark the old entry as obsolete. */ | |
22 | + if (dh != NULL) | |
23 | + dh->usable = false; | |
24 | + dataset = NULL; | |
25 | + } | |
26 | + else if ((dataset = mempool_alloc (db, (sizeof (struct dataset) | |
27 | + + req->key_len), 1)) != NULL) | |
28 | { | |
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 | |
35 | case. */ | |
36 | total = sizeof (notfound); | |
37 | ||
38 | - written = TEMP_FAILURE_RETRY (send (fd, ¬found, total, | |
39 | - MSG_NOSIGNAL)); | |
40 | + if (fd != -1) | |
41 | + written = TEMP_FAILURE_RETRY (send (fd, ¬found, total, | |
42 | + MSG_NOSIGNAL)); | |
43 | + else | |
44 | + written = total; | |
45 | ||
46 | - dataset = mempool_alloc (db, sizeof (struct dataset) + req->key_len, | |
47 | - 1); | |
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)) | |
53 | + { | |
54 | + /* Mark the old entry as obsolete. */ | |
55 | + if (dh != NULL) | |
56 | + dh->usable = false; | |
57 | + } | |
58 | + else if ((dataset = mempool_alloc (db, sizeof (struct dataset) + req->key_len, 1)) != NULL) | |
59 | { | |
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) | |
67 | all_written = false; | |
68 | ||
69 | - dataset = mempool_alloc (db, sizeof (struct dataset) + req->key_len, | |
70 | - 1); | |
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)) | |
76 | + { | |
77 | + /* Mark the old entry as obsolete. */ | |
78 | + if (dh != NULL) | |
79 | + dh->usable = false; | |
80 | + } | |
81 | + else if ((dataset = mempool_alloc (db, (sizeof (struct dataset) | |
82 | + + req->key_len), 1)) != NULL) | |
83 | { | |
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, | |
91 | MSG_NOSIGNAL)); | |
92 | ||
93 | - dataset = mempool_alloc (db, sizeof (struct dataset) + req->key_len, | |
94 | - 1); | |
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)) | |
100 | + { | |
101 | + /* Mark the old entry as obsolete. */ | |
102 | + if (dh != NULL) | |
103 | + dh->usable = false; | |
104 | + } | |
105 | + else if ((dataset = mempool_alloc (db, (sizeof (struct dataset) | |
106 | + + req->key_len), 1)) != NULL) | |
107 | { | |
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, | |
115 | MSG_NOSIGNAL)); | |
116 | ||
117 | - dataset = mempool_alloc (db, sizeof (struct dataset) + req->key_len, | |
118 | - 1); | |
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)) | |
124 | + { | |
125 | + /* Mark the old entry as obsolete. */ | |
126 | + if (dh != NULL) | |
127 | + dh->usable = false; | |
128 | + } | |
129 | + else if ((dataset = mempool_alloc (db, (sizeof (struct dataset) | |
130 | + + req->key_len), 1)) != NULL) | |
131 | { | |
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, | |
138 | { | |
139 | /* We have no data. This means we send the standard reply for this | |
140 | case. */ | |
141 | - total = sizeof (notfound); | |
142 | + written = total = sizeof (notfound); | |
143 | ||
144 | - written = TEMP_FAILURE_RETRY (send (fd, ¬found, total, | |
145 | - MSG_NOSIGNAL)); | |
146 | + if (fd != -1) | |
147 | + written = TEMP_FAILURE_RETRY (send (fd, ¬found, total, | |
148 | + MSG_NOSIGNAL)); | |
149 | ||
150 | - dataset = mempool_alloc (db, sizeof (struct dataset) + req->key_len, | |
151 | - 1); | |
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)) | |
157 | + { | |
158 | + /* Mark the old entry as obsolete. */ | |
159 | + if (dh != NULL) | |
160 | + dh->usable = false; | |
161 | + } | |
162 | + else if ((dataset = mempool_alloc (db, (sizeof (struct dataset) | |
163 | + + req->key_len), 1)) != NULL) | |
164 | { | |
165 | dataset->head.allocsize = sizeof (struct dataset) + req->key_len; | |
166 | dataset->head.recsize = total; |