0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2025-01-03 07:31:54 +00:00

Socket closing has its dedicated function

This commit is contained in:
Maria Matejka 2023-04-20 21:06:42 +02:00
parent 074739e0e9
commit b3f805ce29
13 changed files with 23 additions and 22 deletions

View File

@ -88,6 +88,7 @@ sock *sock_new(pool *); /* Allocate new socket */
int sk_open(sock *, struct birdloop *); /* Open socket */
void sk_reloop(sock *, struct birdloop *); /* Move socket to another loop. Both loops must be locked. */
static inline void sk_close(sock *s) { rfree(&s->r); } /* Explicitly close socket */
int sk_rx_ready(sock *s);
_Bool sk_tx_pending(sock *s);

View File

@ -417,7 +417,7 @@ cli_free(cli *c)
if (defer)
{
rfree(c->sock);
sk_close(c->sock);
c->sock = NULL;
}
else

View File

@ -1680,7 +1680,7 @@ babel_open_socket(struct babel_iface *ifa)
err:
sk_log_error(sk, p->p.name);
rfree(sk);
sk_close(sk);
return 0;
}

View File

@ -604,10 +604,10 @@ bfd_free_iface(struct bfd_iface *ifa)
return;
if (ifa->sk)
rfree(ifa->sk);
sk_close(ifa->sk);
if (ifa->rx)
rfree(ifa->rx);
sk_close(ifa->rx);
rem_node(&ifa->n);
mb_free(ifa);

View File

@ -439,7 +439,7 @@ bfd_open_rx_sk(struct bfd_proto *p, int multihop, int af)
err:
sk_log_error(sk, p->p.name);
rfree(sk);
sk_close(sk);
return NULL;
}
@ -470,7 +470,7 @@ bfd_open_rx_sk_bound(struct bfd_proto *p, ip_addr local, struct iface *ifa)
err:
sk_log_error(sk, p->p.name);
rfree(sk);
sk_close(sk);
return NULL;
}
@ -501,6 +501,6 @@ bfd_open_tx_sk(struct bfd_proto *p, ip_addr local, struct iface *ifa)
err:
sk_log_error(sk, p->p.name);
rfree(sk);
sk_close(sk);
return NULL;
}

View File

@ -294,7 +294,7 @@ bgp_listen_create(void *_ UNUSED)
{
sk_log_error(sk, p->p.name);
log(L_ERR "%s: Cannot open listening socket", p->p.name);
rfree(sk);
sk_close(sk);
UNLOCK_DOMAIN(rtable, bgp_listen_domain);
bgp_initiate_disable(p, BEM_NO_SOCKET);
@ -335,7 +335,7 @@ bgp_listen_create(void *_ UNUSED)
WALK_LIST_DELSAFE(bs, nxt, bgp_sockets)
if (EMPTY_LIST(bs->requests))
{
rfree(bs->sk);
sk_close(bs->sk);
rem_node(&bs->n);
mb_free(bs);
}
@ -465,7 +465,7 @@ bgp_close_conn(struct bgp_conn *conn)
rfree(conn->tx_ev);
conn->tx_ev = NULL;
rfree(conn->sk);
sk_close(conn->sk);
conn->sk = NULL;
mb_free(conn->local_caps);
@ -1336,7 +1336,7 @@ bgp_incoming_connection(sock *sk, uint dummy UNUSED)
{
log(L_WARN "BGP: Unexpected connect from unknown address %I%J (port %d)",
sk->daddr, ipa_is_link_local(sk->daddr) ? sk->iface : NULL, sk->dport);
rfree(sk);
sk_close(sk);
return 0;
}
@ -1370,7 +1370,7 @@ bgp_incoming_connection(sock *sk, uint dummy UNUSED)
if (!acc)
{
rfree(sk);
sk_close(sk);
goto leave;
}
@ -1410,7 +1410,7 @@ bgp_incoming_connection(sock *sk, uint dummy UNUSED)
err:
sk_log_error(sk, p->p.name);
log(L_ERR "%s: Incoming connection aborted", p->p.name);
rfree(sk);
sk_close(sk);
leave:
birdloop_leave(p->p.loop);

View File

@ -173,7 +173,7 @@ ospf_sk_open(struct ospf_iface *ifa)
err:
sk_log_error(sk, p->p.name);
rfree(sk);
sk_close(sk);
return 0;
}
@ -234,7 +234,7 @@ ospf_open_vlink_sk(struct ospf_proto *p)
err:
sk_log_error(sk, p->p.name);
log(L_ERR "%s: Cannot open virtual link socket", p->p.name);
rfree(sk);
sk_close(sk);
}
static void

View File

@ -511,7 +511,7 @@ radv_sk_open(struct radv_iface *ifa)
err:
sk_log_error(sk, ifa->ra->p.name);
rfree(sk);
sk_close(sk);
return 0;
}

View File

@ -1040,6 +1040,6 @@ rip_open_socket(struct rip_iface *ifa)
err:
sk_log_error(sk, p->p.name);
rfree(sk);
sk_close(sk);
return 0;
}

View File

@ -750,7 +750,7 @@ rip_remove_iface(struct rip_proto *p, struct rip_iface *ifa)
rem_node(NODE ifa);
rfree(ifa->sk);
sk_close(ifa->sk);
rfree(ifa->lock);
rfree(ifa->timer);

View File

@ -120,7 +120,7 @@ rpki_tr_close(struct rpki_tr_sock *tr)
if (tr->sk)
{
rfree(tr->sk);
sk_close(tr->sk);
tr->sk = NULL;
}
}

View File

@ -1118,7 +1118,7 @@ krt_sock_close_shared(void)
if (!krt_sock_count)
{
rfree(krt_sock);
sk_close(krt_sock);
krt_sock = NULL;
}
}
@ -1181,7 +1181,7 @@ krt_sys_shutdown(struct krt_proto *p)
{
krt_table_cf[(KRT_CF->sys.table_id)/32][!!(p->af == AF_INET6)] &= ~(1 << ((KRT_CF->sys.table_id)%32));
rfree(p->sys.sk);
sk_close(p->sys.sk);
p->sys.sk = NULL;
krt_buffer_release(&p->p);

View File

@ -1081,7 +1081,7 @@ sk_passive_connected(sock *s, int type)
/* FIXME: handle it better in rfree() */
close(t->fd);
t->fd = -1;
rfree(t);
sk_close(t);
return 1;
}