about summary refs log tree commit diff
path: root/nscd/hstcache.c
diff options
context:
space:
mode:
Diffstat (limited to 'nscd/hstcache.c')
-rw-r--r--nscd/hstcache.c27
1 files changed, 9 insertions, 18 deletions
diff --git a/nscd/hstcache.c b/nscd/hstcache.c
index a79b67aa7e..d4f1ad2fc4 100644
--- a/nscd/hstcache.c
+++ b/nscd/hstcache.c
@@ -152,15 +152,11 @@ cache_addhst (struct database_dyn *db, int fd, request_header *req,
 	  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;
-	      dataset->head.notfound = true;
-	      dataset->head.nreloads = 0;
-	      dataset->head.usable = true;
-
-	      /* Compute the timeout time.  */
-	      dataset->head.ttl = ttl == INT32_MAX ? db->negtimeout : ttl;
-	      timeout = dataset->head.timeout = t + dataset->head.ttl;
+	      timeout = datahead_init_neg (&dataset->head,
+					   (sizeof (struct dataset)
+					    + req->key_len), total,
+					   (ttl == INT32_MAX
+					    ? db->negtimeout : ttl));
 
 	      /* This is the reply.  */
 	      memcpy (&dataset->resp, resp, total);
@@ -257,15 +253,10 @@ cache_addhst (struct database_dyn *db, int fd, request_header *req,
 	  alloca_used = true;
 	}
 
-      dataset->head.allocsize = total + req->key_len;
-      dataset->head.recsize = total - offsetof (struct dataset, resp);
-      dataset->head.notfound = false;
-      dataset->head.nreloads = he == NULL ? 0 : (dh->nreloads + 1);
-      dataset->head.usable = true;
-
-      /* Compute the timeout time.  */
-      dataset->head.ttl = ttl == INT32_MAX ? db->postimeout : ttl;
-      timeout = dataset->head.timeout = t + dataset->head.ttl;
+      timeout = datahead_init_pos (&dataset->head, total + req->key_len,
+				   total - offsetof (struct dataset, resp),
+				   he == NULL ? 0 : dh->nreloads + 1,
+				   ttl == INT32_MAX ? db->postimeout : ttl);
 
       dataset->resp.version = NSCD_VERSION;
       dataset->resp.found = 1;