summaryrefslogtreecommitdiff
path: root/pflocal/connq.h
diff options
context:
space:
mode:
authorNeal H. Walfield <neal@walfield.org>2005-05-17 10:31:09 +0100
committerThomas Schwinge <thomas@codesourcery.com>2012-07-26 12:32:47 +0200
commitd74fad98ca037a539de873a92c033d3d0364fca7 (patch)
treef04330df5addf1b5a83e0e7d32b91637306cf9fa /pflocal/connq.h
parentb4d90f14926247f087a719462a7c61e794afa489 (diff)
pflocal: Handle non-blocking connect with no pending acceptors.
* pflocal/connq.h (struct connq_request): Remove forward. (connq_listen): Wait for a request to be queued not until there is a connection attempt. Remove REQ parameter. Update callers. (connq_request_complete): Remove declaration. (connq_connect): Wait for a slot to queue a request not until there is an acceptor. Remove SOCK parameter. Update callers. (connq_connect_complete): New declaration. (connq_connect_cancel): New declaration. * pflocal/connq.c (struct connq): Remove fields noqueue, queue, length, head and tail. Add fields head, tail, count, max, connectors and num_connectors. That is, replace the circular buffer with a singly linked list. (qnext): Remove function. (struct connq_request): Remove field signal, lock, completed and err. Add field next. (connq_request_init): Rewrite according to new semantics. (connq_request_enqueue): New function. (connq_request_dequeue): New function. (connq_create): Update according to new semantics. (connq_destroy): Likewise. (connq_listen): Rewrite to not block until there is a connector but until there is a request in the queue. (connq_request_complete): Remove function. (connq_connect): Rewrite to not block until there is an acceptor but until there is space for a request. (connq_connect_complete): New function. (connq_connect_cancel): New function. (connq_compress): Remove dead code. (connq_set_length): Rewrite. * pflocal/socket.c (S_socket_connect): Create the server socket here... (S_socket_accept): ... not here.
Diffstat (limited to 'pflocal/connq.h')
-rw-r--r--pflocal/connq.h39
1 files changed, 19 insertions, 20 deletions
diff --git a/pflocal/connq.h b/pflocal/connq.h
index 1039bff9..9278d007 100644
--- a/pflocal/connq.h
+++ b/pflocal/connq.h
@@ -1,6 +1,6 @@
/* Connection queues
- Copyright (C) 1995 Free Software Foundation, Inc.
+ Copyright (C) 1995, 2012 Free Software Foundation, Inc.
Written by Miles Bader <miles@gnu.ai.mit.edu>
@@ -23,9 +23,8 @@
#include <errno.h>
-/* Unknown types */
+/* Forward. */
struct connq;
-struct connq_request;
struct sock;
/* Create a new listening queue, returning it in CQ. The resulting queue
@@ -36,26 +35,26 @@ error_t connq_create (struct connq **cq);
/* Destroy a queue. */
void connq_destroy (struct connq *cq);
-/* Wait for a connection attempt to be made on CQ, and return the connecting
- socket in SOCK, and a request tag in REQ. If REQ is NULL, the request is
- left in the queue, otherwise connq_request_complete must be called on REQ
- to allow the requesting thread to continue. If NOBLOCK is true,
- EWOULDBLOCK is returned when there are no immediate connections
- available. CQ should be unlocked. */
-error_t connq_listen (struct connq *cq, int noblock,
- struct connq_request **req, struct sock **sock);
+/* Return a connection request on CQ. If SOCK is NULL, the request is
+ left in the queue. If NOBLOCK is true, EWOULDBLOCK is returned
+ when there are no immediate connections available. */
+error_t connq_listen (struct connq *cq, int noblock, struct sock **sock);
-/* Return the error code ERR to the thread that made the listen request REQ,
- returned from a previous connq_listen. */
-void connq_request_complete (struct connq_request *req, error_t err);
+/* Try to connect SOCK with the socket listening on CQ. If NOBLOCK is
+ true, then return EWOULDBLOCK if there are no connections
+ immediately available. On success, this call must be followed up
+ either connq_connect_complete or connq_connect_cancel. */
+error_t connq_connect (struct connq *cq, int noblock);
+
+/* Follow up to connq_connect. Completes the connection, SOCK is the
+ new server socket. */
+void connq_connect_complete (struct connq *cq, struct sock *sock);
+
+/* Follow up to connq_connect. Cancel the connect. */
+void connq_connect_cancel (struct connq *cq);
/* Set CQ's queue length to LENGTH. Any sockets already waiting for a
- connections that are past the new length will fail with ECONNREFUSED. */
+ connections that are past the new length remain. */
error_t connq_set_length (struct connq *cq, int length);
-/* Try to connect SOCK with the socket listening on CQ. If NOBLOCK is true,
- then return EWOULDBLOCK immediately when there are no immediate
- connections available. Neither SOCK nor CQ should be locked. */
-error_t connq_connect (struct connq *cq, int noblock, struct sock *sock);
-
#endif /* __CONNQ_H__ */