1 |
/* Listen queue functions |
/* Listen queue functions |
2 |
|
|
3 |
Copyright (C) 1995, 1996 Free Software Foundation, Inc. |
Copyright (C) 1995,96,2001 Free Software Foundation, Inc. |
4 |
|
|
5 |
Written by Miles Bader <miles@gnu.ai.mit.edu> |
Written by Miles Bader <miles@gnu.org> |
6 |
|
|
7 |
This program is free software; you can redistribute it and/or |
This program is free software; you can redistribute it and/or |
8 |
modify it under the terms of the GNU General Public License as |
modify it under the terms of the GNU General Public License as |
132 |
to allow the requesting thread to continue. If NOBLOCK is true, |
to allow the requesting thread to continue. If NOBLOCK is true, |
133 |
EWOULDBLOCK is returned when there are no immediate connections |
EWOULDBLOCK is returned when there are no immediate connections |
134 |
available. */ |
available. */ |
135 |
error_t |
error_t |
136 |
connq_listen (struct connq *cq, int noblock, |
connq_listen (struct connq *cq, int noblock, |
137 |
struct connq_request **req, struct sock **sock) |
struct connq_request **req, struct sock **sock) |
138 |
{ |
{ |
140 |
|
|
141 |
if (noblock && cq->head == cq->tail) |
if (noblock && cq->head == cq->tail) |
142 |
{ |
{ |
143 |
mutex_unlock (&cq->lock); |
mutex_unlock (&cq->lock); |
144 |
return EWOULDBLOCK; |
return EWOULDBLOCK; |
145 |
} |
} |
146 |
|
|
150 |
if (hurd_condition_wait (&cq->listeners, &cq->lock)) |
if (hurd_condition_wait (&cq->listeners, &cq->lock)) |
151 |
{ |
{ |
152 |
cq->num_listeners--; |
cq->num_listeners--; |
153 |
mutex_unlock (&cq->lock); |
mutex_unlock (&cq->lock); |
154 |
return EINTR; |
return EINTR; |
155 |
} |
} |
156 |
|
|
167 |
|
|
168 |
mutex_unlock (&cq->lock); |
mutex_unlock (&cq->lock); |
169 |
|
|
170 |
return 0; |
return 0; |
171 |
} |
} |
172 |
|
|
173 |
/* Return the error code ERR to the thread that made the listen request REQ, |
/* Return the error code ERR to the thread that made the listen request REQ, |
229 |
return err; |
return err; |
230 |
} |
} |
231 |
|
|
232 |
|
#if 0 |
233 |
/* `Compresses' CQ, by removing any NULL entries. CQ should be locked. */ |
/* `Compresses' CQ, by removing any NULL entries. CQ should be locked. */ |
234 |
static void |
static void |
235 |
connq_compress (struct connq *cq) |
connq_compress (struct connq *cq) |
250 |
/* Move back tail to only include what we kept in the queue. */ |
/* Move back tail to only include what we kept in the queue. */ |
251 |
cq->tail = comp_tail; |
cq->tail = comp_tail; |
252 |
} |
} |
253 |
|
#endif |
254 |
|
|
255 |
/* Set CQ's queue length to LENGTH. Any sockets already waiting for a |
/* Set CQ's queue length to LENGTH. Any sockets already waiting for a |
256 |
connections that are past the new length will fail with ECONNREFUSED. */ |
connections that are past the new length will fail with ECONNREFUSED. */ |
257 |
error_t |
error_t |
258 |
connq_set_length (struct connq *cq, int length) |
connq_set_length (struct connq *cq, int length) |
259 |
{ |
{ |
260 |
mutex_lock (&cq->lock); |
mutex_lock (&cq->lock); |