Remove socket when closing UDS transport.

[RC: added cast to sockaddr to avoid compiler warning. ]

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
master
Miroslav Lichvar 2014-07-08 16:14:19 +02:00 committed by Richard Cochran
parent 28865f91df
commit 2423357754
1 changed files with 8 additions and 0 deletions

8
uds.c
View File

@ -42,6 +42,14 @@ struct uds {
static int uds_close(struct transport *t, struct fdarray *fda) static int uds_close(struct transport *t, struct fdarray *fda)
{ {
struct sockaddr_un sa;
socklen_t len = sizeof(sa);
if (!getsockname(fda->fd[FD_GENERAL], (struct sockaddr *) &sa, &len) &&
sa.sun_family == AF_LOCAL) {
unlink(sa.sun_path);
}
close(fda->fd[FD_GENERAL]); close(fda->fd[FD_GENERAL]);
return 0; return 0;
} }