Handle nscd negtimeout==0
Andreas Jaeger
aj@suse.de
Fri Jul 1 20:26:00 GMT 2011
We have the following patch in our glibc version since quite some time and it seems we never upstreamed it ;-(
The code handles the situation that negtimeout is 0 - in this case, no data is stored at all in the database,
Andreas
2011-07-01 Thorsten Kukuk <kukuk@suse.de>
* nscd/pwdcache.c (cache_addpw): Handle zero negtimeout.
* nscd/initgrcache.c (addinitgroupsX): Likewise.
* nscd/hstcache.c (cache_addhst): Likewise.
* nscd/grpcache.c (cache_addgr): Likewise.
* nscd/aicache.c (addhstaiX): Likewise
Index: nscd/aicache.c
===================================================================
--- nscd/aicache.c.orig
+++ nscd/aicache.c
@@ -504,9 +504,15 @@ next_nip:
if (fd != -1)
TEMP_FAILURE_RETRY (send (fd, ¬found, total, MSG_NOSIGNAL));
- dataset = mempool_alloc (db, sizeof (struct dataset) + req->key_len, 1);
/* If we cannot permanently store the result, so be it. */
- if (dataset != NULL)
+ if (db->negtimeout == 0)
+ {
+ /* Mark the old entry as obsolete. */
+ if (dh != NULL)
+ dh->usable = false;
+ dataset = NULL;
+ }
+ else if ((dataset = mempool_alloc (db, sizeof (struct dataset) + req->key_len, 1)) != NULL)
{
dataset->head.allocsize = sizeof (struct dataset) + req->key_len;
dataset->head.recsize = total;
Index: nscd/grpcache.c
===================================================================
--- nscd/grpcache.c.orig
+++ nscd/grpcache.c
@@ -113,10 +113,14 @@ cache_addgr (struct database_dyn *db, in
written = TEMP_FAILURE_RETRY (send (fd, ¬found, total,
MSG_NOSIGNAL));
- dataset = mempool_alloc (db, sizeof (struct dataset) + req->key_len,
- 1);
/* If we cannot permanently store the result, so be it. */
- if (dataset != NULL)
+ if (db->negtimeout == 0)
+ {
+ /* Mark the old entry as obsolete. */
+ if (dh != NULL)
+ dh->usable = false;
+ }
+ else if ((dataset = mempool_alloc (db, sizeof (struct dataset) + req->key_len, 1)) != NULL)
{
dataset->head.allocsize = sizeof (struct dataset) + req->key_len;
dataset->head.recsize = total;
Index: nscd/hstcache.c
===================================================================
--- nscd/hstcache.c.orig
+++ nscd/hstcache.c
@@ -119,10 +119,14 @@ cache_addhst (struct database_dyn *db, i
MSG_NOSIGNAL)) != total)
all_written = false;
- dataset = mempool_alloc (db, sizeof (struct dataset) + req->key_len,
- 1);
/* If we cannot permanently store the result, so be it. */
- if (dataset != NULL)
+ if (db->negtimeout == 0)
+ {
+ /* Mark the old entry as obsolete. */
+ if (dh != NULL)
+ dh->usable = false;
+ }
+ else if ((dataset = mempool_alloc (db, sizeof (struct dataset) + req->key_len, 1)) != NULL)
{
dataset->head.allocsize = sizeof (struct dataset) + req->key_len;
dataset->head.recsize = total;
Index: nscd/initgrcache.c
===================================================================
--- nscd/initgrcache.c.orig
+++ nscd/initgrcache.c
@@ -197,10 +197,14 @@ addinitgroupsX (struct database_dyn *db,
written = TEMP_FAILURE_RETRY (send (fd, ¬found, total,
MSG_NOSIGNAL));
- dataset = mempool_alloc (db, sizeof (struct dataset) + req->key_len,
- 1);
/* If we cannot permanently store the result, so be it. */
- if (dataset != NULL)
+ if (db->negtimeout == 0)
+ {
+ /* Mark the old entry as obsolete. */
+ if (dh != NULL)
+ dh->usable = false;
+ }
+ else if ((dataset = mempool_alloc (db, sizeof (struct dataset) + req->key_len, 1)) != NULL)
{
dataset->head.allocsize = sizeof (struct dataset) + req->key_len;
dataset->head.recsize = total;
Index: nscd/pwdcache.c
===================================================================
--- nscd/pwdcache.c.orig
+++ nscd/pwdcache.c
@@ -120,10 +120,14 @@ cache_addpw (struct database_dyn *db, in
written = TEMP_FAILURE_RETRY (send (fd, ¬found, total,
MSG_NOSIGNAL));
- dataset = mempool_alloc (db, sizeof (struct dataset) + req->key_len,
- 1);
/* If we cannot permanently store the result, so be it. */
- if (dataset != NULL)
+ if (db->negtimeout == 0)
+ {
+ /* Mark the old entry as obsolete. */
+ if (dh != NULL)
+ dh->usable = false;
+ }
+ else if ((dataset = mempool_alloc (db, sizeof (struct dataset) + req->key_len, 1)) != NULL)
{
dataset->head.allocsize = sizeof (struct dataset) + req->key_len;
dataset->head.recsize = total;
--
Andreas Jaeger, Program Manager openSUSE
aj@{suse.com,opensuse.org} Twitter/Identica: jaegerandi
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer, HRB 16746 (AG Nürnberg)
GPG fingerprint = 93A3 365E CE47 B889 DF7F FED1 389A 563C C272 A126
More information about the Libc-alpha
mailing list