diff options
author | Marcus Brinkmann <marcus@gnu.org> | 2001-02-12 17:24:36 +0000 |
---|---|---|
committer | Marcus Brinkmann <marcus@gnu.org> | 2001-02-12 17:24:36 +0000 |
commit | 2888457f4fc3ebfd5ec6e4f6baf5e02223b1c5c6 (patch) | |
tree | e5c428b9e17036ecffafcdbc7b14e6d9107fb706 /pflocal | |
parent | 9fc0f76454246c2c2f3984928627a22c76beec5a (diff) |
2001-02-11 Marcus Brinkmann <marcus@gnu.org>
* connq.c (connq_destroy): New function.
* connq.h: Prototype connq_destroy.
* sock.c (sock_free): Call connq_destroy when listen or connect
queue exist.
Diffstat (limited to 'pflocal')
-rw-r--r-- | pflocal/ChangeLog | 7 | ||||
-rw-r--r-- | pflocal/connq.c | 14 | ||||
-rw-r--r-- | pflocal/connq.h | 3 | ||||
-rw-r--r-- | pflocal/sock.c | 4 |
4 files changed, 28 insertions, 0 deletions
diff --git a/pflocal/ChangeLog b/pflocal/ChangeLog index eb0f1fb1..80708cac 100644 --- a/pflocal/ChangeLog +++ b/pflocal/ChangeLog @@ -1,3 +1,10 @@ +2001-02-11 Marcus Brinkmann <marcus@gnu.org> + + * connq.c (connq_destroy): New function. + * connq.h: Prototype connq_destroy. + * sock.c (sock_free): Call connq_destroy when listen or connect + queue exist. + 2000-08-09 Mark Kettenis <kettenis@gnu.org> * pf.c (S_socket_create): Only accept S_IFCHR, S_IFSOCK and diff --git a/pflocal/connq.c b/pflocal/connq.c index 862c9a14..2b8d68a4 100644 --- a/pflocal/connq.c +++ b/pflocal/connq.c @@ -108,6 +108,20 @@ connq_create (struct connq **cq) *cq = new; return 0; } + +/* Destroy a queue. */ +void +connq_destroy (struct connq *cq) +{ + /* Everybody in the queue should hold a reference to the socket + containing the queue. */ + assert (cq->length == 0); + /* Nevertheless, malloc(0) or realloc(0) might allocate some small + space. */ + if (cq->queue) + free (cq->queue); + free (cq); +} /* ---------------------------------------------------------------- */ diff --git a/pflocal/connq.h b/pflocal/connq.h index 8486eb17..1039bff9 100644 --- a/pflocal/connq.h +++ b/pflocal/connq.h @@ -33,6 +33,9 @@ struct sock; is already listening (change this with connq_set_length). */ 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 diff --git a/pflocal/sock.c b/pflocal/sock.c index dffd6bf7..f37a2350 100644 --- a/pflocal/sock.c +++ b/pflocal/sock.c @@ -136,6 +136,10 @@ sock_free (struct sock *sock) sock_shutdown (sock, SOCK_SHUTDOWN_READ | SOCK_SHUTDOWN_WRITE); if (sock->id != MACH_PORT_NULL) mach_port_destroy (mach_task_self (), sock->id); + if (sock->listen_queue) + connq_destroy (sock->listen_queue); + if (sock->connect_queue) + connq_destroy (sock->connect_queue); free (sock); } |