summaryrefslogtreecommitdiff
path: root/pflocal
diff options
context:
space:
mode:
authorRichard Braun <rbraun@sceen.net>2013-10-18 01:16:07 +0200
committerRichard Braun <rbraun@sceen.net>2013-10-18 01:16:07 +0200
commit4660ac02b9723380b4581b4c6a46e54861b95059 (patch)
tree0db9e3bb2dd4758eb7decdb9eedb1e1b0d9bd0c6 /pflocal
parent1cfdceba98c380ad1cebb3a6b3d1f141d852c691 (diff)
pflocal: fix destruction of explicitely bound sockets
Sockets must have a weak reference on the address they're bound to so that addr_unbind is properly called before addr_clean. For sockets that are automatically bound, this weak reference is created in ensure_addr. Do the same in sock_bind. * pflocal/sock.c (sock_bind): Handle weak reference on addr.
Diffstat (limited to 'pflocal')
-rw-r--r--pflocal/sock.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/pflocal/sock.c b/pflocal/sock.c
index 2641e1c5..8076dd36 100644
--- a/pflocal/sock.c
+++ b/pflocal/sock.c
@@ -294,12 +294,16 @@ sock_bind (struct sock *sock, struct addr *addr)
{
sock->addr = addr;
if (addr)
- sock->refs++;
+ {
+ sock->refs++;
+ ports_port_ref_weak (addr);
+ }
if (old_addr)
{
/* Note that we don't have to worry about SOCK's ref count going to
zero because whoever's calling us should be holding a ref. */
sock->refs--;
+ ports_port_deref_weak (addr);
assert (sock->refs > 0); /* But make sure... */
}
}