180 |
} |
} |
181 |
|
|
182 |
pthread_mutex_lock (&bucket->lock); |
pthread_mutex_lock (&bucket->lock); |
183 |
/* Somebody else might have been faster. */ |
/* Since we dropped the bucket lock during the allocation (which is |
184 |
|
potentially long) we need to check that somebody else didn't |
185 |
|
already allocate a client data structure. If so, we can just use |
186 |
|
that. Otherwise, we continue. */ |
187 |
client = (_hurd_cap_client_t) hurd_ihash_find (&bucket->clients_reverse, |
client = (_hurd_cap_client_t) hurd_ihash_find (&bucket->clients_reverse, |
188 |
task_id); |
task_id); |
189 |
if (client) |
if (client) |
191 |
entry = (_hurd_cap_client_entry_t) |
entry = (_hurd_cap_client_entry_t) |
192 |
HURD_TABLE_LOOKUP (&bucket->clients, client->id); |
HURD_TABLE_LOOKUP (&bucket->clients, client->id); |
193 |
if (entry->dead) |
if (entry->dead) |
194 |
err = EINVAL; /* FIXME: A more appropriate code? */ |
{ |
195 |
|
err = EINVAL; /* FIXME: A more appropriate code? */ |
196 |
|
pthread_mutex_unlock (&bucket->lock); |
197 |
|
} |
198 |
else |
else |
199 |
{ |
{ |
200 |
/* Somebody else was indeed faster. Use the existing entry. */ |
/* Somebody else was indeed faster. Use the existing entry. */ |
201 |
entry->refs++; |
entry->refs++; |
202 |
|
pthread_mutex_unlock (&bucket->lock); |
203 |
|
_hurd_cap_client_dealloc (bucket, *r_client); |
204 |
*r_client = entry->client; |
*r_client = entry->client; |
205 |
} |
} |
|
pthread_mutex_unlock (&bucket->lock); |
|
|
_hurd_cap_client_dealloc (bucket, *r_client); |
|
206 |
return err; |
return err; |
207 |
} |
} |
208 |
|
|