From 4660ac02b9723380b4581b4c6a46e54861b95059 Mon Sep 17 00:00:00 2001 From: Richard Braun Date: Fri, 18 Oct 2013 01:16:07 +0200 Subject: 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. --- pflocal/sock.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'pflocal') 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... */ } } -- cgit v1.2.3