Improve patty_ax25_sock_destroy() for raw sockets
Changes: * Don't clear socket from an interface's promiscuous socket table if the socket state is not SOCK_PROMISC * Destroy socket TNC if socket type is SOCK_RAW * Only attempt to close socket file descriptors >0
This commit is contained in:
parent
acaa5dee0f
commit
a1ec1e00d0
1 changed files with 5 additions and 5 deletions
10
src/sock.c
10
src/sock.c
|
@ -186,16 +186,16 @@ error_malloc_sock:
|
||||||
}
|
}
|
||||||
|
|
||||||
void patty_ax25_sock_destroy(patty_ax25_sock *sock) {
|
void patty_ax25_sock_destroy(patty_ax25_sock *sock) {
|
||||||
if (sock->fd) {
|
if (sock->type == PATTY_AX25_SOCK_RAW) {
|
||||||
if (sock->iface) {
|
if (sock->state == PATTY_AX25_SOCK_PROMISC) {
|
||||||
(void)patty_ax25_if_promisc_delete(sock->iface, sock->fd);
|
(void)patty_ax25_if_promisc_delete(sock->iface, sock->fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
close(sock->fd);
|
patty_kiss_tnc_destroy(sock->raw);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sock->raw) {
|
if (sock->fd > 0) {
|
||||||
patty_kiss_tnc_destroy(sock->raw);
|
(void)close(sock->fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
free(sock->tx_slots);
|
free(sock->tx_slots);
|
||||||
|
|
Loading…
Add table
Reference in a new issue