~ubuntu-branches/ubuntu/precise/eglibc/precise-201308281639

« back to all changes in this revision

Viewing changes to nscd/initgrcache.c

  • Committer: Package Import Robot
  • Author(s): Matthias Klose
  • Date: 2012-02-08 01:58:09 UTC
  • mfrom: (1.5.3) (288.1.12 precise)
  • Revision ID: package-import@ubuntu.com-20120208015809-ulscst7uteq3e22z
Tags: 2.15~pre6-0ubuntu10
Merge from Debian (r5151, 2.13-26).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* Cache handling for host lookup.
2
 
   Copyright (C) 2004, 2005, 2006, 2008, 2009 Free Software Foundation, Inc.
 
2
   Copyright (C) 2004-2006, 2008, 2009, 2011 Free Software Foundation, Inc.
3
3
   This file is part of the GNU C Library.
4
4
   Contributed by Ulrich Drepper <drepper@redhat.com>, 2004.
5
5
 
52
52
#include "../grp/compat-initgroups.c"
53
53
 
54
54
 
55
 
static void
 
55
static time_t
56
56
addinitgroupsX (struct database_dyn *db, int fd, request_header *req,
57
57
                void *key, uid_t uid, struct hashentry *const he,
58
58
                struct datahead *dh)
174
174
 
175
175
  ssize_t total;
176
176
  ssize_t written;
 
177
  time_t timeout;
177
178
 out:
 
179
  timeout = MAX_TIMEOUT_VALUE;
178
180
  if (!any_success)
179
181
    {
180
182
      /* Nothing found.  Create a negative result record.  */
188
190
          if (reload_count != UINT_MAX && dh->nreloads == reload_count)
189
191
            /* Do not reset the value if we never not reload the record.  */
190
192
            dh->nreloads = reload_count - 1;
 
193
 
 
194
          /* Reload with the same time-to-live value.  */
 
195
          timeout = dh->timeout = time (NULL) + db->postimeout;
191
196
        }
192
197
      else
193
198
        {
197
202
            written = TEMP_FAILURE_RETRY (send (fd, &notfound, total,
198
203
                                                MSG_NOSIGNAL));
199
204
 
200
 
          dataset = mempool_alloc (db, sizeof (struct dataset) + req->key_len,
201
 
                                   1);
202
205
          /* If we cannot permanently store the result, so be it.  */
203
 
          if (dataset != NULL)
 
206
          if (__builtin_expect (db->negtimeout == 0, 0))
 
207
            {
 
208
              /* Mark the old entry as obsolete.  */
 
209
              if (dh != NULL)
 
210
                dh->usable = false;
 
211
            }
 
212
          else if ((dataset = mempool_alloc (db, (sizeof (struct dataset)
 
213
                                                  + req->key_len), 1)) != NULL)
204
214
            {
205
215
              dataset->head.allocsize = sizeof (struct dataset) + req->key_len;
206
216
              dataset->head.recsize = total;
209
219
              dataset->head.usable = true;
210
220
 
211
221
              /* Compute the timeout time.  */
212
 
              dataset->head.timeout = time (NULL) + db->negtimeout;
 
222
              timeout = dataset->head.timeout = time (NULL) + db->negtimeout;
213
223
 
214
224
              /* This is the reply.  */
215
225
              memcpy (&dataset->resp, &notfound, total);
273
283
      dataset->head.usable = true;
274
284
 
275
285
      /* Compute the timeout time.  */
276
 
      dataset->head.timeout = time (NULL) + db->postimeout;
 
286
      timeout = dataset->head.timeout = time (NULL) + db->postimeout;
277
287
 
278
288
      dataset->resp.version = NSCD_VERSION;
279
289
      dataset->resp.found = 1;
401
411
      dbg_log (_("short write in %s: %s"), __FUNCTION__,
402
412
               strerror_r (errno, buf, sizeof (buf)));
403
413
    }
 
414
 
 
415
  return timeout;
404
416
}
405
417
 
406
418
 
412
424
}
413
425
 
414
426
 
415
 
void
 
427
time_t
416
428
readdinitgroups (struct database_dyn *db, struct hashentry *he,
417
429
                 struct datahead *dh)
418
430
{
422
434
      .key_len = he->len
423
435
    };
424
436
 
425
 
  addinitgroupsX (db, -1, &req, db->data + he->key, he->owner, he, dh);
 
437
  return addinitgroupsX (db, -1, &req, db->data + he->key, he->owner, he, dh);
426
438
}