2011-01-15 Ulrich Drepper [BZ #6812] * nscd/hstcache.c (tryagain): Define. (cache_addhst): Return tryagain not notfound for temporary errors. (addhstbyX): Also set h_errno to TRY_AGAIN when memory allocation failed. Index: glibc-2.12-2-gc4ccff1/nscd/hstcache.c =================================================================== --- glibc-2.12-2-gc4ccff1.orig/nscd/hstcache.c +++ glibc-2.12-2-gc4ccff1/nscd/hstcache.c @@ -77,6 +77,20 @@ static const hst_response_header notfoun }; +/* This is the standard reply in case there are temporary problems. */ +static const hst_response_header tryagain = +{ + .version = NSCD_VERSION, + .found = 0, + .h_name_len = 0, + .h_aliases_cnt = 0, + .h_addrtype = -1, + .h_length = -1, + .h_addr_list_cnt = 0, + .error = TRY_AGAIN +}; + + static void cache_addhst (struct database_dyn *db, int fd, request_header *req, const void *key, struct hostent *hst, uid_t owner, @@ -111,11 +125,15 @@ cache_addhst (struct database_dyn *db, i else { /* We have no data. This means we send the standard reply for this - case. */ + case. Possibly this is only temporary. */ ssize_t total = sizeof (notfound); + assert (sizeof (notfound) == sizeof (tryagain)); + + const hst_response_header *resp = (errval == EAGAIN + ? &tryagain : ¬found); if (fd != -1 && - TEMP_FAILURE_RETRY (send (fd, ¬found, total, + TEMP_FAILURE_RETRY (send (fd, resp, total, MSG_NOSIGNAL)) != total) all_written = false; @@ -135,7 +153,7 @@ cache_addhst (struct database_dyn *db, i ? db->negtimeout : ttl); /* This is the reply. */ - memcpy (&dataset->resp, ¬found, total); + memcpy (&dataset->resp, resp, total); /* Copy the key data. */ memcpy (dataset->strdata, key, req->key_len); @@ -490,6 +508,7 @@ addhstbyX (struct database_dyn *db, int /* We set the error to indicate this is (possibly) a temporary error and that it does not mean the entry is not available at all. */ + h_errno = TRY_AGAIN; errval = EAGAIN; break; }