101 |
hurd_task_id_t task_id, _hurd_cap_client_t *r_client) |
hurd_task_id_t task_id, _hurd_cap_client_t *r_client) |
102 |
{ |
{ |
103 |
error_t err = 0; |
error_t err = 0; |
104 |
_hurd_cap_client_entry_t entry; |
_hurd_cap_client_t *clientp; |
105 |
|
|
106 |
pthread_mutex_lock (&bucket->lock); |
pthread_mutex_lock (&bucket->lock); |
107 |
/* Look up the client by its ID. */ |
/* Look up the client by its ID. */ |
108 |
entry = hurd_table_lookup (&bucket->clients, client_id); |
clientp = hurd_table_lookup (&bucket->clients, client_id); |
109 |
if (!entry || entry->dead || entry->client->task_id != task_id) |
if (!clientp || (*clientp)->dead || (*clientp)->task_id != task_id) |
110 |
err = ECAP_NOREPLY; |
err = ECAP_NOREPLY; |
111 |
else |
else |
112 |
{ |
{ |
113 |
entry->refs++; |
(*clientp)->refs++; |
114 |
*r_client = entry->client; |
*r_client = *clientp; |
115 |
} |
} |
116 |
pthread_mutex_unlock (&bucket->lock); |
pthread_mutex_unlock (&bucket->lock); |
117 |
|
|
166 |
return err; |
return err; |
167 |
|
|
168 |
/* At this point, CLIENT_ID and CLIENT are valid, and we have one |
/* At this point, CLIENT_ID and CLIENT are valid, and we have one |
169 |
reference for the client entry. */ |
reference for the client. */ |
170 |
|
|
171 |
pthread_mutex_lock (&client->lock); |
pthread_mutex_lock (&client->lock); |
172 |
/* First, we have to check if the class is inhibited, and if it is, |
/* First, we have to check if the class is inhibited, and if it is, |
173 |
we have to wait until it is uninhibited. */ |
we have to wait until it is uninhibited. */ |
174 |
if (client->state == _HURD_CAP_STATE_BLACK) |
if (EXPECT_FALSE (client->state == _HURD_CAP_STATE_BLACK)) |
175 |
err = ECAP_NOREPLY; |
err = ECAP_NOREPLY; |
176 |
else if (client->state != _HURD_CAP_STATE_GREEN) |
else if (EXPECT_FALSE (client->state != _HURD_CAP_STATE_GREEN)) |
177 |
{ |
{ |
178 |
pthread_mutex_unlock (&client->lock); |
pthread_mutex_unlock (&client->lock); |
179 |
pthread_mutex_lock (&bucket->client_cond_lock); |
pthread_mutex_lock (&bucket->client_cond_lock); |
211 |
{ |
{ |
212 |
obj_entry = *entry; |
obj_entry = *entry; |
213 |
|
|
214 |
if (!obj_entry->external_refs) |
if (EXPECT_FALSE (!obj_entry->external_refs)) |
215 |
err = ECAP_NOREPLY; |
err = ECAP_NOREPLY; |
216 |
else if (obj_entry->dead) |
else if (EXPECT_FALSE (obj_entry->dead)) |
217 |
err = ECAP_DIED; |
err = ECAP_DIED; |
218 |
else |
else |
219 |
{ |
{ |
296 |
/* At this point, we have looked up the capability, acquired an |
/* At this point, we have looked up the capability, acquired an |
297 |
internal reference for its entry in the client table (which |
internal reference for its entry in the client table (which |
298 |
implicitely keeps a reference acquired for the object itself), |
implicitely keeps a reference acquired for the object itself), |
299 |
acquired a reference for the capability client entry in the |
acquired a reference for the capability client in the bucket, and |
300 |
bucket, and have added an item to the pending_rpcs lists in the |
have added an item to the pending_rpcs lists in the client, class |
301 |
client, class and object. The object is locked. With all this, |
and object. The object is locked. With all this, we can finally |
302 |
we can finally start to process the message for real. */ |
start to process the message for real. */ |
303 |
|
|
304 |
/* FIXME: Call the internal demuxer here, for things like reference |
/* FIXME: Call the internal demuxer here, for things like reference |
305 |
counter modification, cap passing etc. */ |
counter modification, cap passing etc. */ |