- pthread_rwlock_unlock (&grplock);
- }
- else
- {
- int buflen = 1024;
- char *buffer = malloc (buflen);
- int status;
-
- if (debug_flag)
- dbg_log (_("Doesn't found \"%d\" in cache !\n"), gid);
-
- pthread_rwlock_unlock (&grplock);
-
- pthread_rwlock_rdlock (&neglock);
- status = cache_search_neg (param->key);
- pthread_rwlock_unlock (&neglock);
-
- if (status == 0)
- {
- while (buffer != NULL
- && (getgrgid_r (gid, &resultbuf, buffer, buflen, &grp) != 0)
- && errno == ERANGE)
- {
- errno = 0;
- buflen += 1024;
- buffer = realloc (buffer, buflen);
- }
-
- if (buffer != NULL && grp != NULL)
- {
- struct group *tmp;
-
- ++posmiss;
- pthread_rwlock_wrlock (&grplock);
- /* While we are waiting on the lock, somebody else could
- add this entry. */
- tmp = cache_search_gid (gid);
- if (tmp == NULL)
- add_cache (grp);
- pthread_rwlock_unlock (&grplock);
- }
- else
- {
- ++negmiss;
- pthread_rwlock_wrlock (&neglock);
- add_negcache (param->key);
- pthread_rwlock_unlock (&neglock);
- }
- }
- else
- ++neghit;
-
- gr_send_answer (param->conn, grp);
- close_socket (param->conn);
- if (buffer != NULL)
- free (buffer);
- }
- free (param->key);
- free (param);
- return NULL;
-}
-
-void *
-grptable_update (void *v)
-{
- time_t now;
- int i;
+void
+addgrbygid (struct database *db, int fd, request_header *req, void *key)
+{
+ /* Search for the entry matching the key. Please note that we don't
+ look again in the table whether the dataset is now available. We
+ simply insert it. It does not matter if it is in there twice. The
+ pruning function only will look at the timestamp. */
+ int buflen = 256;
+ char *buffer = alloca (buflen);
+ struct group resultbuf;
+ struct group *grp;
+ gid_t gid = atol (key);